Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial Sphinx docs infrastructure #10

Merged
merged 5 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ jobs:
name: coverage-report-${{ matrix.os }}
path: coverage.xml
if-no-files-found: error
- name: Build Sphinx docs
if: matrix.install-mode == 'dev'
run: |
make -C docs html
19 changes: 19 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
fail_on_warning: true

build:
os: ubuntu-22.04
tools:
python: "3.11"

python:
install:
- requirements: requirements-dev.txt
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
67 changes: 67 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from importlib import metadata

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "IDAES Flowsheet Processor"
copyright = "2024, WaterTAP"
author = "WaterTAP"

release = version = metadata.version("idaes-flowsheet-processor")

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx_rtd_theme",
"sphinx.ext.doctest",
"sphinx.ext.napoleon",
"autoapi.extension",
"sphinx.ext.intersphinx",
]
suppress_warnings = []

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# see https://sphinx-autoapi.readthedocs.io/en/latest/reference/config.html
autoapi_dirs = ["../src"]
autoapi_root = "technical_reference"
autoapi_options = [
"members",
"undoc-members",
"show-module-summary",
]
# set to True to save the autogenerated
autoapi_keep_files = False
autoapi_ignore = ["*conftest.py", "*test_*.py", "*tests/*.py", "*_testing/*.py"]
# suppress_warnings += ["autoapi.python_import_resolution"]

intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"pyomo": ("https://pyomo.readthedocs.io/en/stable", None),
"numpy": ("https://numpy.org/doc/stable", None),
"idaes": ("https://idaes-pse.readthedocs.io/en/stable", None),
"watertap": ("https://watertap.readthedocs.io/en/latest", None),
"prommis": ("https://prommis.readthedocs.io/en/latest", None),
}


def _skip_tests(app, what: str, name: str, obj, skip, options):
return skip


def setup(sphinx):
sphinx.connect("autoapi-skip-member", _skip_tests)


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = []
12 changes: 12 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
IDAES Flowsheet Processor
=========================

Contents
--------

.. toctree::
:maxdepth: 3

technical_reference/index

* :ref:`genindex`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
5 changes: 5 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
black==24.8.0
pytest-cov==5.0.*

Sphinx==7.1.2 ; python_version < '3.9'
Sphinx==7.3.7 ; python_version >= '3.9'
sphinx-autoapi==3.0.0
sphinx-rtd-theme==2.0.0

--editable .[testing]
Loading