fabricatio_typst.models.article_base

Hierarchical article outline base classes (section → chapter → article).

Attributes

ARTICLE_WRAPPER

Classes

ArticleOutlineBase

Base class for article outlines.

SubSectionBase

Base class for article sections and subsections.

SectionBase

Base class for article sections and subsections.

ChapterBase

Base class for article chapters.

ArticleBase

Base class for article outlines.

Module Contents

fabricatio_typst.models.article_base.ARTICLE_WRAPPER
class fabricatio_typst.models.article_base.ArticleOutlineBase(/, **data: Any)

Bases: fabricatio_capabilities.models.generic.ProposedUpdateAble, fabricatio_capabilities.models.generic.PersistentAble, fabricatio_capabilities.models.generic.ModelHash, fabricatio_typst.models.generic.Introspect, fabricatio_typst.models.meta.FromTypstCode, fabricatio_typst.models.meta.ToTypstCode, abc.ABC

Base class for article outlines.

property metadata: fabricatio_typst.models.meta.ArticleMetaData

Returns the metadata of the article component.

update_metadata(other: fabricatio_typst.models.meta.ArticleMetaData) Self

Updates the metadata of the current instance with the attributes of another instance.

update_from_inner(other: Self) Self

Updates the current instance with the attributes of another instance.

class fabricatio_typst.models.article_base.SubSectionBase(/, **data: Any)

Bases: ArticleOutlineBase

Base class for article sections and subsections.

to_typst_code() str

Converts the component into a Typst code snippet for rendering.

introspect() str

Introspects the article subsection outline.

resolve_update_conflict(other: Self) str

Resolve update errors in the article outline.

class fabricatio_typst.models.article_base.SectionBase[T: SubSectionBase](/, **data: Any)

Bases: ArticleOutlineBase

Base class for article sections and subsections.

subsections: List[T]

Subsections of the section. Contains at least one subsection. You can also add more as needed.

child_type: ClassVar[Type[SubSectionBase]]
to_typst_code() str

Converts the section into a Typst formatted code snippet.

Returns:

The formatted Typst code snippet.

Return type:

str

classmethod from_typst_code(title: str, body: str, **kwargs) Self

Creates an Article object from the given Typst code.

resolve_update_conflict(other: Self) str

Resolve update errors in the article outline.

update_from_inner(other: Self) Self

Updates the current instance with the attributes of another instance.

introspect() str

Introspects the article section outline.

property exact_word_count: int

Returns the exact word count of the article section outline.

class fabricatio_typst.models.article_base.ChapterBase[T: SectionBase](/, **data: Any)

Bases: ArticleOutlineBase

Base class for article chapters.

sections: List[T]

Sections of the chapter. Contains at least one section. You can also add more as needed.

child_type: ClassVar[Type[SectionBase]]
to_typst_code() str

Converts the chapter into a Typst formatted code snippet for rendering.

classmethod from_typst_code(title: str, body: str, **kwargs) Self

Creates an Article object from the given Typst code.

resolve_update_conflict(other: Self) str

Resolve update errors in the article outline.

update_from_inner(other: Self) Self

Updates the current instance with the attributes of another instance.

introspect() str

Introspects the article chapter outline.

property exact_word_count: int

Calculates the total word count across all sections in the chapter.

Returns:

The cumulative word count of all sections.

Return type:

int

class fabricatio_typst.models.article_base.ArticleBase[T: ChapterBase](/, **data: Any)

Bases: fabricatio_capabilities.models.generic.FinalizedDumpAble, fabricatio_capabilities.models.generic.AsPrompt, fabricatio_typst.models.meta.FromTypstCode, fabricatio_typst.models.meta.ToTypstCode, abc.ABC

Base class for article outlines.

description: str = None

A comprehensive description of this object, including its purpose, scope, and context. This should clearly explain what this object is about, why it exists, and in what situations it applies. The description should be detailed enough to provide full understanding of this object’s intent and application.

chapters: List[T]

Chapters of the article. Contains at least one chapter. You can also add more as needed.

child_type: ClassVar[Type[ChapterBase]]
property language: str

Get the language of the article.

property exact_word_count: int

Calculates the total word count across all chapters in the article.

Returns:

The cumulative word count of all chapters.

Return type:

int

classmethod from_typst_code(title: str, body: str, **kwargs) Self

Generates an article from the given Typst code.

iter_dfs_rev() Generator[ArticleOutlineBase, None, None]

Performs a depth-first search (DFS) through the article structure in reverse order.

iter_dfs() Generator[ArticleOutlineBase, None, None]

Performs a depth-first search (DFS) through the article structure.

iter_sections() Generator[Tuple[ChapterBase, SectionBase], None, None]

Iterates through all sections in the article.

iter_subsections() Generator[Tuple[ChapterBase, SectionBase, SubSectionBase], None, None]

Iterates through all subsections in the article.

find_introspected() Tuple[ArticleOutlineBase, str] | None

Finds the first introspected component in the article structure.

gather_introspected() str | None

Gathers all introspected components in the article structure.

iter_chap_title() Generator[str, None, None]

Iterates through all chapter titles in the article.

iter_section_title() Generator[str, None, None]

Iterates through all section titles in the article.

iter_subsection_title() Generator[str, None, None]

Iterates through all subsection titles in the article.

to_typst_code() str

Generates the Typst code representation of the article.

finalized_dump() str

Generates standardized hierarchical markup for academic publishing systems.

Implements ACL 2024 outline conventions with four-level structure: = Chapter Title (Level 1) == Section Title (Level 2) === Subsection Title (Level 3) ==== Subsubsection Title (Level 4)

avg_chap_wordcount[S: ArticleBase]() S

Set all chap have same word count sum up to be self.expected_word_count.

avg_sec_wordcount[S: ArticleBase]() S

Set all sec have same word count sum up to be self.expected_word_count.

avg_subsec_wordcount[S: ArticleBase]() S

Set all subsec have same word count sum up to be self.expected_word_count.

avg_wordcount_recursive[S: ArticleBase]() S

Set all chap, sec, subsec have same word count sum up to be self.expected_word_count.

update_article_file[S: ArticleBase](file: str | pathlib.Path) S

Update the article file.

classmethod from_article_file[S: ArticleBase](file: str | pathlib.Path, title: str = '') S

Load article from file.