gen_code

Code generation utilities for atlas_doc_parser.

This module provides utilities to auto-generate the api.py file by scanning the marks/ and nodes/ directories for public API classes.

class atlas_doc_parser.gen_code.PublicAPI(module_name: str, class_name: str, is_attrs: bool = False, is_type_alias: bool = False)[source]

Metadata for a public API class.

Parameters:
  • module_name – The module name (e.g., “mark_link”, “node_heading”)

  • class_name – The class name (e.g., “MarkLink”, “NodeHeading”)

  • is_attrs – Whether this is an Attrs class (e.g., “MarkLinkAttrs”)

  • is_type_alias – Whether this is a type alias (e.g., T_NODE_...)

property relative_import_path: str

Get the relative import path for this API.

For marks: .marks.mark_xxx For nodes: .nodes.node_xxx

atlas_doc_parser.gen_code.scan_module_for_public_apis(module_path: Path, base_classes: tuple) list[PublicAPI][source]

Scan a module for public API classes.

Parameters:
  • module_path – Path to the Python module file

  • base_classes – Tuple of base classes to check inheritance against

Returns:

List of PublicAPI objects for classes that inherit from base_classes

atlas_doc_parser.gen_code.scan_all_modules() dict[str, list[PublicAPI]][source]

Scan all mark and node modules for public APIs.

Returns:

Dictionary with keys ‘marks’ and ‘nodes’, each containing a list of PublicAPI

atlas_doc_parser.gen_code.generate_api_py() str[source]

Generate the content for api.py using Jinja2 template.

Returns:

The generated Python source code

atlas_doc_parser.gen_code.main()[source]

Main entry point for code generation.

Generates the api.py file by scanning marks/ and nodes/ directories.