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

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

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.

int

In addition to common types (like ``int``, ``float``, ``bool``, and
``str``), the config system profides a number of custom domain
Copy link
Contributor

Choose a reason for hiding this comment

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

Rogue typo! Reported upstream.

Suggested change
``str``), the config system profides a number of custom domain
``str``), the config system provides a number of custom domain


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)

:py:meth:`generate_yaml_template()`, and
:py:meth:`generate_documentation()`. The simplest is
:py:meth:`display()`, which prints out the current values of the
configuration object (and if it is a container type, all of it's
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
configuration object (and if it is a container type, all of it's
configuration object (and if it is a container type, all of its

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants