starter-kit/documents/conf.py

207 lines
6 KiB
Python
Raw Normal View History

2025-09-22 14:54:12 -04:00
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
2025-12-29 12:11:38 -05:00
import datetime
import os
import sys
SRC = os.path.abspath("../src")
sys.path.insert(0, SRC)
2025-12-29 12:11:38 -05:00
from nrsk.documents.validate import validate_doc_types
2025-09-22 14:54:12 -04:00
# -- Project information -----------------------------------------------------
2025-12-12 09:40:42 -05:00
company_name = "Applied Maritime Sciences, LLC"
project_name = "Project 1959"
2025-09-22 14:54:12 -04:00
project = f"{company_name} Governing Documents"
author = company_name
release = "1.0"
version = release
project_copyright = f"{datetime.datetime.now(tz=datetime.timezone.utc).year}"
description = f"Procedures, Forms, Templates that govern work at {company_name}"
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinxcontrib.plantuml",
"sphinx_needs",
"myst_parser",
"sphinxcontrib.bibtex",
"sphinx.ext.todo",
2025-09-22 14:54:12 -04:00
"sphinxcontrib.glossaryused",
"sphinx.ext.imgmath",
"sphinxcontrib.datatemplates",
"sphinxcontrib.mermaid",
"sphinxcontrib.apidoc",
2025-09-22 14:54:12 -04:00
"sphinx.ext.graphviz",
# "sphinx.ext.imgconverter", # SVG to png but rasterizes and bad
"sphinxcontrib.inkscapeconverter", # SVG to pdf without rasterizing
"sphinx_timeline",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx_autodoc_typehints",
"sphinx.ext.autosummary",
"sphinxcontrib.autodoc_pydantic",
"sphinx.ext.intersphinx",
"nrsk.schedule.load_schedule",
"nrsk.plant.plant_data_table",
2025-09-22 14:54:12 -04:00
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["generated_assets"]
2025-09-22 14:54:12 -04:00
# -- 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_book_theme"
html_title = f"{project} {release}"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_logo = "_static/logo.png"
html_favicon = "_static/favicon.ico"
html_theme_options = {
"logo": {
"text": html_title,
# "image_light": "_static/logo-light.png",
# "image_dark": "_static/logo-dark.png",
}
}
html_css_files = [
"css/custom.css",
]
# system-specific plantuml config
# https://sphinx-needs.readthedocs.io/en/latest/installation.html#plantuml-support
plantuml = "java -Djava.awt.headless=true -jar /usr/share/plantuml/plantuml.jar"
latex_engine = "xelatex"
latex_elements = {
# "fontenc": r"\usepackage[T2A]{fontenc}",
# "babel": r"\usepackage[english,russian]{babel}",
# "fontpkg": r"""
# \setmainfont{DejaVu Serif}
# \setsansfont{DejaVu Sans}
# \setmonofont{DejaVu Sans Mono}
# """,
"figure_align": "H",
"extraclassoptions": "openany",
#'\makeatletter\@openrightfalse\makeatother'
"extrapackages": r"""
\usepackage{fancyhdr}
\usepackage{etoolbox}
\usepackage{pdflscape}
\usepackage{tabulary}
""",
"preamble": r"""
\AtBeginEnvironment{figure}{\pretocmd{\hyperlink}{\protect}{}{}}
""",
}
2025-09-22 14:54:12 -04:00
# LaTeX document generation options
# doesn't work with sphinx-needs
latex_documents = [
(
"index",
"ams.tex",
"AMS Docs",
2025-09-22 14:54:12 -04:00
author,
"manual",
False,
),
]
# (
# "org/qapd",
# "qapd.tex",
# "Quality Assurance Program Description",
# author,
# "howto",
# False,
# ),
# (
# "proc/calc",
# "proc_calc.tex",
# "Engineering Calculation Procedure",
# author,
# "howto",
# False,
# ),
# (
# "proc/software",
# "proc_software.tex",
# "Software Management Procedure",
# author,
# "howto",
# False,
# ),
# ]
rst_prolog = f"""
.. |inst| replace:: **{company_name}**
.. |project| replace:: **{project_name}**
2025-09-22 14:54:12 -04:00
"""
# will need to move relevant refs somewhere
# more reusable, like into the repo?
bibtex_bibfiles = ["/pool/Reading/refs.bib"]
bibtex_cache = "none" # refresh without wiping build
2025-09-22 14:54:12 -04:00
mermaid_cmd = "./node_modules/.bin/mmdc"
# enable pdf cropping of mermaid diagrams for fit
mermaid_pdfcrop = "/usr/bin/pdfcrop"
mermaid_version = "10.6.1"
# Sphinx Needs config
needs_include_needs = True # turn off to hide all needs (e.g. for working docs)
needs_extra_options = ["basis"]
autodoc_typehints = "description"
autodoc_typehints_description_target = "all"
autodoc_default_options = {
"members": True,
"private-members": False,
"undoc-members": True,
"ignore-module-all": True,
}
autodoc_member_order = "bysource"
apidoc_module_dir = SRC
apidoc_module_first = True
apidoc_output_dir = "api"
apidoc_separate_modules = True
autodoc_pydantic_model_show_field_summary = True
autodoc_pydantic_model_show_validator_summary = True
autodoc_pydantic_field_doc_policy = "both"
set_type_checking_flag = True
intersphinx_mapping = {
"pydantic": ("https://docs.pydantic.dev/latest", None),
"python": ("https://docs.python.org/3", None),
}
2025-12-29 12:11:38 -05:00
def setup(app):
app.connect("builder-inited", validate_doc_types)