Skip to content

Commit 00ceed1

Browse files
authored
docs: update docs and use api-autonav (#93)
* docs: use api-autonav * more updates * typing * fixes * more links * fix union * py38 * lint * fix 38 again
1 parent a0c9c55 commit 00ceed1

File tree

15 files changed

+194
-90
lines changed

15 files changed

+194
-90
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ repos:
99
- repo: https://github.com/pre-commit/pre-commit-hooks
1010
rev: v5.0.0
1111
hooks:
12-
- id: check-docstring-first
1312
- id: end-of-file-fixer
1413
- id: trailing-whitespace
1514
- id: pretty-format-json

docs/api/color.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/api/colormap.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/catalog/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cmap = Colormap('viridis')
1616
`matplotlib.colors.Colormap` instance, you may call
1717
[`.to_mpl()`][cmap.Colormap.to_matplotlib].
1818

19-
See the [Colormap API docs](../api/colormap.md) for details.
19+
See the [Colormap API docs][cmap.Colormap] for details.
2020

2121
<!--
2222
With that object you can do things like:

docs/colormaps.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# Colormaps
22

3-
The `cmap.Colormap` type represents a colormap.
3+
The [`cmap.Colormap`][cmap.Colormap] type represents a colormap.
44

5-
Also known as a LUT (look-up table), a colormap is a mapping from a scalar value to a color. Colormaps are used in a variety of contexts, including image processing, data visualization, and scientific visualization. The `cmap` library provides a [number of built-in colormaps](catalog/index.md), including all of the colormaps in matplotlib, napari, vispy, and more.
5+
Also known as a LUT (look-up table), a colormap is a mapping from a scalar value
6+
to a color. Colormaps are used in a variety of contexts, including image
7+
processing, data visualization, and scientific visualization. The `cmap`
8+
library provides a [number of built-in colormaps](catalog/index.md), including
9+
all of the colormaps in matplotlib, cmocean, colorbrewer, colorcet, crameri, and
10+
more.
611

712
```python
813
from cmap import Colormap
@@ -15,7 +20,7 @@ cm = Colormap('viridis')
1520

1621
The following objects can be interpreted as a colormap, and used as the first argument
1722
to the [`cmap.Colormap`][] constructor; `cmap` refers to these objects collectively as
18-
"`ColormapLike`". Briefly, valid arguments are of type:
23+
["`ColormapLike`"][cmap.ColormapLike]. Briefly, valid arguments are of type:
1924

2025
- [⬇️ `str`](#str)
2126
- [⬇️ `Iterable[ColorLike | tuple[float, ColorLike]]`](#iterablecolorlike-tuple) *(see [`ColorLike`](colors.md#colorlike-objects))*
@@ -300,7 +305,7 @@ external visualization libraries. To that end, `cmap.Colormap` provides
300305
`to_<libname>()` methods for a number of libraries:
301306

302307
!!!tip
303-
Some of these methods take additional arguments, see [Colormap API](api/colormap.md)
308+
Some of these methods take additional arguments, see [Colormap API][cmap.Colormap]
304309
for details.
305310

306311
- [matplotlib](https://matplotlib.org/)

docs/faq.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ Namespaces are directories in the `src/cmap/data` folder.
99

1010
- If the colormap is part of known broader collection (e.g., `cet`, `cmocean`,
1111
`colorbrewer`, etc.), please check to see whether the collection already
12-
exists in the `cmap/data` directory. If so, please extend that collection.
13-
If not, please create a new namespace and directory for that collection.
12+
exists in the [`cmap/data`
13+
directory](https://github.com/pyapp-kit/cmap/tree/main/src/cmap/data). If so,
14+
please extend that collection. If not, please create a new namespace and
15+
directory for that collection.
1416
- If you would like to contribute a colormap that doesn't nicely fit into an
1517
broader collection of colormaps (regardless of whether that collection exists
1618
in `cmap`), please contribute to the `cmap/contrib` namespace.
@@ -24,7 +26,7 @@ Once you have picked a namespace:
2426
in the `record.json` file. The key should be the name of the colormap, and
2527
the value should be an object with the following keys:
2628
- `data`: either a direct
27-
[`ColormapLike` data](https://cmap-docs.readthedocs.io/en/stable/colormaps/#colormaplike-objects)
29+
[`ColormapLike` data](colormaps.md#colormaplike-objects)
2830
entry, such as an array of RGB values; or a
2931
string pointing to the python-path of colormap data in the form of
3032
`cmap.data.<namespace>:<colormap>`.
@@ -57,8 +59,10 @@ Once you have picked a namespace:
5759
]
5860
```
5961

60-
**It may be helpful to look at existing folders and files in the
61-
`cmap/data` directory for examples of how to structure the data.**
62+
!!!tip
63+
It may be helpful to look at existing folders and files in the
64+
[`cmap/data` directory](https://github.com/pyapp-kit/cmap/tree/main/src/cmap/data)
65+
for examples of how to structure the data
6266

6367
When opening a PR, please include a screenshot of the colormap, along
6468
with a brief description of the colormap design and its intended use.
@@ -74,7 +78,7 @@ with a brief description of the colormap design and its intended use.
7478
## How can I add support for exporting to another colormap format?
7579

7680
cmap [exports to a variety of known third-party colormap
77-
formats](https://cmap-docs.readthedocs.io/en/latest/colormaps/#usage-with-external-visualization-libraries).
81+
formats](colormaps.md#usage-with-external-visualization-libraries).
7882

7983
If you are the author (or user) of a library that consumes colormaps, and you
8084
would like to have a `to_your_lib()` function in `cmap`, we welcome

docs/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Overview
22

3-
`cmap` is a work-in-progress colormap library for python, providing all of the
4-
colormaps in matplotlib, vispy, cmocean, (and more), with no dependencies beyond
5-
numpy.
3+
`cmap` is a colormap library for python, providing all of the colormaps in
4+
matplotlib, vispy, cmocean, (and more), with no dependencies beyond numpy.
65

76
## Purpose
87

98
Mapping scalar values to colors is a very common procedure in scientific
109
visualization; as such, many visualization libraries (e.g. matplotlib, vispy,
11-
napari, etc...) have some need for and some internal representation of colors
10+
pygfx, etc...) have some need for and some internal representation of colors
1211
and colormaps.
1312

1413
!!!question "Don't we already have this?"
@@ -29,20 +28,21 @@ and colormaps.
2928
beyond numpy. (by "applying" here, we mean converting an array of scalar
3029
values to an array of RGBA values)
3130
3. Provide an API for converting colormaps to the native format for a variety of
32-
third party libraries (currently including, matplotlib, napari, vispy, pygfx,
33-
bokeh, plotly, altair, and more)
31+
third party libraries (such as matplotlib, napari, vispy, pygfx,
32+
bokeh, plotly, altair,
33+
[and more](https://github.com/pyapp-kit/cmap/blob/main/src/cmap/_external.py))
3434

3535
## Colormaps
3636

3737
For a complete list of available colormaps, see the [Colormaps
3838
catalog](catalog/index.md). You can also use the search bar at the top to search
3939
for a specific colormap.
4040

41-
For details on using the `cmap.Colormap` object, see [Colormaps](colormaps.md).
41+
For details on using the [`cmap.Colormap`][cmap.Colormap] object, see [Colormaps](colormaps.md).
4242

4343
## Colors
4444

45-
This library also offers a simple `cmap.Color` object. It can cast a variety of
45+
This library also offers a simple [`cmap.Color`][cmap.Color] object. It can cast a variety of
4646
inputs (including strings, tuples/lists, arrays, integers) to an RGBA color
4747
representation, and offers some basic conversions. See [Colors](colors.md) for
4848
details

mkdocs.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ nav:
1414
- Colors: colors.md
1515
- Colormaps: colormaps.md
1616
- Colormap Catalog: catalog/
17-
- API: api/
1817
- FAQ: faq.md
1918

2019
theme:
@@ -68,7 +67,11 @@ hooks:
6867
plugins:
6968
- search:
7069
separator: '[\s\-\_,:!=\[\]()"/]+|(?!\b)(?=[A-Z][a-z])|\.(?!\d)|&[lg]t;'
71-
- autorefs
70+
- autorefs:
71+
resolve_closest: true
72+
- api-autonav:
73+
modules: ['src/cmap']
74+
exclude: ['cmap.data']
7275
- literate-nav:
7376
implicit_index: true
7477
nav_file: SUMMARY.md
@@ -89,7 +92,7 @@ plugins:
8992
- mkdocstrings:
9093
handlers:
9194
python:
92-
import:
95+
inventories:
9396
- https://docs.python.org/3/objects.inv
9497
- https://numpy.org/doc/stable/objects.inv
9598
options:
@@ -105,6 +108,14 @@ plugins:
105108
docstring_section_style: list
106109
merge_init_into_class: true
107110

111+
filters: ['(__call__|^[^_])']
112+
heading_level: 1
113+
parameter_headings: true
114+
separate_signature: true
115+
show_symbol_type_heading: true
116+
show_symbol_type_toc: true
117+
summary: true
118+
108119
extra_css:
109120
- stylesheets/extra.css
110121

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ docs = [
3535
'imageio',
3636
'mkdocs-gen-files',
3737
'mkdocs-literate-nav',
38+
'mkdocs-api-autonav',
3839
'mkdocs-material',
3940
'mkdocs-minify-plugin',
4041
'mkdocs',

src/cmap/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
__version__ = "uninstalled"
1010

1111

12-
from ._color import HSLA, HSVA, RGBA, RGBA8, Color
13-
from ._colormap import Colormap, ColorStops
12+
from ._color import HSLA, HSVA, RGBA, RGBA8, Color, ColorLike
13+
from ._colormap import Colormap, ColormapLike, ColorStop, ColorStops
1414

1515
if TYPE_CHECKING:
1616
from ._catalog import CatalogItem
@@ -69,6 +69,9 @@ def resolve(self, name: str) -> str:
6969
"Catalog",
7070
"CatalogItem",
7171
"Color",
72+
"ColorLike",
73+
"ColorStop",
7274
"ColorStops",
7375
"Colormap",
76+
"ColormapLike",
7477
]

0 commit comments

Comments
 (0)