Home / Function/ extract_header_permalinks() — fastapi Function Reference

extract_header_permalinks() — fastapi Function Reference

Architecture documentation for the extract_header_permalinks() function in doc_parsing_utils.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  18c1040f_822a_efb1_8354_766783a44343["extract_header_permalinks()"]
  c463d6a9_085f_f272_b9fc_455b7e9b6a57["doc_parsing_utils.py"]
  18c1040f_822a_efb1_8354_766783a44343 -->|defined in| c463d6a9_085f_f272_b9fc_455b7e9b6a57
  63822d7d_03fc_4331_3f93_3026c9c03415["check_translation()"]
  63822d7d_03fc_4331_3f93_3026c9c03415 -->|calls| 18c1040f_822a_efb1_8354_766783a44343
  style 18c1040f_822a_efb1_8354_766783a44343 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/doc_parsing_utils.py lines 141–189

def extract_header_permalinks(lines: list[str]) -> list[HeaderPermalinkInfo]:
    """
    Extract list of header permalinks from the given lines.

    Return list of HeaderPermalinkInfo, where each dict contains:
    - `line_no` - line number (1-based)
    - `hashes` - string of hashes representing header level (e.g., "###")
    - `permalink` - permalink string (e.g., "{#permalink}")
    """

    headers: list[HeaderPermalinkInfo] = []
    in_code_block3 = False
    in_code_block4 = False

    for line_no, line in enumerate(lines, start=1):
        if not (in_code_block3 or in_code_block4):
            if line.startswith("```"):
                count = len(line) - len(line.lstrip("`"))
                if count == 3:
                    in_code_block3 = True
                    continue
                elif count >= 4:
                    in_code_block4 = True
                    continue

            header_match = HEADER_WITH_PERMALINK_RE.match(line)
            if header_match:
                hashes, title, permalink = header_match.groups()
                headers.append(
                    HeaderPermalinkInfo(
                        hashes=hashes, line_no=line_no, permalink=permalink, title=title
                    )
                )

        elif in_code_block3:
            if line.startswith("```"):
                count = len(line) - len(line.lstrip("`"))
                if count == 3:
                    in_code_block3 = False
                    continue

        elif in_code_block4:
            if line.startswith("````"):
                count = len(line) - len(line.lstrip("`"))
                if count >= 4:
                    in_code_block4 = False
                    continue

    return headers

Domain

Subdomains

Frequently Asked Questions

What does extract_header_permalinks() do?
extract_header_permalinks() is a function in the fastapi codebase, defined in scripts/doc_parsing_utils.py.
Where is extract_header_permalinks() defined?
extract_header_permalinks() is defined in scripts/doc_parsing_utils.py at line 141.
What calls extract_header_permalinks()?
extract_header_permalinks() is called by 1 function(s): check_translation.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free