add_permalinks_page() — fastapi Function Reference
Architecture documentation for the add_permalinks_page() function in docs.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD ee158d7d_d0df_df2d_c16a_072bb9b8958c["add_permalinks_page()"] 089911a1_02c3_0f6b_d62d_71c980ade67e["docs.py"] ee158d7d_d0df_df2d_c16a_072bb9b8958c -->|defined in| 089911a1_02c3_0f6b_d62d_71c980ade67e 5b37f6ed_ea4d_ce9c_8231_0b387f397d99["add_permalinks_pages()"] 5b37f6ed_ea4d_ce9c_8231_0b387f397d99 -->|calls| ee158d7d_d0df_df2d_c16a_072bb9b8958c acca33db_ce7a_6048_24fb_0f8f70535828["add_permalinks()"] acca33db_ce7a_6048_24fb_0f8f70535828 -->|calls| ee158d7d_d0df_df2d_c16a_072bb9b8958c 7383d03e_e16f_8d7e_aa97_fdbcb5b605f9["slugify()"] ee158d7d_d0df_df2d_c16a_072bb9b8958c -->|calls| 7383d03e_e16f_8d7e_aa97_fdbcb5b605f9 9b2d722b_cde0_8e48_48a5_5473341727c3["extract_visible_text()"] ee158d7d_d0df_df2d_c16a_072bb9b8958c -->|calls| 9b2d722b_cde0_8e48_48a5_5473341727c3 style ee158d7d_d0df_df2d_c16a_072bb9b8958c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
scripts/docs.py lines 449–505
def add_permalinks_page(path: Path, update_existing: bool = False):
"""
Add or update header permalinks in specific page of En docs.
"""
if not path.is_relative_to(en_docs_path / "docs"):
raise RuntimeError(f"Path must be inside {en_docs_path}")
rel_path = path.relative_to(en_docs_path / "docs")
# Skip excluded sections
if str(rel_path).startswith(non_translated_sections):
return
visible_text_extractor = VisibleTextExtractor()
updated_lines = []
in_code_block3 = False
in_code_block4 = False
permalinks = set()
with path.open("r", encoding="utf-8") as f:
lines = f.readlines()
for line in lines:
# Handle codeblocks start and end
if not (in_code_block3 or in_code_block4):
if code_block4_pattern.match(line):
in_code_block4 = True
elif code_block3_pattern.match(line):
in_code_block3 = True
else:
if in_code_block4 and code_block4_pattern.match(line):
in_code_block4 = False
elif in_code_block3 and code_block3_pattern.match(line):
in_code_block3 = False
# Process Headers only outside codeblocks
if not (in_code_block3 or in_code_block4):
match = header_pattern.match(line)
if match:
hashes, title, _permalink = match.groups()
if (not _permalink) or update_existing:
slug = slugify(visible_text_extractor.extract_visible_text(title))
if slug in permalinks:
# If the slug is already used, append a number to make it unique
count = 1
original_slug = slug
while slug in permalinks:
slug = f"{original_slug}_{count}"
count += 1
permalinks.add(slug)
line = f"{hashes} {title} {{ #{slug} }}\n"
updated_lines.append(line)
with path.open("w", encoding="utf-8") as f:
f.writelines(updated_lines)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does add_permalinks_page() do?
add_permalinks_page() is a function in the fastapi codebase, defined in scripts/docs.py.
Where is add_permalinks_page() defined?
add_permalinks_page() is defined in scripts/docs.py at line 449.
What does add_permalinks_page() call?
add_permalinks_page() calls 2 function(s): extract_visible_text, slugify.
What calls add_permalinks_page()?
add_permalinks_page() is called by 2 function(s): add_permalinks, add_permalinks_pages.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free