Skip to content

Commit f36acdf

Browse files
authored
docs: fix 404 for names with dashes in docs (#99)
* docs: fix names with dashes * chore: ignore type error * change tests * undo
1 parent 5e1fb5a commit f36acdf

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
if: runner.os != 'Windows'
6161
run: |
6262
python -m pip install -e .[test_thirdparty] ${{ github.event_name == 'schedule' && '--pre' || '' }}
63-
python -m pip install PyQt6==6.5.3
63+
python -m pip install PyQt6==6.8.1
6464
6565
- name: Run test
6666
if: runner.os != 'Windows'

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ repos:
3434
- id: mypy
3535
files: "^src/"
3636
additional_dependencies:
37-
- numpy>=2
37+
- numpy>=2.2

docs/_gen_cmaps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def build_catalog(catalog: "_catalog.Catalog") -> None:
9696
except KeyError as e:
9797
raise KeyError(f"Missing info for {name}: {e}") from e
9898

99+
# FIXME: not a great way to determine aliases...
100+
# prone to false positives if normalization is not perfect/consistent
99101
if info.qualified_name.lower() != name.lower():
100102
# skip aliases
101103
continue

src/cmap/_catalog.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import json
1212
import logging
13+
import warnings
1314
from collections.abc import Container, Iterable, Iterator, Mapping
1415
from dataclasses import dataclass, field
1516
from pathlib import Path
@@ -197,6 +198,17 @@ def _build_catalog(records: Iterable[FileDescriptorOrPath]) -> CatalogDict:
197198
)
198199
ctlg[f"{namespace}{NAMESPACE_DELIMITER}{alias}"] = {"alias": namespaced}
199200

201+
if dashed_names := {
202+
k for k in ctlg if "-" in k and "alias" not in ctlg[k]
203+
}: # pragma: no cover
204+
warnings.warn(
205+
f"The following colormap names contain dashes in the record.json: "
206+
f"{dashed_names}.\n\n"
207+
"This is unsupported and will cause issues for docs. "
208+
"Please use underscores instead.",
209+
stacklevel=2,
210+
)
211+
200212
return ctlg
201213

202214

src/cmap/_colormap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ def _mpl_segmentdata_to_stops(
13991399
alpha = np.ones_like(all_positions)
14001400

14011401
rgba = np.stack([*rgb, alpha], axis=1)
1402-
return [(a, tuple(b)) for a, b in zip(all_positions, rgba.tolist())]
1402+
return [(a, tuple(b)) for a, b in zip(all_positions, rgba.tolist())] # type: ignore
14031403

14041404

14051405
def _make_identifier(name: str) -> str:

src/cmap/data/tol/record.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"data": "cmap.data.tol:bright",
4040
"interpolation": false
4141
},
42-
"bright-alt": {
42+
"bright_alt": {
4343
"category": "qualitative",
4444
"data": "cmap.data.tol:bright_alt",
4545
"interpolation": false
@@ -49,12 +49,12 @@
4949
"data": "cmap.data.tol:dark",
5050
"interpolation": false
5151
},
52-
"high-contrast": {
52+
"high_contrast": {
5353
"category": "qualitative",
5454
"data": "cmap.data.tol:high_contrast",
5555
"interpolation": false
5656
},
57-
"high-contrast-alt": {
57+
"high_contrast_alt": {
5858
"category": "qualitative",
5959
"data": "cmap.data.tol:high_contrast_alt",
6060
"interpolation": false
@@ -72,17 +72,17 @@
7272
"data": "cmap.data.tol:light",
7373
"interpolation": false
7474
},
75-
"light-alt": {
75+
"light_alt": {
7676
"category": "qualitative",
7777
"data": "cmap.data.tol:light_alt",
7878
"interpolation": false
7979
},
80-
"medium-contrast": {
80+
"medium_contrast": {
8181
"category": "qualitative",
8282
"data": "cmap.data.tol:medium_contrast",
8383
"interpolation": false
8484
},
85-
"medium-contrast-alt": {
85+
"medium_contrast_alt": {
8686
"category": "qualitative",
8787
"data": "cmap.data.tol:medium_contrast_alt",
8888
"interpolation": false
@@ -92,7 +92,7 @@
9292
"data": "cmap.data.tol:muted",
9393
"interpolation": false
9494
},
95-
"muted-alt": {
95+
"muted_alt": {
9696
"category": "qualitative",
9797
"data": "cmap.data.tol:muted_alt",
9898
"interpolation": false
@@ -256,7 +256,7 @@
256256
"data": "cmap.data.tol:vibrant",
257257
"interpolation": false
258258
},
259-
"vibrant-alt": {
259+
"vibrant_alt": {
260260
"category": "qualitative",
261261
"data": "cmap.data.tol:vibrant_alt",
262262
"interpolation": false

0 commit comments

Comments
 (0)