Module

utils.sections

Section-related utility helpers.

Provides safe normalization helpers for section references that may be either Sectionobjects or precomputed string paths depending on context (e.g., runtime vs cached/incremental data structures).

Functions

resolve_page_section_path
Resolve a page's section path as a string, handling multiple representations. The page may expose …
1 str | None
def resolve_page_section_path(page: Any) -> str | None

Resolve a page's section path as a string, handling multiple representations.

The page may expose its section association in different ways depending on build phase or caching:

  • page.sectionmay be aSectionobject with a.pathattribute
  • page.sectionmay already be a string path
  • It may be missing or falsy for root-level pages

Parameters 1

Name Type Default Description
page Any

Page-like object which may have asectionattribute

Returns

str | None

String path to the section (e.g., "docs/tutorials") or None if not set.