Skip to content

Commit be863bc

Browse files
authored
[develop]: Add GitHub Actions to check that Technical Docs are up-to-date (#1152)
* Adds a GitHub Actions workflow & script to check whether the Technical Documentation is up-to-date * Turns on the -W flag so that documentation build warnings register as error * Updates the requirements file so that --remove-old flag can be used to check Tech Docs * Updates the Contributor's Guide w/information on Technical Documentation and troubleshooting guidelines * Fixes a few broken links.
1 parent 87b26cc commit be863bc

File tree

11 files changed

+112
-22
lines changed

11 files changed

+112
-22
lines changed

.github/scripts/check_tech_doc.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# This script recreates technical documentation for the ush and tests/WE2E Python scripts
3+
# If the tech docs produced here do not match the branch's contents, the script will fail
4+
5+
set -eo pipefail
6+
7+
# Install prerequisites
8+
pip install sphinx
9+
pip install sphinx-rtd-theme
10+
pip install sphinxcontrib-bibtex
11+
12+
# Regenerate tech docs in ush and tests/WE2E based on current state of scripts in those directories.
13+
cd doc/TechDocs
14+
sphinx-apidoc -fM --remove-old -o ./ush ../../ush
15+
sphinx-apidoc -fM --remove-old -o ./tests/WE2E ../../tests/WE2E
16+
17+
# Check for mismatch between what comes out of this action and what is in the PR.
18+
status=`git status -s`
19+
20+
if [ -n "${status}" ]; then
21+
echo ${status}
22+
echo ""
23+
echo "Please update your Technical Documentation RST files."
24+
exit 1
25+
else
26+
echo "Technical documentation is up-to-date."
27+
exit 0
28+
fi

.github/workflows/doc_tests.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Doc Tests
2+
on:
3+
push:
4+
pull_request:
5+
branches:
6+
- develop
7+
- 'release/*'
8+
workflow_dispatch:
9+
10+
defaults:
11+
run:
12+
shell: bash -leo pipefail {0}
13+
14+
jobs:
15+
doc_tests:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
- name: Check tech docs
21+
run: .github/scripts/check_tech_doc.sh
22+
- name: Build documentation
23+
run: |
24+
cd doc
25+
make doc

doc/ContribGuide/documentation.rst

+51-1
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,54 @@ Please follow these guidelines when contributing to the documentation:
6969
7070
.. code-block:: python
7171
72-
n = 88
72+
n = 88
73+
74+
Troubleshooting Documentation
75+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76+
77+
In the SRW App documentation Makefile (``ufs-srweather-app/doc/Makefile``), the ``-W`` option causes documentation builds to fail when there are errors or warnings in the build.
78+
This ensures that the documentation remains up-to-date and notifies developers of any new issues (like failing links). However, the build will fail when it hits the first error without showing subsequent errors.
79+
When troubleshooting, it can be useful to see all warnings and errors.
80+
To see all warnings and errors, comment out the ``-W`` flag in ``SPHINXOPTS`` in the Makefile and build the documentation by running ``make doc`` from the ``doc`` directory.
81+
82+
Technical Documentation Guidelines
83+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
84+
85+
Technical (API-like) documentation is generated for any Python scripts in the ``ush`` or ``tests/WE2E`` directories.
86+
When developers change Python files in these directories, they need to update the Python docstrings (i.e., comments in ``"""triple quotes"""``) to reflect the changes they made.
87+
Each Python script should include:
88+
89+
* A summary of the script's purpose/functionality
90+
91+
* Should start with a verb, e.g., "checks" or "loads" or "initializes"
92+
93+
* Docstrings for each method (except methods like ``_parse_args`` that start with an underscore). These docstrings should include:
94+
95+
* A description of what the method does (starting with a verb, e.g., "checks" or "parses")
96+
* A list of method parameters, or ``Args:``, with a definition and expected data type for each
97+
* A return statement (``Returns:``) -- if applicable
98+
* List of exceptions (``Raises:``) -- if applicable
99+
100+
.. note::
101+
102+
Python does not have truly private methods, but methods that start with an underscore are the closest equivalent. In the SRW App, the underscore signals that this method is only accessed by the script within which it is called.
103+
104+
After updating the docstrings, developers need to update the corresponding RST files.
105+
To do this successfully, developers must have *sphinx>=7.4.0* installed on their system. To update the RST files, run:
106+
107+
.. code-block:: console
108+
109+
cd ufs-srweather-app/doc/TechDoc
110+
sphinx-apidoc -fM --remove-old -o ./ush ../../ush
111+
sphinx-apidoc -fM --remove-old -o ./tests/WE2E ../../tests/WE2E
112+
113+
.. note::
114+
115+
Developers who do not have *sphinx>=7.4.0* installed may issue the following commands from ``ufs-srweather-app/doc/TechDoc`` before running the sphinx-apidoc commands above:
116+
117+
.. code-block:: console
118+
119+
rm -rf ush
120+
rm -rf tests/WE2E
121+
122+
This will delete current RST files before recreating them with the ``sphinx-apidoc`` command based on the current contents of ``ush`` and ``tests/WE2E``. This step is necessary because the ``--remove-old`` flag does not work with earlier versions of sphinx.

doc/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Makefile for Sphinx documentation
22

3-
SPHINXOPTS = -a -n #-W
3+
SPHINXOPTS = -a -n -W
44
SPHINXBUILD = sphinx-build
55
SOURCEDIR = .
66
BUILDDIR = build

doc/UsersGuide/BuildingRunningTesting/VXCases.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ Point STAT Files
262262

263263
The Point-Stat files contain continuous variables like temperature, pressure, and wind speed. A description of the Point-Stat file can be found :ref:`here <met:point-stat>` in the MET documentation.
264264

265-
The Point-Stat files contain a potentially overwhelming amount of information. Therefore, it is recommended that users focus on the CNT MET test, which contains the `RMSE <https://metplus.readthedocs.io/projects/met/en/latest/Users_Guide/appendixC.html#root-mean-squared-error-rmse>`_ and `MBIAS <https://metplus.readthedocs.io/projects/met/en/latest/Users_Guide/appendixC.html#multiplicative-bias>`_ statistics. The MET tests are defined in column 24 'LINE_TYPE' of the ``.stat`` file. Look for 'CNT' in this column. Then find column 66-68 for MBIAS and 78-80 for RMSE statistics. A full description of this file can be found :ref:`here <met:point_stat-output>`.
265+
The Point-Stat files contain a potentially overwhelming amount of information. Therefore, it is recommended that users focus on the CNT MET test, which contains the Root Mean Squared Error (`RMSE <https://metplus.readthedocs.io/en/latest/Users_Guide/statistics_list.html#statistics-list-p-r>`_) and Magnitude &
266+
Multiplicative bias (`MBIAS <https://metplus.readthedocs.io/en/latest/Users_Guide/statistics_list.html#statistics-list-g-m>`_) statistics. The MET tests are defined in column 24 'LINE_TYPE' of the ``.stat`` file. Look for 'CNT' in this column. Then find column 66-68 for MBIAS and 78-80 for RMSE statistics. A full description of this file can be found :ref:`here <met:point_stat-output>`.
266267

267268
To narrow down the variable field even further, users can focus on these weather variables:
268269

doc/UsersGuide/CustomizingTheWorkflow/DefineWorkflow.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Defining an SRW App Workflow
66

77
Many predefined workflows with optional variants exist within the Short-Range Weather Application, but the Application also includes the ability to define a new workflow from scratch. This functionality allows users to add tasks to the workflow to meet their scientific exploration needs.
88

9-
Rocoto is the primary workflow manager software used by the UFS SRW App. Rocoto workflows are defined in an XML file (``FV3LAM_wflow.xml``) based on parameters set during experiment generation. This section explains how the Rocoto XML is built using a Jinja2 template (`Jinja docs here <https://jinja.palletsprojects.com/en/3.1.x/templates/>`__) and structured YAML files. The YAML follows the requirements in the `Rocoto documentation <http://christopherwharrop.github.io/rocoto/>`__ with a few exceptions or additions outlined in this documentation.
9+
Rocoto is the primary workflow manager software used by the UFS SRW App. Rocoto workflows are defined in an XML file (``FV3LAM_wflow.xml``) based on parameters set during experiment generation. This section explains how the Rocoto XML is built using a Jinja2 template (`Jinja docs here <https://jinja.palletsprojects.com/en/stable/templates>`_) and structured YAML files. The YAML follows the requirements in the `Rocoto documentation <http://christopherwharrop.github.io/rocoto/>`__ with a few exceptions or additions outlined in this documentation.
1010

1111
The Jinja2 Template
1212
===================

doc/conf.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@
3838

3939
nitpick_ignore = [('py:class', 'obj'),('py:class',
4040
'yaml.dumper.Dumper'),('py:class',
41-
'xml.etree.ElementTree'),]
41+
'xml.etree.ElementTree'),('py:class', 'Basemap'),]
4242

