Home / Function/ replace_html_links() — fastapi Function Reference

replace_html_links() — fastapi Function Reference

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

Function python FastAPI Routing calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  3405fcf2_6572_cb8b_b678_e8690a631a36["replace_html_links()"]
  c463d6a9_085f_f272_b9fc_455b7e9b6a57["doc_parsing_utils.py"]
  3405fcf2_6572_cb8b_b678_e8690a631a36 -->|defined in| c463d6a9_085f_f272_b9fc_455b7e9b6a57
  63822d7d_03fc_4331_3f93_3026c9c03415["check_translation()"]
  63822d7d_03fc_4331_3f93_3026c9c03415 -->|calls| 3405fcf2_6572_cb8b_b678_e8690a631a36
  5b3b4919_0c37_b982_3e43_e27ec8b34816["_construct_html_link()"]
  3405fcf2_6572_cb8b_b678_e8690a631a36 -->|calls| 5b3b4919_0c37_b982_3e43_e27ec8b34816
  style 3405fcf2_6572_cb8b_b678_e8690a631a36 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/doc_parsing_utils.py lines 433–468

def replace_html_links(
    text: list[str],
    links: list[HtmlLinkInfo],
    original_links: list[HtmlLinkInfo],
    lang_code: str,
) -> list[str]:
    """
    Replace HTML links in the given text with the links from the original document.

    Adjust URLs for the given language code.
    Fail if the number of links does not match the original.
    """

    if len(links) != len(original_links):
        raise ValueError(
            "Number of HTML links does not match the number in the "
            "original document "
            f"({len(links)} vs {len(original_links)})"
        )

    modified_text = text.copy()
    for link_index, link in enumerate(links):
        original_link_info = original_links[link_index]

        # Replace in the document text
        replacement_link = _construct_html_link(
            link_text=link["text"],
            attributes=original_link_info["attributes"],
            lang_code=lang_code,
        )
        line_no = link["line_no"] - 1
        modified_text[line_no] = modified_text[line_no].replace(
            link["full_tag"], replacement_link, 1
        )

    return modified_text

Domain

Subdomains

Frequently Asked Questions

What does replace_html_links() do?
replace_html_links() is a function in the fastapi codebase, defined in scripts/doc_parsing_utils.py.
Where is replace_html_links() defined?
replace_html_links() is defined in scripts/doc_parsing_utils.py at line 433.
What does replace_html_links() call?
replace_html_links() calls 1 function(s): _construct_html_link.
What calls replace_html_links()?
replace_html_links() 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