Skip to content

Commit a242959

Browse files
committed
Merge branch 'main' into 88-plotly-in-sphinx
2 parents 3076914 + e942b58 commit a242959

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+290
-276
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.1
2+
current_version = 0.3.0
33
commit = True
44
commit_args = -s
55
message = Release version {new_version}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Project specific
33
# ============================================================================
44

5+
docs/api/autogen
6+
docs/api/public
57
docs/examples_gallery_out/
68
docs/sg_execution_times.rst
79

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ repos:
1010
- id: check-ast
1111
- id: check-executables-have-shebangs
1212
- id: check-json
13+
exclude: ^pyrightconfig\.json$
1314
- id: check-merge-conflict
1415
- id: check-shebang-scripts-are-executable
1516
- id: check-symlinks
@@ -33,7 +34,7 @@ repos:
3334
- id: pretty-format-json
3435
args: [ --autofix, --no-sort-keys ]
3536
# ignore jupyter notebooks
36-
exclude: ^.*\.ipynb$
37+
exclude: (^.*\.ipynb$|^pyrightconfig\.json$)
3738
- id: pretty-format-json
3839
args: [ --autofix, --no-sort-keys, --indent=1, --no-ensure-ascii ]
3940
# only jupyter notebooks
@@ -101,7 +102,7 @@ repos:
101102
additional_dependencies: [setuptools-scm]
102103

103104
- repo: https://github.com/astral-sh/ruff-pre-commit
104-
rev: v0.8.1
105+
rev: v0.8.3
105106
hooks:
106107
- id: ruff-format
107108
- id: ruff

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ recursive-include docs/_templates *.html
3030
exclude docs/sg_execution_times.rst
3131
prune docs/examples_gallery_out
3232
prune docs/build
33+
prune docs/api/autogen
34+
prune docs/api/public
3335

3436
# Misc
3537
recursive-include .github *.yml *.yaml

cicd_utils/cicd/compile_plotly_charts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010

1111
from copy import deepcopy
1212
from pathlib import Path
13-
from typing import TYPE_CHECKING, Callable
13+
from typing import TYPE_CHECKING
1414

1515
from minify_html import minify
1616
from plotly.offline import get_plotlyjs
1717

1818
from ridgeplot_examples import ALL_EXAMPLES, tighten_margins
1919

2020
if TYPE_CHECKING:
21+
from collections.abc import Callable
22+
2123
import plotly.graph_objects as go
2224

2325

cicd_utils/ridgeplot_examples/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from __future__ import annotations
22

3-
from typing import Callable
3+
from typing import TYPE_CHECKING
44

55
import plotly.graph_objects as go
66

7+
if TYPE_CHECKING:
8+
from collections.abc import Callable
9+
710

811
def tighten_margins(fig: go.Figure, px: int = 0) -> go.Figure:
912
"""Tighten the margins of a Plotly figure."""

docs/api/index.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,3 @@ Data loading utilities
1919

