fabricatio_typst.models.article_base

A foundation for hierarchical document components with dependency tracking.

Attributes

ARTICLE_WRAPPER

RefKey

Classes

ReferringType

Enumeration of different types of references that can be made in an article.

ArticleMetaData

Metadata for an article component.

FromTypstCode

Base class for article components that can be created from a Typst code snippet.

ToTypstCode

Base class for article components that can be converted to a Typst code snippet.

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.ReferringType

Bases: enum.StrEnum

Enumeration of different types of references that can be made in an article.

CHAPTER = 'chapter'
SECTION = 'section'
SUBSECTION = 'subsection'
type fabricatio_typst.models.article_base.RefKey = Tuple[str, str | None, str | None]
class fabricatio_typst.models.article_base.ArticleMetaData(/, **data: Any)

Bases: fabricatio_core.models.generic.SketchedAble, fabricatio_core.models.generic.Described, fabricatio_capabilities.models.generic.WordCount, fabricatio_core.models.generic.Titled, fabricatio_core.models.generic.Language

Metadata for an article component.

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.

title: str = None

The title of this object, make it professional and concise.No prefixed heading number should be included.

aims: List[str]

List of writing aims of the research component in academic style.

property typst_metadata_comment: str

Generates a comment for the metadata of the article component.

property unstructured_body: str

Returns the unstructured body of the article component.

update_unstructured_body[S: ArticleMetaData](body: str) S

Update the unstructured body of the article component.

property language: str

Get the language of the article component.

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

Bases: ArticleMetaData

Base class for article components that can be created from a Typst code snippet.

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

Converts a Typst code snippet into an article component.

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

Bases: ArticleMetaData

Base class for article components that can be converted to a Typst code snippet.

to_typst_code() str

Converts the component into a Typst code snippet for rendering.

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, FromTypstCode, ToTypstCode, abc.ABC

Base class for article outlines.

property metadata: ArticleMetaData

Returns the metadata of the article component.

update_metadata(other: 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, FromTypstCode, ToTypstCode, abc.ABC

Base class for article outlines.

description: str = None

The abstract of this article, which serves as a concise summary of an academic article, encapsulating its core purpose, methodologies, key results, and conclusions while enabling readers to rapidly assess the relevance and significance of the study. Functioning as the article’s distilled essence, it succinctly articulates the research problem, objectives, and scope, providing a roadmap for the full text while also facilitating database indexing, literature reviews, and citation tracking through standardized metadata. Additionally, it acts as an accessibility gateway, allowing scholars to gauge the study’s contribution to existing knowledge, its methodological rigor, and its broader implications without engaging with the entire manuscript, thereby optimizing scholarly communication efficiency.

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.

Returns:

Each component in the article structure in reverse order.

Return type:

Generator[ArticleMainBase]

iter_dfs() Generator[ArticleOutlineBase, None, None]

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

Returns:

Each component in the article structure.

Return type:

Generator[ArticleMainBase]

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

Iterates through all sections in the article.

Returns:

Each section in the article.

Return type:

Generator[ArticleOutlineBase]

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

Iterates through all subsections in the article.

Returns:

Each subsection in the article.

Return type:

Generator[ArticleOutlineBase]

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)

Returns:

Strictly formatted outline with academic sectioning

Return type:

str

Example

= Methodology == Neural Architecture Search Framework === Differentiable Search Space ==== Constrained Optimization Parameters === Implementation Details == Evaluation Protocol

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.