4343
# -- General configuration ---------------------------------------------------
4444

4545
# Sphinx extension module names:
4646
extensions = [
4747
'sphinx_rtd_theme',
4848
'sphinx.ext.autodoc',
49-
'sphinxcontrib.autoyaml',
5049
'sphinx.ext.doctest',
5150
'sphinx.ext.intersphinx',
5251
'sphinx.ext.extlinks',
@@ -310,10 +309,3 @@ def warn_undocumented_members(app, what, name, obj, options, lines):
310309
'uw': ('https://uwtools.readthedocs.io/en/main/%s', '%s'),
311310
}
312311

313-
# -- Options for autoyaml extension ---------------------------------------
314-
315-
autoyaml_root = "../ush"
316-
autoyaml_doc_delimiter = "###" # Character(s) which start a documentation comment.
317-
autoyaml_comment = "#" #Comment start character(s).
318-
autoyaml_level = 6
319-
#autoyaml_safe_loader = False

doc/requirements.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
sphinx>=6.0.0
1+
sphinx>=7.4.0
22
sphinx_rtd_theme
33
sphinxcontrib-bibtex
4-
sphinxcontrib-autoyaml

doc/requirements.txt

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is autogenerated by pip-compile with Python 3.11
33
# by the following command:
44
#
5-
# pip-compile --strip-extras requirements.in
5+
# pip-compile requirements.in
66
#
77
alabaster==0.7.16
88
# via sphinx
@@ -42,27 +42,22 @@ pyyaml==6.0.1
4242
# via pybtex
4343
requests==2.32.2
4444
# via sphinx
45-
ruamel-yaml==0.16.13
46-
# via sphinxcontrib-autoyaml
4745
six==1.16.0
4846
# via
4947
# latexcodec
5048
# pybtex
5149
snowballstemmer==2.2.0
5250
# via sphinx
53-
sphinx==7.2.6
51+
sphinx==7.4.7
5452
# via
5553
# -r requirements.in
5654
# sphinx-rtd-theme
57-
# sphinxcontrib-autoyaml
5855
# sphinxcontrib-bibtex
5956
# sphinxcontrib-jquery
6057
sphinx-rtd-theme==2.0.0
6158
# via -r requirements.in
6259
sphinxcontrib-applehelp==1.0.8
6360
# via sphinx
64-
sphinxcontrib-autoyaml==1.1.1
65-
# via -r requirements.in
6661
sphinxcontrib-bibtex==2.6.2
6762
# via -r requirements.in
6863
sphinxcontrib-devhelp==1.0.6

0 commit comments

Comments
 (0)