Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Axolotl ai cloud Axolotl Generate Config Docs

From Leeroopedia


Knowledge Sources
Domains Documentation, Code_Generation
Last Updated 2026-02-07 00:00 GMT

Overview

Python script that auto-generates Quarto documentation for all Axolotl configuration options by introspecting the Pydantic schema model hierarchy.

Description

The generate_config_docs.py script contains the QuartoGenerator class, which uses Python introspection and AST parsing to automatically produce a complete configuration reference document from the AxolotlInputConfig Pydantic model. It traverses the full class inheritance hierarchy (MRO), extracts field annotations from source code, detects field groupings based on blank lines and comments in source, recursively expands nested Pydantic sub-models inline, and generates a single YAML code block in Quarto (.qmd) format. Key methods include _build_inheritance_map for caching class field ownership, _extract_type_from_source for reading exact type annotations via AST, _extract_field_groups_from_source for detecting logical field groups, and _generate_field_documentation for recursive nested model expansion with cycle detection.

Usage

This script runs as a Quarto pre-render hook (configured in _quarto.yml) each time the documentation site is built. It can also be run standalone to regenerate docs/config-reference.qmd. It should be used whenever the Pydantic schema changes to keep documentation in sync.

Code Reference

Source Location

Signature

class QuartoGenerator:
    """Generate Quarto documentation from Pydantic models."""

    def __init__(self): ...
    def _get_direct_fields(self, cls: Type[BaseModel]) -> FrozenSet[str]: ...
    def _extract_nested_type(self, field_type) -> Any: ...
    def _extract_all_pydantic_models_from_type(self, field_type) -> list[type[BaseModel]]: ...
    def _get_nested_models(self, model_class, visited=None) -> dict[str, type[BaseModel]]: ...
    def _build_inheritance_map(self, child_class: Type[BaseModel]): ...
    def _extract_type_from_source(self, model_class, field_name) -> str: ...
    def _extract_field_groups_from_all_classes(self, model_class) -> list[dict]: ...
    def _generate_field_documentation(self, model_class, field_name, field_info, field_type_str, is_required, indent_level=0, visited_models=None) -> list[str]: ...
    def generate_qmd(self, model_class, title=None, expand_nested=True) -> str: ...

def main(): ...

Import

from docs.scripts.generate_config_docs import QuartoGenerator
# Or run as script:
# python docs/scripts/generate_config_docs.py

I/O Contract

Inputs

Name Type Required Description
model_class Type[BaseModel] Yes Pydantic model to document (AxolotlInputConfig)
title str No Document title (defaults to model name)
expand_nested bool No Whether to expand nested Pydantic models inline (default True)

Outputs

Name Type Description
QMD content str Quarto markdown document with YAML code block
docs/config-reference.qmd File Written config reference file

Usage Examples

Run Standalone

# Generate the config reference documentation
python docs/scripts/generate_config_docs.py
# Output: docs/config-reference.qmd

Use Programmatically

from docs.scripts.generate_config_docs import QuartoGenerator
from axolotl.utils.schemas.config import AxolotlInputConfig

generator = QuartoGenerator()
qmd = generator.generate_qmd(AxolotlInputConfig, "Config Reference", expand_nested=True)
print(qmd)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment