Skip to content

Commit

Permalink
switch to mkdocstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Sep 6, 2024
1 parent 3a3f3a4 commit 1768f71
Show file tree
Hide file tree
Showing 21 changed files with 65 additions and 8,310 deletions.
33 changes: 4 additions & 29 deletions .github/workflows/deploy_mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install numpy
python -m pip install -e .["docs"]
python -m pip install git+https://github.com/timothycrosley/pdocs
- name: update API docs
run: |
pdocs as_markdown \
--output_dir docs/src/api/ \
--exclude_source \
--overwrite \
rio_tiler.colormap \
rio_tiler.constants \
rio_tiler.errors \
rio_tiler.expression \
rio_tiler.models \
rio_tiler.io.base \
rio_tiler.io.rasterio \
rio_tiler.io.stac \
rio_tiler.io.xarray \
rio_tiler.mosaic.methods.base \
rio_tiler.mosaic.methods.defaults \
rio_tiler.mosaic.reader \
rio_tiler.profiles \
rio_tiler.reader \
rio_tiler.tasks \
rio_tiler.utils
- name: Deploy docs
run: mkdocs gh-deploy -f docs/mkdocs.yml --force
34 changes: 33 additions & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,33 @@ nav:
plugins:
- search
- mkdocs-jupyter:
include_source: True
include_source: true
ignore: ["**/.ipynb_checkpoints/*.ipynb"]
- mkdocstrings:
enable_inventory: true
handlers:
python:
paths: [src]
options:
filters:
- "!^__post_init__"
docstring_section_style: list
docstring_style: google
line_length: 100
separate_signature: true
show_root_heading: true
show_signature_annotations: true
show_source: false
show_symbol_type_toc: true
signature_crossrefs: true
extensions:
- griffe_inherited_docstrings
import:
- https://docs.python.org/3/objects.inv
- https://numpy.org/doc/stable/objects.inv
- https://rasterio.readthedocs.io/en/stable/objects.inv
- https://docs.pydantic.dev/latest/objects.inv
- https://developmentseed.org/morecantile/objects.inv

# Theme
theme:
Expand All @@ -94,6 +118,14 @@ theme:
text: 'Nunito Sans'
code: 'Fira Code'
custom_dir: 'src/overrides'
features:
- content.code.annotate
- content.code.copy
- navigation.indexes
- navigation.instant
- navigation.tracking
- search.suggest
- search.share

# These extensions are chosen to be a superset of Pandoc's Markdown.
# This way, I can write in Pandoc's Markdown and have it be supported here.
Expand Down
233 changes: 1 addition & 232 deletions docs/src/api/rio_tiler/colormap.md
Original file line number Diff line number Diff line change
@@ -1,232 +1 @@
# Module rio_tiler.colormap

rio-tiler colormap functions and classes.

None

## Variables

```python3
DEFAULT_CMAPS_FILES
```

```python3
EMPTY_COLORMAP
```

```python3
USER_CMAPS_DIR
```

```python3
cmap
```

## Functions


### apply_cmap

```python3
def apply_cmap(
data: numpy.ndarray,
colormap: Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]]]
) -> Tuple[numpy.ndarray, numpy.ndarray]
```


Apply colormap on data.

**Parameters:**

| Name | Type | Description | Default |
|---|---|---|---|
| data | numpy.ndarray | 1D image array to translate to RGB. | None |
| colormap | dict or sequence | GDAL RGBA Color Table dictionary or sequence (for intervals). | None |

**Returns:**

| Type | Description |
|---|---|
| tuple | Data (numpy.ndarray) and Mask (numpy.ndarray) values. |

**Raises:**

| Type | Description |
|---|---|
| InvalidFormat | If data is not a 1 band dataset (1, col, row). |


### apply_discrete_cmap

```python3
def apply_discrete_cmap(
data: numpy.ndarray,
colormap: Dict[int, Tuple[int, int, int, int]]
) -> Tuple[numpy.ndarray, numpy.ndarray]
```


Apply discrete colormap.

**Parameters:**

| Name | Type | Description | Default |
|---|---|---|---|
| data | numpy.ndarray | 1D image array to translate to RGB. | None |
| color_map | dict | Discrete ColorMap dictionary. | None |

**Returns:**

| Type | Description |
|---|---|
| tuple | Data (numpy.ndarray) and Alpha band (numpy.ndarray). |


### apply_intervals_cmap

```python3
def apply_intervals_cmap(
data: numpy.ndarray,
colormap: Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]]
) -> Tuple[numpy.ndarray, numpy.ndarray]
```


Apply intervals colormap.

**Parameters:**

| Name | Type | Description | Default |
|---|---|---|---|
| data | numpy.ndarray | 1D image array to translate to RGB. | None |
| color_map | Sequence | Sequence of intervals and color in form of [([min, max], [r, g, b, a]), ...]. | None |

**Returns:**

| Type | Description |
|---|---|
| tuple | Data (numpy.ndarray) and Alpha band (numpy.ndarray). |


### make_lut

```python3
def make_lut(
colormap: Dict[int, Tuple[int, int, int, int]]
) -> numpy.ndarray
```


Create a lookup table numpy.ndarray from a GDAL RGBA Color Table dictionary.

**Parameters:**

| Name | Type | Description | Default |
|---|---|---|---|
| colormap | dict | GDAL RGBA Color Table dictionary. | None |

**Returns:**

| Type | Description |
|---|---|
| numpy.ndarray | colormap lookup table. |


### parse_color

```python3
def parse_color(
rgba: Union[Sequence[int], str]
) -> Tuple[int, int, int, int]
```


Parse RGB/RGBA color and return valid rio-tiler compatible RGBA colormap entry.

**Parameters:**

| Name | Type | Description | Default |
|---|---|---|---|
| rgba | str or list of int | HEX encoded or list RGB or RGBA colors. | None |

**Returns:**

| Type | Description |
|---|---|
| tuple | RGBA values. |

## Classes

### ColorMaps

```python3
class ColorMaps(
data: Dict[str, Union[str, Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]]]] = NOTHING
)
```

#### Attributes

| Name | Type | Description | Default |
|---|---|---|---|
| data | dict | colormaps. Defaults to `rio_tiler.colormap.DEFAULTS_CMAPS`. | `rio_tiler.colormap.DEFAULTS_CMAPS` |

#### Methods


#### get

```python3
def get(
self,
name: str
) -> Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]]]
```


Fetch a colormap.

**Parameters:**

| Name | Type | Description | Default |
|---|---|---|---|
| name | str | colormap name.
Returns | None |
| dict | None | colormap dictionary. | None |


#### list

```python3
def list(
self
) -> List[str]
```


List registered Colormaps.

Returns
list: list of colormap names.


#### register

```python3
def register(
self,
custom_cmap: Dict[str, Union[str, Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]]]],
overwrite: bool = False
) -> 'ColorMaps'
```


Register a custom colormap.

**Parameters:**

| Name | Type | Description | Default |
|---|---|---|---|
| custom_cmap | dict | custom colormap(s) to register. | None |
| overwrite | bool | Overwrite existing colormap with same key. Defaults to False. | False |
::: rio_tiler.colormap
26 changes: 3 additions & 23 deletions docs/src/api/rio_tiler/constants.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
# Module rio_tiler.constants

rio-tiler constant values.

None

## Variables

```python3
MAX_THREADS
```

```python3
WEB_MERCATOR_CRS
```

```python3
WEB_MERCATOR_TMS
```

```python3
WGS84_CRS
```
::: rio_tiler.constants
options:
show_source: true
Loading

0 comments on commit 1768f71

Please sign in to comment.