Skip to content

Commit 6bb3994

Browse files
authored
Add initial Sphinx docs infrastructure (#10)
* Add initial Sphinx files * Add ReadTheDocs config file * Add dev dependencies for docs build * Add job step to test local docs build * Format docs/conf.py with Black
1 parent c1d740a commit 6bb3994

File tree

7 files changed

+162
-0
lines changed

7 files changed

+162
-0
lines changed

.github/workflows/checks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,7 @@ jobs:
104104
name: coverage-report-${{ matrix.os }}
105105
path: coverage.xml
106106
if-no-files-found: error
107+
- name: Build Sphinx docs
108+
if: matrix.install-mode == 'dev'
109+
run: |
110+
make -C docs html

.readthedocs.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Build documentation in the docs/ directory with Sphinx
9+
sphinx:
10+
fail_on_warning: true
11+
12+
build:
13+
os: ubuntu-22.04
14+
tools:
15+
python: "3.11"
16+
17+
python:
18+
install:
19+
- requirements: requirements-dev.txt

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from importlib import metadata
2+
3+
# Configuration file for the Sphinx documentation builder.
4+
#
5+
# For the full list of built-in configuration values, see the documentation:
6+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
7+
8+
# -- Project information -----------------------------------------------------
9+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
10+
11+
project = "IDAES Flowsheet Processor"
12+
copyright = "2024, WaterTAP"
13+
author = "WaterTAP"
14+
15+
release = version = metadata.version("idaes-flowsheet-processor")
16+
17+
# -- General configuration ---------------------------------------------------
18+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
19+
20+
extensions = [
21+
"sphinx_rtd_theme",
22+
"sphinx.ext.doctest",
23+
"sphinx.ext.napoleon",
24+
"autoapi.extension",
25+
"sphinx.ext.intersphinx",
26+
]
27+
suppress_warnings = []
28+
29+
templates_path = ["_templates"]
30+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
31+
32+
# see https://sphinx-autoapi.readthedocs.io/en/latest/reference/config.html
33+
autoapi_dirs = ["../src"]
34+
autoapi_root = "technical_reference"
35+
autoapi_options = [
36+
"members",
37+
"undoc-members",
38+
"show-module-summary",
39+
]
40+
# set to True to save the autogenerated
41+
autoapi_keep_files = False
42+
autoapi_ignore = ["*conftest.py", "*test_*.py", "*tests/*.py", "*_testing/*.py"]
43+
# suppress_warnings += ["autoapi.python_import_resolution"]
44+
45+
intersphinx_mapping = {
46+
"python": ("https://docs.python.org/3", None),
47+
"pyomo": ("https://pyomo.readthedocs.io/en/stable", None),
48+
"numpy": ("https://numpy.org/doc/stable", None),
49+
"idaes": ("https://idaes-pse.readthedocs.io/en/stable", None),
50+
"watertap": ("https://watertap.readthedocs.io/en/latest", None),
51+
"prommis": ("https://prommis.readthedocs.io/en/latest", None),
52+
}
53+
54+
55+
def _skip_tests(app, what: str, name: str, obj, skip, options):
56+
return skip
57+
58+
59+
def setup(sphinx):
60+
sphinx.connect("autoapi-skip-member", _skip_tests)
61+
62+
63+
# -- Options for HTML output -------------------------------------------------
64+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
65+
66+
html_theme = "sphinx_rtd_theme"
67+
html_static_path = []

docs/index.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
IDAES Flowsheet Processor
2+
=========================
3+
4+
Contents
5+
--------
6+
7+
.. toctree::
8+
:maxdepth: 3
9+
10+
technical_reference/index
11+
12+
* :ref:`genindex`

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

requirements-dev.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
black==24.8.0
22
pytest-cov==5.0.*
33

4+
Sphinx==7.1.2 ; python_version < '3.9'
5+
Sphinx==7.3.7 ; python_version >= '3.9'
6+
sphinx-autoapi==3.0.0
7+
sphinx-rtd-theme==2.0.0
8+
49
--editable .[testing]

0 commit comments

Comments
 (0)