Skip to main content

Section

ClassDataClassSource

Section(title: str, level: int = 0, content: list[str] = [])

Document section extracted from a Markdown string.

Fields

NameTypeRequired
Description
titlestrThe text of the title
levelintThe level number of the title.
contentlist[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

NameType
Description
v_1strThe 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

NameTypeRequired
Description
md_textstr | NoneThe text to be parsed. It is ususually a docstring.

Returns

NameType
Description
v_1list[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.