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

Autogenerate API documentation #3378

Merged
merged 82 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
fd3ad4f
Stub in the auto-generated library reference
jsiirola Aug 31, 2024
8e4d410
Move the API docs to the root; rename old Library Reference -> Topical
jsiirola Aug 31, 2024
5d1a3aa
Merge branch 'doc-reorg' into doc-index
jsiirola Sep 13, 2024
add2bef
Removing redundant pynumero, common API documentation
jsiirola Sep 23, 2024
169d7ec
Update rst docs to not duplicate API docs (add :noindex: or use summa…
jsiirola Sep 23, 2024
a166b5a
Simplify toctree entries in library reference
jsiirola Sep 30, 2024
6a4730e
make clean: remove autogenerated API files
jsiirola Oct 1, 2024
b099501
Update references to BiBTeX 'alpha' format
jsiirola Oct 1, 2024
c8f5333
Update __init__.py to remove absolute pyomo imports
jsiirola Oct 1, 2024
baee0e9
General cleanup of doc files
jsiirola Oct 1, 2024
865a55e
re-adding working with abstrct models sections [inadvertantly removed]
jsiirola Oct 1, 2024
0bdc03a
Fix incorrect class references
jsiirola Oct 1, 2024
3152c31
Remove autosectionlabel, update references
jsiirola Oct 1, 2024
2354765
General update of documentation formatting
jsiirola Oct 1, 2024
38375e7
Clean up docstrings, silence Sphinx warnings and errors
jsiirola Oct 1, 2024
8dc93cb
Switch to using ply decorators to not confuse Sphinx
jsiirola Oct 1, 2024
5530607
Rework building_documentation() logic to improve Sphinx output/suppre…
jsiirola Oct 3, 2024
6297b95
Avoid importing Qt when building documentation to suppress Sphine API…
jsiirola Oct 3, 2024
29687a8
Update the deprecation decorators to avoid doc warnings
jsiirola Oct 3, 2024
2f280c2
Wrap enum.IntEnum to resolve warnings from Sphinx autodoc
jsiirola Oct 3, 2024
5df7203
Clean up some imports
jsiirola Oct 3, 2024
f08ebad
Output str instead of repr for Config default values
jsiirola Oct 3, 2024
f8c99c4
Add blank line to help resolve Sphinx autodoc warnings
jsiirola Oct 3, 2024
03cb961
Update TestCase documentation & resolve some Sphinx warnings
jsiirola Oct 3, 2024
ff40d0d
Suppress warning for (intentionally) unindexed RST file
jsiirola Oct 3, 2024
b6767f7
Remove unused intersphinx link
jsiirola Oct 3, 2024
823f556
Update copyright statement to match the rest of Pyomo
jsiirola Oct 3, 2024
56095e9
Update Sphinx config to improve API rendering
jsiirola Oct 3, 2024
11f0df4
Fixing typos
jsiirola Oct 3, 2024
76c4250
Deprecate/Remove unneeded references to results data structures from …
jsiirola Oct 3, 2024
cdf6396
Merge branch 'doc-reorg' into doc-index
jsiirola Oct 4, 2024
cffc600
Update EOL handling in ConfigDict to remove extra EOL, update tests
jsiirola Oct 4, 2024
a08fa45
Track changes in repr(FlagType)
jsiirola Oct 4, 2024
19cfd2d
NFC: apply black
jsiirola Oct 4, 2024
47b0ff4
Import relevant module for doctests of classes/functions
jsiirola Oct 7, 2024
4b74321
Don't document inherited-members for ndarray derived classes
jsiirola Oct 7, 2024
5cce82c
Exclude all 'tests' when building source documentation
jsiirola Oct 7, 2024
18c0f82
Allow interior_point ex1.py to be imported without executing
jsiirola Oct 7, 2024
a385f42
Remove unused import
jsiirola Oct 7, 2024
a4e39b1
Fix doc example typo
jsiirola Oct 7, 2024
5acddbf
Reverse the BlockVector/MPIBlickVector base class order
jsiirola Oct 8, 2024
1729143
Improve the error message from ImmutableConfigValue
jsiirola Oct 8, 2024
1e09883
Add support for setting the state of `building_documentation()`
jsiirola Oct 8, 2024
e832bf1
Check state of `logger` module attribute before dereferencing
jsiirola Oct 8, 2024
777f868
Resolve errors in docstrings
jsiirola Oct 8, 2024
efcaac7
Use try-finally pattern in the context manager (from decorator docume…
jsiirola Oct 8, 2024
f827af6
Emit log messages to Pyomo logger when building documentation
jsiirola Oct 8, 2024
2777b48
Update sphinx configuration
jsiirola Oct 8, 2024
6c3150f
Clean up Reference TOC appearance
jsiirola Oct 8, 2024
7fb6690
Fix docstring error
jsiirola Oct 8, 2024
19e18ac
Simplify logic for erstoring log handlers
jsiirola Oct 8, 2024
87e6b21
Remove unused sphinx extensions
jsiirola Oct 8, 2024
2536333
Fixing doc typos
jsiirola Oct 8, 2024
ef61460
Merge pull request #3380 from jsiirola/pynumero-inheritance-order
jsiirola Oct 8, 2024
03e14c4
Remove use of relative imports
jsiirola Oct 8, 2024
2c87f43
NFC: apply black
jsiirola Oct 8, 2024
e6ecf55
Merge branch 'main' into doc-reorg
jsiirola Oct 8, 2024
180602f
Merge branch 'doc-reorg' into doc-index
jsiirola Oct 8, 2024
f309eed
Standardizing references
jsiirola Oct 8, 2024
d91ab37
Documenting reference standard
jsiirola Oct 8, 2024
bfad2dd
Updating reference
jsiirola Oct 8, 2024
d1df0ef
remove references to the global logger
jsiirola Oct 8, 2024
ee1e3d5
Fix 'tests' exclusion pattern
jsiirola Oct 8, 2024
7afbc41
Explicitly set the default numpy print precision
jsiirola Oct 9, 2024
a7da074
Update doctest test file exclusion
jsiirola Oct 9, 2024
c38b48b
Update tests filter for Sphinx>=8
jsiirola Oct 10, 2024
38a4b3e
Minor (NFC) reorder of doctest_global_setup
jsiirola Oct 10, 2024
97e23a1
Make TempfileContext more robust when deleted during Python shutdown
jsiirola Oct 10, 2024
532115c
Resolve Sphinx errors; update comment to match current practice
jsiirola Oct 10, 2024
ad32818
Edit MIS test to not run on module import
jsiirola Oct 10, 2024
07b5cbe
Silence Sphinx warnings
jsiirola Oct 10, 2024
562c5d5
NFC: typo
jsiirola Oct 10, 2024
1dd0a35
Move pint import to common.dependencies; update for Python 3.13 + pin…
jsiirola Oct 10, 2024
b47c26c
Revert previous commit to Archive/conf.py; apply to current OnlineDoc…
jsiirola Oct 10, 2024
08341a9
Do not trigger DeferredImportError exceptions when attempting to seri…
jsiirola Oct 10, 2024
48080ad
Update doctests for OSX, Numpy changes
jsiirola Oct 10, 2024
eefb98c
Remove debugging
jsiirola Oct 10, 2024
465298a
Add (hidden) documentation of the NumPy2 output
jsiirola Oct 10, 2024
1860a1d
Fix indentation typo
jsiirola Oct 11, 2024
91922d7
Clean up makefile
jsiirola Oct 11, 2024
adf8bb5
Restore (and update) doc README
jsiirola Oct 11, 2024
c29de6b
update baseline to match python 3.13 behavior
jsiirola Oct 11, 2024
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
2 changes: 1 addition & 1 deletion doc/Archive/contributed_packages/parmest/driver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Parameter Estimation
Parameter Estimation using parmest requires a Pyomo model, experimental
data which defines multiple scenarios, and parameters
(thetas) to estimate. parmest uses Pyomo [PyomoBookII]_ and (optionally)
mpi-sppy [mpisppy]_ to solve a
mpi-sppy [KMM+23]_ to solve a
two-stage stochastic programming problem, where the experimental data is
used to create a scenario tree. The objective function needs to be
written with the Pyomo Expression for first stage cost
Expand Down
2 changes: 2 additions & 0 deletions doc/OnlineDocs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPHINXBUILD = sphinx-build
SPHINXPROJ = Pyomo
SOURCEDIR = .
BUILDDIR = _build
APIDIR = api

# Put it first so that "make" without argument is like "make help".
help:
Expand All @@ -23,6 +24,7 @@ clean:
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo "Removing *.spy, *.out"
@find . -name \*.spy -delete
@if test -d "$(SOURCEDIR)/${APIDIR}"; then rm -r "$(SOURCEDIR)/${APIDIR}"; fi

rebuild:
@$(MAKE) clean
Expand Down
13 changes: 13 additions & 0 deletions doc/OnlineDocs/_templates/recursive-base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{ name | escape | underline}}

({{ objtype }} from :py:mod:`{{ module }}`)

.. testsetup:: *

# import everything from the module containing this class so that
# doctests for the class docstrings see the correct environment
from {{ module }} import *

.. currentmodule:: {{ module }}

.. auto{{ objtype }}:: {{ objname }}
47 changes: 47 additions & 0 deletions doc/OnlineDocs/_templates/recursive-class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{ name | escape | underline}}

(class from :py:mod:`{{ module }}`)

.. testsetup:: *

# import everything from the module containing this class so that
# doctests for the class docstrings see the correct environment
from {{ module }} import *

.. currentmodule:: {{ module }}

{# Note that numpy.ndarray examples fail doctest; disable documentation
of inherited members for classes derived from ndarray #}

.. autoclass:: {{ objname }}
:members:
:show-inheritance:
{{ '' if (module + '.' + name) in (
'pyomo.contrib.pynumero.sparse.block_vector.BlockVector',
'pyomo.contrib.pynumero.sparse.mpi_block_vector.MPIBlockVector',
'pyomo.core.expr.ndarray.NumericNDArray',
) else ':inherited-members:' }}

{% block methods %}
.. automethod:: __init__

{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
77 changes: 77 additions & 0 deletions doc/OnlineDocs/_templates/recursive-module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{% if fullname == 'pyomo' %}
Library Reference
=================
{% else %}
{{ name | escape | underline}}
{% endif %}

.. automodule:: {{ fullname }}
:undoc-members:

{% block attributes %}
{%- if attributes %}
.. rubric:: {{ _('Module Attributes') }}

.. autosummary::
:toctree:
:template: recursive-base.rst
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{%- endblock %}

{%- block functions %}
{%- if functions %}
.. rubric:: {{ _('Functions') }}

.. autosummary::
:toctree:
:template: recursive-base.rst
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{%- endblock %}

{%- block classes %}
{%- if classes %}
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:template: recursive-class.rst
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{%- endblock %}

{%- block exceptions %}
{%- if exceptions %}
.. rubric:: {{ _('Exceptions') }}

.. autosummary::
:toctree:
:template: recursive-class.rst
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{%- endblock %}

{%- block modules %}
{%- if modules %}
.. rubric:: Modules

.. autosummary::
:toctree:
:template: recursive-module.rst
:recursive:
{% for item in modules %}
{% if '.test' not in item and '.example' not in item %}
{{ item }}
{% endif %}
{%- endfor %}
{% endif %}
{%- endblock %}
9 changes: 9 additions & 0 deletions doc/OnlineDocs/code.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:orphan:

.. autosummary::
:toctree: api
:caption: Library Reference
:template: recursive-module.rst
:recursive:

pyomo
25 changes: 18 additions & 7 deletions doc/OnlineDocs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
'pandas': ('https://pandas.pydata.org/docs/', None),
'scikit-learn': ('https://scikit-learn.org/stable/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
'Sphinx': ('https://www.sphinx-doc.org/en/master/', None),
}

# -- General configuration ------------------------------------------------
Expand All @@ -84,8 +83,6 @@
'sphinx.ext.todo',
'sphinx_copybutton',
'enum_tools.autoenum',
'sphinx.ext.autosectionlabel',
#'sphinx.ext.githubpages',
]

viewcode_follow_imported_members = True
Expand All @@ -108,7 +105,7 @@

# General information about the project.
project = u'Pyomo'
copyright = u'2008-2023, Sandia National Laboratories'
copyright = u'2008-2024, Sandia National Laboratories'
author = u'Pyomo Developers'

# The version info for the project you're documenting, acts as replacement for
Expand All @@ -132,7 +129,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ['_build', '**/tests', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
Expand Down Expand Up @@ -168,7 +165,7 @@
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
html_theme_options = {'navigation_depth': 6, 'titles_only': True}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down Expand Up @@ -235,6 +232,9 @@
# autodoc_member_order = 'bysource'
# autodoc_member_order = 'groupwise'

autosummary_generate = True
autosummary_ignore_module_all = True

# -- Check which conditional dependencies are available ------------------
# Used for skipping certain doctests
from sphinx.ext.doctest import doctest
Expand Down Expand Up @@ -271,11 +271,12 @@ def check_output(self, want, got, optionflags):
attempt_import, numpy_available, scipy_available, pandas_available,
yaml_available, networkx_available, matplotlib_available,
pympler_available, dill_available,
numpy as np,
)
pint_available = attempt_import('pint', defer_import=False)[1]
from pyomo.contrib.parmest.parmest import parmest_available

import pyomo.environ as _pe # (trigger all plugin registrations)
import pyomo.environ as pyo # (register plugins, make environ available to tests)
import pyomo.opt as _opt

# Not using SolverFactory to check solver availability because
Expand All @@ -291,6 +292,11 @@ def check_output(self, want, got, optionflags):

baron = _opt.SolverFactory('baron')

if numpy_available:
# Recent changes on GHA seem to have dropped the default precision
# from 8 to 4; restore the default.
np.set_printoptions(precision=8)

if numpy_available and scipy_available:
import pyomo.contrib.pynumero.asl as _asl
asl_available = _asl.AmplInterface.available()
Expand All @@ -302,6 +308,11 @@ def check_output(self, want, got, optionflags):
ma27_available = False
mumps_available = False

# Mark that we are testing code (in this case, testing the documentation)
from pyomo.common.flags import in_testing_environment
in_testing_environment(True)

# Prevent any Pyomo logs from propagating up to the doctest logger
import logging
logging.getLogger('pyomo').propagate = False
'''
6 changes: 6 additions & 0 deletions doc/OnlineDocs/explanation/analysis/alternative_solutions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,20 @@ Interface Documentation
.. currentmodule:: pyomo.contrib.alternative_solutions

.. autofunction:: enumerate_binary_solutions
:noindex:

.. autofunction:: enumerate_linear_solutions
:noindex:

.. autofunction:: pyomo.contrib.alternative_solutions.lp_enum_solnpool.enumerate_linear_solutions_soln_pool
:noindex:

.. autofunction:: gurobi_generate_solutions
:noindex:

.. autofunction:: obbt_analysis_bounds_and_solutions
:noindex:

.. autoclass:: Solution
:noindex:

4 changes: 3 additions & 1 deletion doc/OnlineDocs/explanation/analysis/community.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ detection. Thus, this package provides the user with a lot of control over the c
function we use for this community detection is shown below:

.. autofunction:: pyomo.contrib.community_detection.detection.detect_communities
:noindex:
:noindex:

As stated above, the characteristics of the NetworkX graph of the Pyomo model are very important to the
community detection. The main graph features the user can specify are the type of community map,
Expand Down Expand Up @@ -383,7 +383,9 @@ We can see an example for the three separate graphs created by these three funct
Functions in this Package
-------------------------
.. automodule:: pyomo.contrib.community_detection.detection
:noindex:
:members:

.. automodule:: pyomo.contrib.community_detection.community_graph
:noindex:
:members:
10 changes: 8 additions & 2 deletions doc/OnlineDocs/explanation/analysis/iis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ Infeasibility Diagnostics

There are two closely related tools for infeasibility diagnosis:

- :ref:`Infeasible Irreducible System (IIS) Tool`
- :ref:`Minimal Intractable System finder (MIS) Tool`
- :ref:`iis`
- :ref:`mis`

The first simply provides a conduit for solvers that compute an
infeasible irreducible system (e.g., Cplex, Gurobi, or Xpress). The
second provides similar functionality, but uses the ``mis`` package
contributed to Pyomo.


.. _iis:

Infeasible Irreducible System (IIS) Tool
========================================

.. automodule:: pyomo.contrib.iis.iis
:noindex:

.. autofunction:: pyomo.contrib.iis.write_iis
:noindex:

.. _mis:

Minimal Intractable System finder (MIS) Tool
============================================
Expand Down
1 change: 1 addition & 0 deletions doc/OnlineDocs/explanation/analysis/incidence/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Incidence Options
=================

.. automodule:: pyomo.contrib.incidence_analysis.config
:noindex:
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Weakly Connected Components
===========================

.. automodule:: pyomo.contrib.incidence_analysis.connected
:noindex:
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Dulmage-Mendelsohn Partition
============================

.. automodule:: pyomo.contrib.incidence_analysis.dulmage_mendelsohn
:noindex:
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Incident Variables
==================

.. automodule:: pyomo.contrib.incidence_analysis.incidence
:noindex:
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Pyomo Interfaces
================

.. automodule:: pyomo.contrib.incidence_analysis.interface
:noindex:
:members:
1 change: 1 addition & 0 deletions doc/OnlineDocs/explanation/analysis/incidence/matching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Maximum Matching
================

.. automodule:: pyomo.contrib.incidence_analysis.matching
:noindex:
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Block Triangular Decomposition Solver
=====================================

.. automodule:: pyomo.contrib.incidence_analysis.scc_solver
:noindex:
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Block Triangularization
=======================

.. automodule:: pyomo.contrib.incidence_analysis.triangularize
:noindex:
:members:
1 change: 1 addition & 0 deletions doc/OnlineDocs/explanation/analysis/mpc/conversion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Data Conversion
===============

.. automodule:: pyomo.contrib.mpc.data.convert
:noindex:
:members:
Loading