| 1 | # Configuration file for the Sphinx documentation builder. |
| 2 | # |
| 3 | # This file only contains a selection of the most common options. For a full |
| 4 | # list see the documentation: |
| 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html |
| 6 | from pathlib import Path |
| 7 | from typing import Any |
| 8 | |
| 9 | from sphinx.application import Sphinx |
| 10 | from sphinx.ext import apidoc |
| 11 | |
| 12 | # -- Project information ----------------------------------------------------- |
| 13 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information |
| 14 | |
| 15 | project = "annotatedyaml" |
| 16 | copyright = "2025, Home Assistant Devs" |
| 17 | author = "Home Assistant Devs" |
| 18 | release = "1.0.2" |
| 19 | |
| 20 | # -- General configuration --------------------------------------------------- |
| 21 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration |
| 22 | |
| 23 | # Add any Sphinx extension module names here, as strings. They can be |
| 24 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
| 25 | # ones. |
| 26 | extensions = [ |
| 27 | "myst_parser", |
| 28 | "sphinx.ext.napoleon", |
| 29 | "sphinx.ext.autodoc", |
| 30 | "sphinx.ext.viewcode", |
| 31 | ] |
| 32 | napoleon_google_docstring = False |
| 33 | |
| 34 | # The suffix of source filenames. |
| 35 | source_suffix = [ |
| 36 | ".rst", |
| 37 | ".md", |
| 38 | ] |
| 39 | |
| 40 | # Add any paths that contain templates here, relative to this directory. |
| 41 | templates_path = [ |
| 42 | "_templates", |
| 43 | ] |
| 44 | |
| 45 | # List of patterns, relative to source directory, that match files and |
| 46 | # directories to ignore when looking for source files. |
| 47 | # This pattern also affects html_static_path and html_extra_path. |
| 48 | exclude_patterns = [ |
| 49 | "_build", |
| 50 | "Thumbs.db", |
| 51 | ".DS_Store", |
| 52 | ] |
| 53 | |
| 54 | |
| 55 | # -- Options for HTML output ------------------------------------------------- |
| 56 | |
| 57 | # The theme to use for HTML and HTML Help pages. See the documentation for |
| 58 | # a list of builtin themes. |
| 59 | # |
| 60 | html_theme = "furo" |
| 61 | |
| 62 | # Add any paths that contain custom static files (such as style sheets) here, |
| 63 | # relative to this directory. They are copied after the builtin static files, |
| 64 | # so a file named "default.css" will overwrite the builtin "default.css". |
| 65 | html_static_path = ["_static"] |
| 66 | |
| 67 | |
| 68 | # -- Automatically run sphinx-apidoc ----------------------------------------- |
| 69 | |
| 70 | |
| 71 | def run_apidoc(_: Any) -> None: |
| 72 | """Run sphinx-apidoc.""" |
| 73 | docs_path = Path(__file__).parent |
| 74 | module_path = docs_path.parent / "src" / "annotatedyaml" |
| 75 | |
| 76 | apidoc.main( |
| 77 | [ |
| 78 | "--force", |
| 79 | "--module-first", |
| 80 | "-o", |
| 81 | docs_path.as_posix(), |
| 82 | module_path.as_posix(), |
| 83 | ] |
| 84 | ) |
| 85 | |
| 86 | |
| 87 | def setup(app: Sphinx) -> None: |
| 88 | """Setup sphinx.""" |
| 89 | app.connect("builder-inited", run_apidoc) |