Skip to content

Commit 848e0ea

Browse files
authored
Reduce Sphinx documentation build warnings (#800)
* Removing a lot of warnings when building docs * Loosening ammonia tolerance in the example test * Cleaning up a few more docs build issues * Fixing minor doc indentation issues
1 parent bceeeb4 commit 848e0ea

43 files changed

Lines changed: 328 additions & 210 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@
5050
- Removed hard-coded logic of price units in finance models to be flexible to any type of commodity. Created helper functions `_compute_price_units` and `_compute_rate_units` in `h2integrate.finances.tools` and integrated usage of these functions into all finance models (`numpy_financial_npv`, `profast_npv`, `profast_lco`) accordingly. [PR 786](https://github.com/NatLabRockies/H2Integrate/pull/786)
5151
- Removed the `is_electricity_producer` helper from `h2integrate.core.commodity_stream_definitions` and the electricity-specific auto-detection branch in `H2IntegrateModel`, making finance-subgroup `commodity_stream` resolution fully commodity-agnostic; updated example `plant_config.yaml` files that previously relied on the auto-detection to set `commodity_stream` explicitly. [PR 786](https://github.com/NatLabRockies/H2Integrate/pull/786)
5252
- Ensure OpenMDAO data is cleaned up during testing [PR 797](https://github.com/NatLabRockies/H2Integrate/pull/797).
53+
- Added capability to specify demand technology for system-level control, and renamed the framework-derived system-level control classification dict from `slc_config` to `slc_topology` to distinguish it from the user-authored `control_parameters` block. [PR 784](https://github.com/NatLabRockies/H2Integrate/pull/784)
54+
- Reduced Sphinx documentation build warnings from roughly 880 to under 20. [PR 800](https://github.com/NatLabRockies/H2Integrate/pull/800)
55+
- Set `napoleon_use_ivar` and added `napoleon_custom_sections` so custom Google-style sections (Inputs, Outputs, Promoted Inputs, Promoted Outputs, Subsystems, Discrete Inputs, Discrete Outputs, Options, Behavior, Side Effects) render cleanly.
56+
- Suppressed the `etoc.toctree` category emitted by autosummary `:recursive:` stubs.
57+
- Cleared stale `_autosummary/` files at the start of every docs build.
58+
- Removed duplicated `Methods:` docstring sections that collided with autodoc method discovery.
59+
- Added `:no-index:` to hand-authored autoclass directives that duplicated autosummary entries.
60+
- Cleaned up docstring formatting bugs across roughly twenty source files (bullet and definition list separations, starred attribute markers, unbalanced backticks, and stray substitution references).
61+
- Fixed several MyST cross-reference targets (missing labels, ambiguous doc vs ref targets, incorrect autosummary path, duplicate labels, broken image path, and a broken literalinclude path).
62+
- Added a custom `docs/_templates/autosummary/module.rst` template that filters pytest `conftest.py` submodules from generated stubs, eliminating the "failed to import conftest" warnings that appeared on the Read the Docs build.
63+
- Renamed the `GeoH2SubsurfaceCostModel` MyST label in `docs/technology_models/geologic_hydrogen.md` to `mathur-modified-geoh2-cost` to remove an ambiguous cross-reference with the autosummary entry for the Python class of the same name.
5364
- Updates `h2integrate/core/file_utils.py::check_data_dir` to allow for the creation of nested
5465
directories, not just the final subdirectory for smoother initialization of a feedstock directory
5566
[PR 801](https://github.com/NatLabRockies/H2Integrate/pull/801).

docs/_config.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,41 @@ sphinx:
6161
autodoc_typehints: description
6262
html_static_path:
6363
- _static
64+
# A local ``autosummary/module.rst`` template lives here that filters out
65+
# pytest ``conftest.py`` submodules from the generated stubs (they can't be
66+
# imported outside a pytest session, so autosummary would emit "failed to
67+
# import" warnings for every one).
68+
templates_path:
69+
- _templates
6470
napoleon_use_admonition_for_notes: true
6571
napoleon_use_rtype: false
72+
# Render "Attributes:" sections with the :ivar: role instead of separate
73+
# ".. attribute::" directives. This prevents autodoc from documenting the
74+
# same attribute twice (once from the napoleon-parsed Attributes: block and
75+
# once from autodoc's own member discovery), which was the single largest
76+
# source of "duplicate object description" warnings in the docs build.
77+
napoleon_use_ivar: true
78+
# Teach napoleon about extra Google-style section headings that appear in
79+
# H2Integrate docstrings. Each entry is either a plain string (renders as
80+
# a generic section) or a ``[name, style]`` pair mapping the section to
81+
# an existing napoleon style so its contents are parsed as parameters.
82+
napoleon_custom_sections:
83+
- [Inputs, params_style]
84+
- [Outputs, params_style]
85+
- [Promoted Inputs, params_style]
86+
- [Promoted Outputs, params_style]
87+
- [Subsystems, params_style]
88+
- [Discrete Inputs, params_style]
89+
- [Discrete Outputs, params_style]
90+
- [Options, params_style]
91+
- [Behavior, notes_style]
92+
- [Side Effects, notes_style]
93+
# Suppress the class of warnings emitted by sphinx-external-toc for
94+
# ``.. toctree::`` directives inside autosummary-generated stubs. Those
95+
# toctrees are how ``autosummary :recursive:`` links its child module
96+
# pages together and can't be moved into ``_toc.yml``, so the warnings
97+
# are noise rather than a real problem to fix.
98+
suppress_warnings:
99+
- etoc.toctree
66100
nb_merge_streams: true
67101
nb_execution_raise_on_error: true
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. automodule:: {{ fullname }}
4+
5+
{% block attributes %}
6+
{% if attributes %}
7+
.. rubric:: {{ _('Module Attributes') }}
8+
9+
.. autosummary::
10+
{% for item in attributes %}
11+
{{ item }}
12+
{%- endfor %}
13+
{% endif %}
14+
{% endblock %}
15+
16+
{% block functions %}
17+
{% if functions %}
18+
.. rubric:: {{ _('Functions') }}
19+
20+
.. autosummary::
21+
{% for item in functions %}
22+
{{ item }}
23+
{%- endfor %}
24+
{% endif %}
25+
{% endblock %}
26+
27+
{% block classes %}
28+
{% if classes %}
29+
.. rubric:: {{ _('Classes') }}
30+
31+
.. autosummary::
32+
{% for item in classes %}
33+
{{ item }}
34+
{%- endfor %}
35+
{% endif %}
36+
{% endblock %}
37+
38+
{% block exceptions %}
39+
{% if exceptions %}
40+
.. rubric:: {{ _('Exceptions') }}
41+
42+
.. autosummary::
43+
{% for item in exceptions %}
44+
{{ item }}
45+
{%- endfor %}
46+
{% endif %}
47+
{% endblock %}
48+
49+
{% block modules %}
50+
{# Filter out pytest conftest modules; they cannot be imported outside a
51+
pytest session (they use `from test.conftest import ...` which requires
52+
the repo-root ``test/`` package to be on ``sys.path``) and so autosummary
53+
raises "failed to import" warnings on them. #}
54+
{% set filtered_modules = modules | reject('equalto', 'conftest') | list %}
55+
{% if filtered_modules %}
56+
.. rubric:: Modules
57+
58+
.. autosummary::
59+
:toctree:
60+
:recursive:
61+
{% for item in filtered_modules %}
62+
{{ item }}
63+
{%- endfor %}
64+
{% endif %}
65+
{% endblock %}

docs/build_book.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ if [[ "${1:-}" == "--clean" ]]; then
1818
rm -rf _build
1919
fi
2020

21+
# Always remove the autosummary-generated stubs before building. These files
22+
# are regenerated from the current package layout by ``autosummary_generate``,
23+
# but sphinx does not delete stubs for modules that were renamed or removed.
24+
# Leaving stale stubs behind produces spurious "failed to import" /
25+
# "document isn't included in any toctree" warnings on every subsequent build.
26+
rm -rf _autosummary
27+
2128
# Generate the interactive class hierarchy diagram
2229
python generate_class_hierarchy.py
2330

docs/control/system_level_control/control_classifier.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ storage | Can modulate consumption/production within bounds while tracking SOC |
1919
feedstock | Are not directly controlled, but useful for SLC to make dispatch decisions | feedstocks
2020

2121
To add a classifier for a particular model it would look something like this in the class:
22-
```{python}
22+
```python
2323
_control_classifier = "flexible"
2424
```
2525

@@ -30,14 +30,15 @@ _control_classifier = "flexible"
3030
## Fixed
3131
A fixed performance model represents anything that always produces at its rated capacity and cannot be controlled or reduced by the system level controller. The SLC reads the output from a fixed technology and subtracts it from the demand, but does not send a set-point back to the technology. A good example of this is a classical nuclear plant model: it produces a constant output that the rest of the system must accommodate.
3232

33+
(flexible)=
3334
## Flexible
3435
A flexible performance model represents anything whose production is determined by an external resource (e.g., wind speed, solar irradiance) and that can only be *reduced* below that resource-determined maximum and never increased above it. The system-level controller sends a `{commodity}_set_point` that acts as an upper bound: when the resource-driven output exceeds the set-point, output is curtailed down to the set-point; otherwise, output is left at the resource-driven value. A good example is the PVWatts PySAM solar plant in H2I; its performance is a function of the input solar resource, and we cannot tell the sun to shine more, but we can curtail the panel output below the available solar production.
3536

3637
In other words, flexible is a strictly more restricted case of [dispatchable](#dispatchable): a dispatchable model can be ramped both up and down in response to a set-point, while a flexible model can only be ramped down.
3738

3839
To simplify the implementation of applying this curtailment we added a method, `apply_curtailment()`, to the `PerformanceBaseClass`.
3940

40-
```{figure} figures/curtailable.png
41+
```{figure} figures/flexible.png
4142
:width: 70%
4243
:align: center
4344
```

docs/control/technology_level_control/open-loop_controllers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,4 @@ An example output for the first week of a one-year simulation is shown below. Or
108108
For an example of how to use the `PeakLoadManagementHeuristicOpenLoopStorageController`, see:
109109
- `examples/33_peak_load_management/`
110110

111-
For API details, see the [`PeakLoadManagementHeuristicOpenLoopStorageController` API documentation](../_autosummary/h2integrate.control.control_strategies.storage.plm_openloop_storage_controller).
111+
For API details, see the [`PeakLoadManagementHeuristicOpenLoopStorageController` API documentation](../../_autosummary/h2integrate.control.control_strategies.storage.plm_openloop_storage_controller).

docs/developer_guide/adding_a_new_technology.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Every model in H2Integrate inherits from a small set of baseclasses that wire it
1212
into the rest of the framework. Before writing code, pick the appropriate base
1313
class and configuration class for each piece of your technology.
1414

15-
See the class structure in H2I to learn more: [Class Structure](#class_structure)
15+
See the class structure in H2I to learn more: {ref}`Class Structure <class_structure>`
1616

1717
## Adding a new technology
1818

19-
Common model types (performance, cost, control, etc.) with slightly more explanation and examples are include here: [Technology Model Types](#technology_model_types)
19+
Common model types (performance, cost, control, etc.) with slightly more explanation and examples are include here: {ref}`Technology Model Types <technology_model_types>`
2020

2121
Every model has:
2222
- [Required class attributes](#required-class-attributes): These are usually defined within the class but not in a specific function definition.
@@ -103,9 +103,9 @@ class SolarPerformanceClass(PerformanceModelBaseClass):
103103
)
104104

105105
def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
106-
# example calculation using inputs set in `setup()
106+
# example calculation using inputs set in setup()
107107
# this input can be an openmdao design variable
108-
rated_pv_output = inputs["system_capacity"]*0.33 `
108+
rated_pv_output = inputs["system_capacity"] * 0.33
109109

110110
# example of calculation using a value from the attrs configuration class.
111111
# this method of input cannot be an openmdao design variable
@@ -116,10 +116,10 @@ class SolarPerformanceClass(PerformanceModelBaseClass):
116116

117117
...
118118

119-
# set outputs defined in `setup()` or baseclass `setup()`
119+
# set outputs defined in setup() or baseclass setup()
120120
output["panel_efficiency"] = panel_efficiency
121121

122-
# this output is defined in the `PerformanceModelBaseClass` but is required to be set in the performance model since that class is inherited
122+
# this output is defined in the PerformanceModelBaseClass but is required to be set in the performance model since that class is inherited
123123
output["capacity_factor"] = capacity_factor
124124

125125
```

docs/developer_guide/testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Run `pytest -m unit` to run only the unit test suite or `pytest -m not-unit` to
6262
An example of a unit test is in the example below where there is only a validation of the location
6363
of the output directory and subdirectory, and not the contents of those files.
6464

65-
:::{literalinclude} ../../h2integrate/resource/utilities/test/test_resource_file_tools.py
65+
:::{literalinclude} ../../h2integrate/core/test/test_utilities.py
6666
:start-at: @pytest.mark.unit
6767
:end-at: assert output_dir == expected_output_dir
6868
:::

docs/resource/resource_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ There are two ways to supply resource data to a technology:
1414

1515

1616

17+
(resource-data-specified-using-setval)=
1718
### Resource data specified using `set_val()`
1819

1920
Resource data for a technology can be set using the `set_val()` command. In the [Run of River Example](https://github.com/NatLabRockies/H2Integrate/tree/develop/examples/07_run_of_river_plant/), the technology named `river` needs a resource input called `discharge`. An example of this is shown below:
@@ -38,6 +39,7 @@ h2i.run()
3839
```
3940

4041

42+
(custom-resource-models)=
4143
### Custom resource models
4244
The benefit of using a custom resource model is that the resource data can be made to vary for different inputs, which can be beneficial if running a design sweep or optimization where the resource location (specified by a latitude and longitude) is a design variable.
4345

docs/resource/solar_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(solar_resource:models)=
2+
(solar-resource-model-overview)=
23
# Solar Resource: Model Overview
34

45
- [GOES PSM v4 API](goes_solar_v4_api): these models require an API key from the [NLR developer network](https://developer.nlr.gov/signup/), the available models are:
@@ -20,6 +21,7 @@ Please refer to the [Setting Environment Variables](../getting_started/environme
2021
```
2122

2223
(solarresource:overview)=
24+
(solar-resource-output-data)=
2325
# Solar Resource: Output Data
2426

2527
Solar resource models may output solar resource data, site information, information about the data source, and time information. This information is outputted as a dictionary. The following sections detail the naming convention for the dictionary keys, standardized units, and descriptions of all the output data that may be output from a solar resource model.

0 commit comments

Comments
 (0)