document_kwargs_from_configdict
(类来自 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]
基础类:
object装饰器用于将ConfigDict的文档附加到docstring中
这将指定的
ConfigDict的文档(使用numpydoc_ConfigFormatter格式化器)添加到装饰对象的文档字符串中。- Parameters:
config (ConfigDict 或 str) – 要记录的
ConfigDict。如果是str,则通过从装饰对象中检索命名属性来获取ConfigDict(从而可以记录那些__init__关键字参数由ConfigDict类属性处理的类对象)section (str) – 用于在配置文档前添加的章节标题
indent_spacing (int) – 每个文档块的缩进空格数
width (int) – 文档的总宽度,以字符为单位(用于换行段落)
文档 (str, 可选) – 要附加ConfigDict文档的初始文档字符串。 如果为None,则将使用装饰对象的
__doc__。
示例
>>> 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]
方法
__init__(config[, section, indent_spacing, ...])成员文档