Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ on:

jobs:
check_nipanel:
name: Check
name: Check nipanel
uses: ./.github/workflows/check_nipanel.yml
check_docs:
name: Check docs
uses: ./.github/workflows/check_docs.yml
run_unit_tests:
name: Run unit tests
uses: ./.github/workflows/run_unit_tests.yml
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/check_docs.yml
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: nipanel-with-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
- name: Install nipanel (with docs)
run: poetry install -v --only main,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: nipanel-docs
path: docs/_build/
101 changes: 101 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
"""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"
copyright = f"2025-%Y, {company}"
if datetime.datetime.now().year == 2025:
copyright = f"%Y, {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" / "nipanel"]
autoapi_type = "python"
autodoc_typehints = "description"


# TODO: https://github.com/ni/nitypes-python/issues/16 - Update nitypes-python docs to use
# :canonical: to resolve aliases (once supported by sphinx-autoapi)
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("nipanel._"):
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"]


# TODO: AB#3120159 - Update nipanel intersphinx mapping for nitypes
intersphinx_mapping = {
"grpc": ("https://grpc.github.io/grpc/python/", None),
"measurement-plugin-python": (
"https://measurement-plugin-python.readthedocs.io/en/latest/",
None,
),
"numpy": ("https://numpy.org/doc/stable/", None),
"protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),
"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
11 changes: 11 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NI Panel Python API
===================
.. toctree::
:maxdepth: 3

autoapi/index

Indices and tables
------------------
* :ref:`modindex`
* :ref:`search`
Loading