Skip to content

Commit 44a0ee3

Browse files
authored
Fix API doc build (#556)
* Error on doc build warnings * Add missing maxdepth parameter value * Restore docs build steps which installed jupytergis wheels Unclear why removed in #412 * Remove pip install from build_packages.py Setting up the environment should probably be decoupled from the build helper script. * Try build _then_ build:packages This actually worked locally 🙏 * Fix type annotation errors * Fix docutils warning ``` /home/docs/micromamba/envs/jupytergis-docs/lib/python3.12/site-packages/jupytergis_lab/notebook/gis_document.py:docstring of jupytergis_lab.notebook.gis_document.GISDocument:5: WARNING: Field list ends without a blank line; unexpected unindent. [docutils] ``` * Remove undefined `_type_` type * Fix some broken type documentation * Bugfix: Remove mutable default arguments
1 parent 1f0c03d commit 44a0ee3

File tree

5 files changed

+52
-37
lines changed

5 files changed

+52
-37
lines changed

.readthedocs.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,17 @@ build:
3737
pre_build:
3838
- /bin/bash --login -c "micromamba run -n jupytergis-build jlpm install"
3939
- /bin/bash --login -c "micromamba run -n jupytergis-build jlpm build"
40+
- /bin/bash --login -c "micromamba run -n jupytergis-build jlpm build:packages"
41+
- |-
42+
/bin/bash --login -c "micromamba run -n jupytergis-docs \
43+
python -m pip install \
44+
$(ls ./python/jupytergis_core/dist/jupytergis*.whl) \
45+
$(ls ./python/jupytergis_lab/dist/jupytergis*.whl) \
46+
$(ls ./python/jupytergis_qgis/dist/jupytergis*.whl)"
4047
4148
build:
4249
html:
4350
- |-
4451
/bin/bash --login -c "cd docs && micromamba run -n jupytergis-docs \
45-
python -m sphinx -T -b html -d _build/doctrees -D language=en . \
52+
python -m sphinx --fail-on-warning --keep-going --nitpicky --show-traceback --builder html --doctree-dir _build/doctrees --define language=en . \
4653
$READTHEDOCS_OUTPUT/html"

docs/user_guide/features/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Features
22

33
```{toctree}
4-
:maxdepth:
4+
:maxdepth: 2
55
66
extension.rst
77
collab.rst

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,7 @@ extend-include = ["*.ipynb"]
4444
select = [
4545
# pycodestyle
4646
"E",
47+
# bugbear: Disallow mutable argument defaults
48+
"B006",
4749
]
4850
ignore = ["E501", "E731"]

python/jupytergis_lab/jupytergis_lab/notebook/gis_document.py

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class GISDocument(CommWidget):
4343
"""
4444
Create a new GISDocument object.
4545
46-
:param path: the path to the file that you would like to open.
47-
If not provided, a new empty document will be created.
46+
:param path: the path to the file that you would like to open. If not provided, a new empty document will be created.
4847
"""
4948

5049
def __init__(
@@ -234,7 +233,7 @@ def add_geojson_layer(
234233
logical_op: str | None = None,
235234
feature: str | None = None,
236235
operator: str | None = None,
237-
value: Union[str, number, float] | None = None,
236+
value: Union[str, int, float] | None = None,
238237
color_expr=None,
239238
):
240239
"""
@@ -244,7 +243,6 @@ def add_geojson_layer(
244243
:param path: The path to the JSON file to embed into the jGIS file.
245244
:param data: The raw GeoJSON data to embed into the jGIS file.
246245
:param type: The type of the vector layer to create.
247-
:param color: The color to apply to features.
248246
:param opacity: The opacity, between 0 and 1.
249247
:param color_expr: The style expression used to style the layer, defaults to None
250248
"""
@@ -334,9 +332,9 @@ def add_image_layer(
334332

335333
def add_video_layer(
336334
self,
337-
urls: [],
335+
urls: List,
338336
name: str = "Image Layer",
339-
coordinates: [] = [],
337+
coordinates: Optional[List] = None,
340338
opacity: float = 1,
341339
):
342340
"""
@@ -347,6 +345,8 @@ def add_video_layer(
347345
:param coordinates: Corners of video specified in longitude, latitude pairs.
348346
:param opacity: The opacity, between 0 and 1.
349347
"""
348+
if coordinates is None:
349+
coordinates = []
350350

351351
if urls is None or coordinates is None:
352352
raise ValueError("URLs and Coordinates are required")
@@ -383,14 +383,14 @@ def add_tiff_layer(
383383
"""
384384
Add a tiff layer
385385
386-
:param str url: URL of the tif
387-
:param int min: Minimum pixel value to be displayed, defaults to letting the map display set the value
388-
:param int max: Maximum pixel value to be displayed, defaults to letting the map display set the value
389-
:param str name: The name that will be used for the object in the document, defaults to "Tiff Layer"
390-
:param bool normalize: Select whether to normalize values between 0..1, if false than min/max have no effect, defaults to True
391-
:param bool wrapX: Render tiles beyond the tile grid extent, defaults to False
392-
:param float opacity: The opacity, between 0 and 1, defaults to 1.0
393-
:param _type_ color_expr: The style expression used to style the layer, defaults to None
386+
:param url: URL of the tif
387+
:param min: Minimum pixel value to be displayed, defaults to letting the map display set the value
388+
:param max: Maximum pixel value to be displayed, defaults to letting the map display set the value
389+
:param name: The name that will be used for the object in the document, defaults to "Tiff Layer"
390+
:param normalize: Select whether to normalize values between 0..1, if false than min/max have no effect, defaults to True
391+
:param wrapX: Render tiles beyond the tile grid extent, defaults to False
392+
:param opacity: The opacity, between 0 and 1, defaults to 1.0
393+
:param color_expr: The style expression used to style the layer, defaults to None
394394
"""
395395

396396
source = {
@@ -421,7 +421,7 @@ def add_hillshade_layer(
421421
self,
422422
url: str,
423423
name: str = "Hillshade Layer",
424-
urlParameters: Dict = {},
424+
urlParameters: Optional[Dict] = None,
425425
attribution: str = "",
426426
):
427427
"""
@@ -431,6 +431,8 @@ def add_hillshade_layer(
431431
:param str name: The name that will be used for the object in the document, defaults to "Hillshade Layer"
432432
:param attribution: The attribution.
433433
"""
434+
if urlParameters is None:
435+
urlParameters = {}
434436

435437
source = {
436438
"type": SourceType.RasterDemSource,
@@ -454,14 +456,14 @@ def add_hillshade_layer(
454456

455457
def add_heatmap_layer(
456458
self,
457-
feature: string,
459+
feature: str,
458460
path: str | Path | None = None,
459461
data: Dict | None = None,
460462
name: str = "Heatmap Layer",
461463
opacity: float = 1,
462-
blur: number = 15,
463-
radius: number = 8,
464-
gradient: List[str] = ["#00f", "#0ff", "#0f0", "#ff0", "#f00"],
464+
blur: int = 15,
465+
radius: int = 8,
466+
gradient: Optional[List[str]] = None,
465467
):
466468
"""
467469
Add a Heatmap Layer to the document.
@@ -495,6 +497,9 @@ def add_heatmap_layer(
495497
if data is not None:
496498
parameters = {"data": data}
497499

500+
if gradient is None:
501+
gradient = ["#00f", "#0ff", "#0f0", "#ff0", "#f00"]
502+
498503
source = {
499504
"type": SourceType.GeoJSONSource,
500505
"name": f"{name} Source",
@@ -609,16 +614,16 @@ def add_filter(
609614
logical_op: str,
610615
feature: str,
611616
operator: str,
612-
value: Union[str, number, float],
617+
value: Union[str, int, float],
613618
):
614619
"""
615620
Add a filter to a layer
616621
617-
:param str layer_id: The ID of the layer to filter
618-
:param str logical_op: The logical combination to apply to filters. Must be "any" or "all"
619-
:param str feature: The feature to be filtered on
620-
:param str operator: The operator used to compare the feature and value
621-
:param Union[str, number, float] value: The value to be filtered on
622+
:param layer_id: The ID of the layer to filter
623+
:param logical_op: The logical combination to apply to filters. Must be "any" or "all"
624+
:param feature: The feature to be filtered on
625+
:param operator: The operator used to compare the feature and value
626+
:param value: The value to be filtered on
622627
"""
623628
layer = self._layers.get(layer_id)
624629

@@ -655,16 +660,16 @@ def update_filter(
655660
logical_op: str,
656661
feature: str,
657662
operator: str,
658-
value: Union[str, number, float],
663+
value: Union[str, int, float],
659664
):
660665
"""
661666
Update a filter applied to a layer
662667
663-
:param str layer_id: The ID of the layer to filter
664-
:param str logical_op: The logical combination to apply to filters. Must be "any" or "all"
665-
:param str feature: The feature to update the value for
666-
:param str operator: The operator used to compare the feature and value
667-
:param Union[str, number, float] value: The new value to be filtered on
668+
:param layer_id: The ID of the layer to filter
669+
:param logical_op: The logical combination to apply to filters. Must be "any" or "all"
670+
:param feature: The feature to update the value for
671+
:param operator: The operator used to compare the feature and value
672+
:param value: The new value to be filtered on
668673
"""
669674
layer = self._layers.get(layer_id)
670675

scripts/build_packages.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""Build all JupyterGIS packages.
2+
3+
IMPORTANT: Requires dependencies in requirements-build.txt
4+
"""
5+
16
import subprocess
27
from pathlib import Path
38

@@ -8,8 +13,6 @@ def execute(cmd: str, cwd=None):
813

914
def build_packages():
1015
root_path = Path(__file__).parents[1]
11-
requirements_build_path = root_path / "requirements-build.txt"
12-
install_build_deps = f"python -m pip install -r {requirements_build_path}"
1316

1417
python_package_prefix = "python"
1518
python_packages = [
@@ -20,8 +23,6 @@ def build_packages():
2023
"jupytergis_lite",
2124
]
2225

23-
execute(install_build_deps)
24-
2526
for py_package in python_packages:
2627
execute("hatch build", cwd=root_path / python_package_prefix / py_package)
2728

0 commit comments

Comments
 (0)