configblock.docprinter module
Class to print documentation for the options defined by a configuration
This class can be used to print a summary of the options available in a ConfigBlock hierarchy for a user’s documentation.
- class configblock.docprinter.DocPrinter(stream: ~io.TextIOBase = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, indent_width: int = 4, detail: int = 0, only_active: bool = False, section_order: ~typing.Tuple[~configblock.outputwriter.Section] = (<Section.Options: 1>, <Section.Subconfigs: 2>, <Section.SubconfigTypes: 3>))
Bases:
OutputWriterBaseSimple printer
- begin()
Begin the output for the provided hierarchy
- Returns
Whether the hierarchy should be entered
- Return type
bool
- begin_globals()
Begin writing the globals
- Returns
Whether the block should be entered
- Return type
bool
- begin_options()
Begin writing the options
- Returns
Whether the options should be iterated over
- Return type
bool
- begin_subcfg(key: str, subcfg: ConfigBlock)
Begin writing a single subconfig
Note that this method should not handle further iteration into the subconfig
- Returns
Whether the subconfig should be entered
- Return type
bool
- begin_subcfg_types()
Begin writing the subconfig types section
- Returns
Whether to iterate over the subconfiguration factories
- Return type
bool
- begin_subcfgs()
Begin writing the subconfigs section
- Returns
Whether the subconfigs section should be iterated over
- Return type
bool
- property detail: int
Do not print options with a higher detail level than this
- end_options()
End writing the options on the current block
- end_subcfg_types()
End the subconfig types section
- end_subcfgs()
End writing the subconfigs section
- write_default_subcfg_type(factory: Optional[Callable[[], ConfigBlock]], already_output: bool)
Write the default subconfig factory
- Parameters
factory (Optional[ConfigBlockFactory]) – The default subconfig factory for the current block
already_output (bool) – Whether or not the information has been output in the current stack. This is to prevent infinite recursion where a block has itself as the default type
- write_globals()
Write information for the global options
- write_option(key: str, option: OptionData)
Write a single option
- write_subcfg_type(key: str, factory: Callable[[], ConfigBlock], already_output: bool)
Write a single subconfig type
- Parameters
factory (Optional[ConfigBlockFactory]) – The factory to write
already_output (bool) – Whether or not the information has been output in the current stack. This is to prevent infinite recursion where a block has itself as the default type