generated from ni/github-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 3
docs: Generate API reference using sphinx-autoapi #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d135ead
pyproject.toml: Add docs dependency group
bkeryan 20c8518
Update poetry.lock
bkeryan 16e0ff2
waveform: Fix bulleted list formatting
bkeryan 7cfb2e3
docs: Add configuration and index page
bkeryan 6585af8
github: Update check_nitypes.yml to generate docs
bkeryan 07e3926
Remove Py3.8 Sphinx versioning
bkeryan ec2fc88
Update poetry.lock
bkeryan 31bfc47
github: Upload an artifact containing the generated docs
bkeryan 0f23bc6
github: Split check_docs into a separate workflow file so it doesn't …
bkeryan a430104
waveform: Document warnings with "Raises" because "Warnings" displays…
bkeryan 4a09bd8
docs: Add GitHub issue link to TODO
bkeryan 1028055
pyproject.toml: Upgrade to latest Sphinx
bkeryan 1fba844
Update poetry.lock
bkeryan 00ca56c
docs: Update copyright to use range of years
bkeryan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: Check docs | ||
|
|
||
| on: | ||
| workflow_call: | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| POETRY_VERSION: 1.8.2 | ||
| PYTHON_VERSION: 3.11.9 | ||
|
|
||
| jobs: | ||
| check_docs: | ||
| name: Check docs | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out repo | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| id: setup-python | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
| - name: Set up Poetry | ||
| uses: Gr1N/setup-poetry@v9 | ||
| with: | ||
| poetry-version: ${{ env.POETRY_VERSION }} | ||
| - name: Check for lock changes | ||
| run: poetry check --lock | ||
| - name: Cache virtualenv (with docs) | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: .venv | ||
| key: nitypes-with-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} | ||
| - name: Install nitypes (with docs) | ||
| run: poetry install -v --with docs | ||
| - name: Generate docs | ||
| run: poetry run sphinx-build docs docs/_build -b html -W --keep-going | ||
| - name: Upload docs artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: nitypes-docs | ||
| path: docs/_build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| """Sphinx Configuration File.""" | ||
|
|
||
| import datetime | ||
| import pathlib | ||
|
|
||
| import autoapi.extension | ||
| import toml | ||
|
|
||
| # Add any Sphinx extension module names here, as strings. They can be | ||
| # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
| # ones. | ||
| extensions = [ | ||
| "autoapi.extension", | ||
| "m2r2", | ||
| "sphinx.ext.autodoc", | ||
| "sphinx.ext.intersphinx", | ||
| "sphinx.ext.napoleon", | ||
| "sphinx.ext.viewcode", | ||
| ] | ||
|
|
||
| root_path = pathlib.Path(__file__).parent.parent | ||
| pyproj_file = root_path / "pyproject.toml" | ||
| proj_config = toml.loads(pyproj_file.read_text()) | ||
|
|
||
|
|
||
| project = proj_config["tool"]["poetry"]["name"] | ||
| company = "National Instruments" | ||
| year = str(datetime.datetime.now().year) | ||
| copyright = f"{year}, {company}" | ||
|
|
||
|
|
||
| # The version info for the project you're documenting, acts as replacement for | ||
| # |version| and |release|, also used in various other places throughout the | ||
| # built documents. | ||
| # | ||
| version = proj_config["tool"]["poetry"]["version"] | ||
| release = ".".join(version.split(".")[:2]) | ||
| description = proj_config["tool"]["poetry"]["description"] | ||
|
|
||
|
|
||
| htmlhelp_basename = f"{project}doc" | ||
|
|
||
|
|
||
| # tell autoapi to doc the public options | ||
| autoapi_options = list(autoapi.extension._DEFAULT_OPTIONS) | ||
| autoapi_options.remove("private-members") # note: remove this to include "_" members in docs | ||
| autoapi_dirs = [root_path / "src" / "nitypes"] | ||
| autoapi_type = "python" | ||
| autodoc_typehints = "description" | ||
|
|
||
|
|
||
| # TODO: figure out how to make :canonical: work with autoapi | ||
bkeryan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def skip_aliases(app, what, name, obj, skip, options): | ||
| """Skip documentation for classes that are exported from multiple modules.""" | ||
| # For names that are defined in a private sub-module and aliased into a | ||
| # public package, hide the definition. | ||
| if name.startswith("nitypes.time._") or name.startswith("nitypes.waveform._"): | ||
| skip = True | ||
|
|
||
| return skip | ||
|
|
||
|
|
||
| def setup(sphinx): | ||
| """Sphinx setup callback.""" | ||
| sphinx.connect("autoapi-skip-member", skip_aliases) | ||
|
|
||
|
|
||
| # List of patterns, relative to source directory, that match files and | ||
| # directories to ignore when looking for source files. | ||
| # This patterns also effect to html_static_path and html_extra_path | ||
| exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] | ||
|
|
||
|
|
||
| intersphinx_mapping = { | ||
| "python": ("https://docs.python.org/3", None), | ||
| } | ||
|
|
||
|
|
||
| # -- Options for HTML output ---------------------------------------------- | ||
|
|
||
|
|
||
| # The theme to use for HTML and HTML Help pages. See the documentation for | ||
| # a list of builtin themes. | ||
| # | ||
| html_theme = "sphinx_rtd_theme" | ||
| html_theme_options = { | ||
| "navigation_depth": -1, | ||
| } | ||
|
|
||
| # Napoleon settings | ||
| napoleon_numpy_docstring = False | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| Data Types for NI Python APIs | ||
| ============================= | ||
| .. toctree:: | ||
| :maxdepth: 3 | ||
|
|
||
| autoapi/index | ||
|
|
||
| Indices and tables | ||
| ------------------ | ||
| * :ref:`modindex` | ||
| * :ref:`search` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.