okflint.index module

OKF §6 index.md generation.

Pure computation only: no file is written here. cli.py owns the dry-run/diff/write orchestration (see okflint index).

class okflint.index.IndexEntry(filename, title, description)[source]

Bases: object

A single concept file to list in an index.md.

description: str | None
filename: str
title: str
okflint.index.build_index_content(dir_path, entries, subdirs)[source]

Build the OKF §6 markdown body of an index.md for one directory.

No frontmatter is emitted (safe default with respect to R001). Sub-directories are listed before files, both in case-insensitive alphabetical order.

Parameters:
  • dir_path (Path) – Directory this index.md belongs to (kept for signature symmetry with generate_indexes; the content only depends on entries/subdirs).

  • entries (list[IndexEntry]) – Concept files to list.

  • subdirs (list[str]) – Names of sub-directories that own their own index.md.

Return type:

str

Returns:

The markdown body (no frontmatter).

okflint.index.generate_indexes(manifest)[source]

Compute the expected index.md content for every directory in the base.

Walks every manifest root, respecting exclude_patterns and skipping the reserved index/log files. One entry is produced per directory that contains at least one (non-excluded) .md file, directly or in a sub-directory. Performs no write.

Parameters:

manifest (Manifest) – Loaded and validated OKF manifest.

Return type:

dict[Path, str]

Returns:

Mapping from each directory’s expected index.md path to its expected content.