document_kwargs_from_configdict
(class from pyomo.common.config
)
- class pyomo.common.config.document_kwargs_from_configdict(config, section='Keyword Arguments', indent_spacing=4, width=78, visibility=None, doc=None)[source]
Bases:
object
Decorator to append the documentation of a ConfigDict to the docstring
This adds the documentation of the specified
ConfigDict
(using thenumpydoc_ConfigFormatter
formatter) to the decorated object’s docstring.- Parameters:
config (ConfigDict or str) – the
ConfigDict
to document. If astr
, then theConfigDict
is obtained by retrieving the named attribute from the decorated object (thereby enabling documenting class objects whose__init__
keyword arguments are processed by aConfigDict
class attribute)section (str) – the section header to preface config documentation with
indent_spacing (int) – number of spaces to indent each block of documentation
width (int) – total documentation width in characters (for wrapping paragraphs)
doc (str, optional) – the initial docstring to append the ConfigDict documentation to. If None, then the decorated object’s
__doc__
will be used.
Examples
>>> from pyomo.common.config import ( ... ConfigDict, ConfigValue, document_kwargs_from_configdict ... ) >>> class MyClass(object): ... CONFIG = ConfigDict() ... CONFIG.declare('iterlim', ConfigValue( ... default=3000, ... domain=int, ... doc="Iteration limit. Specify None for no limit" ... )) ... CONFIG.declare('tee', ConfigValue( ... domain=bool, ... doc="If True, stream the solver output to the console" ... )) ... ... @document_kwargs_from_configdict(CONFIG) ... def solve(self, **kwargs): ... config = self.CONFIG(kwargs) ... # ... ... >>> help(MyClass.solve) Help on function solve: solve(self, **kwargs) Keyword Arguments ----------------- iterlim: int, default=3000 Iteration limit. Specify None for no limit tee: bool, optional If True, stream the solver output to the console
- __init__(config, section='Keyword Arguments', indent_spacing=4, width=78, visibility=None, doc=None)[source]
Methods
__init__
(config[, section, indent_spacing, ...])Member Documentation