Module

content_types.registry

Content type strategy registry.

Maps content type names to their strategies and provides lookup functionality.

Functions

normalize_page_type_to_content_type
Normalize a page type to a content type. Handles special cases where page types (from frontmatter)…
1 str | None
def normalize_page_type_to_content_type(page_type: str) -> str | None

Normalize a page type to a content type.

Handles special cases where page types (from frontmatter) map to content types:

  • python-module -> api-reference
  • cli-command -> cli-reference
  • Other types pass through if registered

Parameters 1

Name Type Default Description
page_type str

Page type from frontmatter (e.g., "python-module", "blog")

Returns

str | None

Content type name if recognized, None otherwise

get_strategy
Get the strategy for a content type.
1 ContentTypeStrategy
def get_strategy(content_type: str) -> ContentTypeStrategy

Get the strategy for a content type.

Parameters 1

Name Type Default Description
content_type str

Type name (e.g., "blog", "doc", "api-reference")

Returns

ContentTypeStrategy

ContentTypeStrategy instance

detect_content_type
Auto-detect content type from section characteristics. Uses heuristics from each strategy to deter…
2 str
def detect_content_type(section: Section, config: dict[str, Any] | None = None) -> str

Auto-detect content type from section characteristics.

Uses heuristics from each strategy to determine the best type.

Priority order:

  1. Explicit type in section metadata
  2. Cascaded type from parent section
  3. Auto-detection via strategy heuristics
  4. Config-based default (content.default_type or site.default_content_type)
  5. Default to "list"

Parameters 2

Name Type Default Description
section Section

Section to analyze

config dict[str, Any] | None None

Optional site config for default_content_type lookup

Returns

str

Content type name

register_strategy
Register a custom content type strategy. Allows users to add their own content types.
2 None
def register_strategy(content_type: str, strategy: ContentTypeStrategy) -> None

Register a custom content type strategy.

Allows users to add their own content types.

Parameters 2

Name Type Default Description
content_type str

Type name

strategy ContentTypeStrategy

Strategy instance