Section
ClassDataClassSource
Section(title: str, level: int = 0, content: list[str] = [])
Document section extracted from a Markdown string.
Fields
| Name | Type | Required | |
|---|---|---|---|
title | str | The text of the title | |
level | int | The level number of the title. | |
content | list[str] | The line-by-line content in the section. |
Methods
as_md_text
v_1: str = self.as_md_text()
Render as Markdown text.
Returns
| Name | Type | |
|---|---|---|
v_1 | str | The Markdown text rendered from the section. |
from_md_text
v_1: list[Self] = Section.from_md_text(md_text: str | None)
Parse Markdown docstring as a list of sections.
Each section starts with a title.
Requires
| Name | Type | Required | |
|---|---|---|---|
md_text | str | None | The text to be parsed. It is ususually a docstring. |
Returns
| Name | Type | |
|---|---|---|
v_1 | list[Self] | A list of sections. Each section starts with a title. The content are preserved as a sequence of lines. If the section does not have a title, its title level will be 0. |