Classes
DocElement
dataclass
Represents a documented element (function, class, endpoint, command, etc.).
This is the unified da…
DocElement
dataclass Represents a documented element (function, class, endpoint, command, etc.).
This is the unified data model used by all extractors. Each extractor converts its specific domain into this common format.
Attributes
| Name | Type | Description |
|---|---|---|
name |
str |
Element name (e.g., 'build', 'Site', 'GET /users') |
qualified_name |
str |
Full path (e.g., 'bengal.core.site.Site.build') |
description |
str |
Main description/docstring |
element_type |
str |
Type of element ('function', 'class', 'endpoint', 'command', etc.) |
source_file |
Path | None |
Source file path (if applicable) |
line_number |
int | None |
Line number in source (if applicable) |
metadata |
dict[str, Any] |
Type-specific data (signatures, parameters, etc.) |
typed_metadata |
DocMetadata | None |
|
children |
list[DocElement] |
Nested elements (methods, subcommands, etc.) |
examples |
list[str] |
Usage examples |
see_also |
list[str] |
Cross-references to related elements |
deprecated |
str | None |
Deprecation notice (if any) |
Methods 2
to_dict
Convert to dictionary for caching/serialization.
to_dict
def to_dict(self) -> dict[str, Any]
Convert to dictionary for caching/serialization.
Returns
dict[str, Any]
from_dict
classmethod
Create from dictionary (for cache loading).
from_dict
classmethod def from_dict(cls, data: dict[str, Any]) -> DocElement
Create from dictionary (for cache loading).
Parameters 1
data |
dict[str, Any] |
Returns
DocElement
Internal Methods 1
_deserialize_typed_metadata
staticmethod
Deserialize typed_metadata from dict.
_deserialize_typed_metadata
staticmethod def _deserialize_typed_metadata(data: dict[str, Any]) -> DocMetadata | None
Deserialize typed_metadata from dict.
Parameters 1
data |
dict[str, Any] |
Dict with "type" and "data" keys |
Returns
Typed metadata instance or NoneDocMetadata | None
—
Extractor
abstract
Base class for all documentation extractors.
Each documentation type (Python, OpenAPI, CLI) implem…
Extractor
abstract Base class for all documentation extractors.
Each documentation type (Python, OpenAPI, CLI) implements this interface. This enables a unified API for generating documentation from different sources.
ABCMethods 2
extract
Extract documentation elements from source.
extract
def extract(self, source: Any) -> list[DocElement]
Extract documentation elements from source.
Parameters 1
source |
Any |
Source to extract from (Path for files, dict for specs, etc.) |
Returns
List of DocElement objects representing the documentation structurelist[DocElement]
—
get_output_path
Determine output path for an element.
get_output_path
def get_output_path(self, element: DocElement) -> Path | None
Determine output path for an element.
Parameters 1
element |
DocElement |
Element to generate path for |
Returns
Relative path for the generated markdown file, or None if the
element should be skipped (e.g., stripped prefix packages)Path | None
—