Skip to content

Rework ConfigDict numpydoc generation support #3667

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

Merged
merged 33 commits into from
Aug 1, 2025
Merged

Conversation

jsiirola
Copy link
Member

@jsiirola jsiirola commented Jul 27, 2025

Fixes # .

Summary/Motivation:

This PR is a significant overhaul of the utilities for converting ConfigDict objects unto numpydoc documentation strings. This was motivated by #3641, where it was pointed out that it is difficult / impossible to cleanly document CONFIG class attributes and nested ConfigDict objects.

This PR demonstrates the new use / formatting using the NLWriter and the contrib.solver Ipopt interface. Promulagating it to the rest of the solvers / transformations is left for a future PR.

Changes proposed in this PR:

  • Move the detailed (explanation) documentation of the Config system into the RST file (prevents duplicate labels / references
  • Add new decorators:
    • @document_configdict for documenting classes derived from ConfigDict
    • @document_class_CONFIG for documenting CONFIG class attributes (and optionally, methods that use CONFIG for keyword argument resolution
  • monkeypatch Sphinx so that non-class domain validators are correctly linked in the documentation.
  • Update the numpydoc formatter:
    • reference (do not recurse into) nested ConfigDict if the ConfigDict is documented separately (either through @document_configdict or @document_class_CONFIG)
    • Avoid unused (and unneeded) dict object in ConfigDict domain
  • Rework the Executable and Library factories to be true singletons; support their use as domains in ConfigValue
  • Convert repn.plugins.nl_writer and contrib.solver.solvers.ipopt to the new system (as demonstrators / test cases).

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

jsiirola added 29 commits July 24, 2025 00:22
Copy link
Contributor

@mrmundt mrmundt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I overall love this - just found some wee typos / one nitpick.


Configuring class hierarchies
=============================

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bit of back-and-forth across these docks - do you want it to be capitalized or not? (Config or config)

@github-project-automation github-project-automation bot moved this from Todo to Reviewer Approved in August 2025 Release Jul 29, 2025
Copy link
Member

@blnicho blnicho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really neat! I have a couple minor questions but otherwise I think this looks good.

@blnicho blnicho merged commit 4cbef3b into Pyomo:main Aug 1, 2025
35 checks passed
@github-project-automation github-project-automation bot moved this from Reviewer Approved to Done in August 2025 Release Aug 1, 2025
@jsiirola jsiirola deleted the doc-config branch August 1, 2025 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants