File size: 4,422 Bytes
eb1a751
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# -*- coding: utf-8 -*-
# Configuration file for the Sphinx documentation builder (hensmith).
import os
import re
import sys
import pathlib
import importlib.util

os.environ.setdefault('NUMBA_DISABLE_JIT', '1')      # docs never need JIT; avoids numba cache writes
ROOT = pathlib.Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))                         # document this checkout even if not pip-installed

# Fallback only: mock modules that are genuinely missing. Inert when the
# biosteam stack is installed (locally via PYTHONPATH; on RTD via post_install).
autodoc_mock_imports = [
    m for m in ('biosteam', 'thermosteam', 'numba')
    if importlib.util.find_spec(m) is None
]

import hensmith  # noqa: E402
print(f'[conf.py] documenting hensmith {hensmith.__version__} from {hensmith.__file__}')

project = 'hensmith'
author = 'Sarang S. Bhagwat'
copyright = '2020-2026, Sarang S. Bhagwat'
version = release = hensmith.__version__

extensions = [
    'sphinx.ext.duration',
    'sphinx.ext.autodoc',
    'sphinx.ext.autosummary',
    'sphinx.ext.napoleon',
    'sphinx.ext.intersphinx',
    'sphinx.ext.viewcode',
    'sphinx.ext.mathjax',
    'sphinx_design',
    'sphinx_copybutton',
]

autosummary_generate = False                          # API pages are hand-written
# Flag options such as 'undoc-members' are on whenever their key is present,
# whatever the value (False included), so undocumented members are left out
# by omitting the key. With it on, a class default such as
# StreamLifeCycle.splits = () was documented a second time next to its entry
# in the class's Attributes section, and -W failed on the duplicate.
autodoc_default_options = {
    'members': True,
    'show-inheritance': True,
}
autodoc_member_order = 'bysource'

napoleon_numpy_docstring = True
napoleon_google_docstring = False
napoleon_include_init_with_doc = False
napoleon_use_param = True
napoleon_use_rtype = True

intersphinx_mapping = {
    'python': ('https://docs.python.org/3/', None),
    'numpy': ('https://numpy.org/doc/stable/', None),
    'matplotlib': ('https://matplotlib.org/stable/', None),
    'biosteam': ('https://biosteam.readthedocs.io/en/latest/', None),
}
intersphinx_disabled_domains = ['std']
intersphinx_timeout = 30
if os.environ.get('SPHINX_OFFLINE'):                  # local builds without network: -W would fail on inventories
    intersphinx_mapping = {}

templates_path = []
exclude_patterns = []

html_theme = 'pydata_sphinx_theme'
html_title = 'hensmith'
html_static_path = ['_static']
html_css_files = ['css/custom.css']
html_favicon = '_static/images/logo/mark_hensmith.png'
html_theme_options = {
    'logo': {
        'image_light': '_static/images/logo/logo_hensmith.png',
        'image_dark': '_static/images/logo/logo_hensmith.png',
    },
    'show_toc_level': 2,
    'icon_links': [
        {'name': 'GitHub', 'url': 'https://github.com/BioSTEAMDevelopmentGroup/hensmith',
         'icon': 'fa-brands fa-github', 'type': 'fontawesome'},
        {'name': 'PyPI', 'url': 'https://pypi.org/project/hensmith/',
         'icon': 'fa-brands fa-python', 'type': 'fontawesome'},
    ],
}

copybutton_prompt_text = r'>>> |\.\.\. |\$ '
copybutton_prompt_is_regexp = True

linkcheck_ignore = [r'https://doi\.org/.*']           # DOIs 403 on bots; checked manually

# --- Loud guard: every asset referenced by the sources must be committed ---
# RTD never runs docs/_demo_src (no graphviz there, and the outputs are the
# reviewed source of truth), so a figure/capture/GIF that was not regenerated
# and committed must fail the build with a clear list, not render as an empty
# include or a broken image.
SRC = pathlib.Path(__file__).parent
_missing = []
for _rst in sorted(SRC.rglob('*.rst')):
    _text = _rst.read_text(encoding='utf-8')
    _refs = [(d, t) for d, t in re.findall(
        r'^\s*\.\. (literalinclude|figure|image):: (\S+)', _text, re.M)]
    _refs += [('html', t) for t in re.findall(r'(?:src|srcset)="(_static/[^"\s]+)"', _text)]
    for _directive, _target in _refs:
        _path = (SRC / _target.lstrip('/')) if _target.startswith('/') else (_rst.parent / _target)
        if not _path.resolve().exists():
            _missing.append(f'{_rst.relative_to(SRC)}: {_directive}:: {_target}')
if _missing:
    raise FileNotFoundError(
        'missing committed asset(s); run docs/_demo_src/build_all.py locally and commit:\n  '
        + '\n  '.join(_missing))