2020
ridgeplot.datasets.load_probly
2121
ridgeplot.datasets.load_lincoln_weather
22-
23-
24-
Internals
25-
=========
26-
27-
.. toctree::
28-
:maxdepth: 1
29-
:glob:
30-
31-
internal/*

docs/api/internal/_color/colorscale.rst

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

docs/api/internal/_color/css_colors.rst

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

docs/api/internal/_color/interpolation.rst

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

docs/api/internal/_color/utils.rst

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

docs/api/internal/_obj/traces.rst

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

docs/api/internal/_obj/traces/area.rst

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

docs/api/internal/_obj/traces/bar.rst

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

docs/api/internal/_obj/traces/base.rst

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

docs/api/internal/color.rst

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

docs/api/internal/figure_factory.rst

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

docs/api/internal/hist.rst

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

docs/api/internal/kde.rst

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

docs/api/internal/missing.rst

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

docs/api/internal/obj.rst

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

docs/api/internal/types.rst

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

docs/api/internal/utils.rst

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

docs/api/public/ridgeplot.datasets.load_lincoln_weather.rst

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

docs/api/public/ridgeplot.datasets.load_probly.rst

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

docs/api/public/ridgeplot.list_all_colorscale_names.rst

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

docs/api/public/ridgeplot.ridgeplot.rst

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

docs/conf.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
try:
1111
import importlib.metadata as importlib_metadata
1212
except ImportError:
13-
import importlib_metadata # pyright: ignore[no-redef]
13+
import importlib_metadata
1414

1515
try:
1616
from cicd.compile_plotly_charts import compile_plotly_charts
@@ -56,8 +56,9 @@
5656
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
5757
# ones.
5858
extensions = [
59+
# https://myst-parser.readthedocs.io/en/v0.15.1/sphinx/intro.html
5960
"myst_parser",
60-
"notfound.extension",
61+
# https://www.sphinx-doc.org/en/master/usage/extensions/index.html
6162
"sphinx.ext.autodoc",
6263
"sphinx.ext.autosectionlabel",
6364
"sphinx.ext.autosummary",
@@ -79,10 +80,16 @@
7980
"sphinx_sitemap",
8081
"sphinx_thebe",
8182
"sphinx_togglebutton",
83+
# https://github.com/sphinx-contrib/apidoc
84+
"sphinxcontrib.apidoc",
85+
# https://github.com/sphinx-toolbox/sphinx-toolbox
8286
"sphinx_toolbox.collapse",
8387
"sphinx_toolbox.more_autodoc.autoprotocol",
8488
"sphinx_toolbox.more_autodoc.generic_bases",
89+
# https://github.com/wpilibsuite/sphinxext-opengraph
8590
"sphinxext.opengraph",
91+
# https://github.com/readthedocs/sphinx-notfound-page
92+
"notfound.extension",
8693
]
8794

8895
# Add any paths that contain templates here, relative to this directory.
@@ -207,6 +214,7 @@
207214
intersphinx_mapping = {
208215
"python": ("https://docs.python.org/3", None),
209216
"packaging": ("https://packaging.pypa.io/en/latest", None),
217+
"typing_extensions": ("https://typing-extensions.readthedocs.io/en/latest", None),
210218
"numpy": ("https://numpy.org/doc/stable/", None),
211219
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
212220
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
@@ -220,7 +228,14 @@
220228
sitemap_url_scheme = "{link}"
221229

222230

223-
# -- autodoc, napoleon, and autodoc-typehints ------------------------------------------------------
231+
# -- autodoc, apidoc, napoleon, and autodoc-typehints ----------------------------------------------
232+
233+
# apidoc config
234+
apidoc_module_dir = "../src/ridgeplot"
235+
apidoc_output_dir = "api/autogen"
236+
apidoc_separate_modules = True
237+
apidoc_extra_args = ["--no-toc", "--private"]
238+
224239

225240
# autosectionlabel
226241
autosectionlabel_prefix_document = True
@@ -254,7 +269,7 @@
254269
napoleon_use_admonition_for_examples = True
255270
napoleon_use_admonition_for_notes = False
256271
napoleon_use_param = False
257-
# napoleon_use_rtype = False
272+
napoleon_use_rtype = True
258273
napoleon_preprocess_types = True
259274
napoleon_attr_annotations = True
260275

@@ -379,19 +394,7 @@ def reset_sys_argv() -> Generator[None]:
379394
sys.argv = original_sys_argv
380395

381396

382-
def _fix_generated_public_api_rst() -> None:
383-
from pre_commit_hooks.end_of_file_fixer import main as end_of_file_fixer
384-
from pre_commit_hooks.fix_byte_order_marker import main as fix_byte_order_marker
385-
386-
files = [file.resolve().as_posix() for file in Path("api/public/").glob("*.rst")]
387-
if not files:
388-
raise RuntimeError("No RST files found. Check that the path above is correct.")
389-
with reset_sys_argv():
390-
end_of_file_fixer(files)
391-
fix_byte_order_marker(files)
392-
393-
394-
def _fix_html_charts() -> None:
397+
def _fix_html_charts(app: Sphinx, exception: Exception | None) -> None:
395398
from pre_commit_hooks.end_of_file_fixer import main as end_of_file_fixer
396399

397400
files = [file.resolve().as_posix() for file in Path("_static/charts/").glob("*.html")]
@@ -401,7 +404,7 @@ def _fix_html_charts() -> None:
401404
end_of_file_fixer(files)
402405

403406

404-
def rename_plotly_io_show() -> None:
407+
def _rename_plotly_io_show(app: Sphinx) -> None:
405408
"""Rename usages of `plotly.io.show` to `fig.show`."""
406409
from pathlib import Path
407410

@@ -420,6 +423,5 @@ def setup(app: Sphinx) -> None:
420423
compile_plotly_charts()
421424
# app.connect("html-page-context", register_jinja_functions)
422425

423-
app.connect("builder-inited", lambda *_: rename_plotly_io_show()) # pyright: ignore[reportUnknownLambdaType]
424-
app.connect("build-finished", lambda *_: _fix_generated_public_api_rst()) # pyright: ignore[reportUnknownLambdaType]
425-
app.connect("build-finished", lambda *_: _fix_html_charts()) # pyright: ignore[reportUnknownLambdaType]
426+
app.connect("builder-inited", _rename_plotly_io_show)
427+
app.connect("build-finished", _fix_html_charts)

docs/reference/changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ This document outlines the list of changes to ridgeplot between each release. Fo
55
Unreleased changes
66
------------------
77

8+
### Internal
9+
10+
- Improve type annotations and use stricter pyright settings ({gh-pr}`291`)
11+
- Use `sphinxcontrib.apidoc` to automatically generate API docs from the source code ({gh-pr}`296`)
12+
13+
---
14+
15+
0.3.0
16+
------
17+
818
### Features
919

1020
- Add support for histogram and bar traces ({gh-pr}`287`)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dependencies = [
4242
"numpy>=1",
4343
"plotly>=5.20", # The `fillgradient` option was added in 5.20
4444
"statsmodels>=0.12,!=0.14.2", # See GH197 for details
45-
'typing-extensions; python_version<"3.13"',
45+
"typing-extensions",
4646
'importlib-resources; python_version<"3.10"',
4747
]
4848

0 commit comments

Comments
 (0)