DocEnum
ClassDataClassSource
DocEnum(
name: str,
descr: str,
init_func: DocFunction = _default_init(),
init_func_specified: bool = True,
methods: list[DocFunction] = [],
properties: list[DocProp] = [],
operators: list[DocOpTemplate] = [],
abstract_attrs: DocClassAbstractAttrs | None = None,
slang: str = "",
lineno: int = 0,
type: Literal["enum"] = "enum",
enum_items: list[DocEnumItem] = []
)
The docstring and basic information of an enum class.
This serializable data type contains the parsed docstrings of the enum class. It is a specialized class. When rendering the documentation, the initialization function is replaced by the enum item details.
Fields
| Name | Type | Required | |
|---|---|---|---|
name | str | The name of the class. | |
descr | str | The description body of the class. | |
init_func | DocFunction | The initialization function of the class. | |
init_func_specified | bool | A flag. When it is on, it means that the initialization function has been defined by user. | |
methods | list[DocFunction] | The list of methods of this class. | |
properties | list[DocProp] | The list of properties of this class. | |
operators | list[DocOpTemplate] | The list of operators of this class. | |
abstract_attrs | DocClassAbstractAttrs | None | Additional abstract attributes. Will present only when the class is abstract. For the protocols, this value will be always None. | |
slang | str | The internal code identifying this class. | |
lineno | int | The line number where the class is defined. If the number is unknown, this value will be 0. | |
type | Literal["enum"] | The identifier of this documentation item. | |
enum_items | list[DocEnumItem] | The items of the enum class. |
Methods
as_md_text
v_1: str = self.as_md_text(renderer: ProtocolComponent)
Render as Markdown text.
Requires
| Name | Type | Required | |
|---|---|---|---|
renderer | ProtocolComponent | The renderer providing component rendering. |
Returns
| Name | Type | |
|---|---|---|
v_1 | str | The Markdown text rendered from the enum object. |
table_enums
v_1: str = self.table_enums(
has_type: bool = True, has_value: bool = True, has_doc: bool = False
)
Format the fields as a table.
Requires
| Name | Type | Required | |
|---|---|---|---|
has_type | bool | A flag. If specified, will display the enum item type. | |
has_value | bool | A flag. If specified, will display the value of the enum item. | |
has_doc | bool | A flag. If specified, will display the docstring of the enum item. |
Returns
| Name | Type | |
|---|---|---|
v_1 | str | The Markdown table of the enum items. |
Properties
str_v2
str_v2: str = self.str_v2
Render as V2 string.
The v2 string is in the following format:
ClassName(field1: type1, field2: type2 = default2, ...)
which is more compact than the default string.