selfdoc v0.15.1 /selfdoc.docs
On this page

Shared resolution pipeline module that reads docs/ templates, resolves directives using the project's language extractor, and returns processed Markdown.

#selfdoc.docs

#selfdoc.docs

Shared resolution pipeline for docs/ templates.

Provides parse_frontmatter (moved from build.py) and resolve_all_docs, which walks docs/, parses frontmatter, and resolves directives for each .md file. Used by build.py, check.py, and gen.py to avoid duplicating the walk-parse-resolve logic.

#parse_frontmatter

python
def parse_frontmatter(content)

Parse YAML-like frontmatter from markdown content (Feature 34).

If the content starts with '---', extracts key: value pairs until the closing '---'. Returns (metadata_dict, remaining_content). If no frontmatter is found, returns ({}, original_content).

Simple parser: splits on ':' (first occurrence), strips whitespace. No YAML library needed.

#resolve_all_docs

python
def resolve_all_docs(config, docs_dir=None, base_dir='.')

Walk docs/, parse frontmatter, resolve directives for each .md file.

Returns dict mapping rel_path to (frontmatter_dict, resolved_content, raw_content, fm_line_count).

  • rel_path: relative to docs_dir (e.g. "index.html", "api/reference/")
  • frontmatter_dict: parsed frontmatter (empty dict if none)
  • resolved_content: markdown with all directives replaced
  • raw_content: original body content (frontmatter stripped, directives

NOT resolved)

  • fm_line_count: number of lines consumed by frontmatter (including

delimiters); 0 when no frontmatter is present