Home / File/ mkdocs_hooks.py — fastapi Source File

mkdocs_hooks.py — fastapi Source File

Architecture documentation for mkdocs_hooks.py, a python file in the fastapi codebase. 8 imports, 0 dependents.

File python FastAPI Routing 8 imports 11 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  566dbae4_46de_4e4a_0ed4_0c59e40fbcf8["mkdocs_hooks.py"]
  958aa7af_9d63_fe0c_3544_91dd93294508["functools"]
  566dbae4_46de_4e4a_0ed4_0c59e40fbcf8 --> 958aa7af_9d63_fe0c_3544_91dd93294508
  b3e303a2_3f2d_638d_930c_3a5dcc2f5a42["pathlib"]
  566dbae4_46de_4e4a_0ed4_0c59e40fbcf8 --> b3e303a2_3f2d_638d_930c_3a5dcc2f5a42
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  566dbae4_46de_4e4a_0ed4_0c59e40fbcf8 --> 0dda2280_3359_8460_301c_e98c77e78185
  1f446b27_840b_de4a_928e_12416537c4b3["material"]
  566dbae4_46de_4e4a_0ed4_0c59e40fbcf8 --> 1f446b27_840b_de4a_928e_12416537c4b3
  4d8cb7f6_d173_7611_f222_ffe5cdf0bbdb["mkdocs.config.defaults"]
  566dbae4_46de_4e4a_0ed4_0c59e40fbcf8 --> 4d8cb7f6_d173_7611_f222_ffe5cdf0bbdb
  d963152e_0fe3_25bc_ea25_02deeb0e228e["mkdocs.structure.files"]
  566dbae4_46de_4e4a_0ed4_0c59e40fbcf8 --> d963152e_0fe3_25bc_ea25_02deeb0e228e
  9a4404b8_9573_4761_4b99_a11f41312fb1["mkdocs.structure.nav"]
  566dbae4_46de_4e4a_0ed4_0c59e40fbcf8 --> 9a4404b8_9573_4761_4b99_a11f41312fb1
  eec81234_35aa_876c_01df_67871f17e70d["mkdocs.structure.pages"]
  566dbae4_46de_4e4a_0ed4_0c59e40fbcf8 --> eec81234_35aa_876c_01df_67871f17e70d
  style 566dbae4_46de_4e4a_0ed4_0c59e40fbcf8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from functools import lru_cache
from pathlib import Path
from typing import Any, Union

import material
from mkdocs.config.defaults import MkDocsConfig
from mkdocs.structure.files import File, Files
from mkdocs.structure.nav import Link, Navigation, Section
from mkdocs.structure.pages import Page

non_translated_sections = [
    "reference/",
    "release-notes.md",
    "fastapi-people.md",
    "external-links.md",
    "newsletter.md",
    "management-tasks.md",
    "management.md",
]


@lru_cache
def get_missing_translation_content(docs_dir: str) -> str:
    docs_dir_path = Path(docs_dir)
    missing_translation_path = docs_dir_path.parent.parent / "missing-translation.md"
    return missing_translation_path.read_text(encoding="utf-8")


@lru_cache
def get_translation_banner_content(docs_dir: str) -> str:
    docs_dir_path = Path(docs_dir)
    translation_banner_path = docs_dir_path / "translation-banner.md"
    if not translation_banner_path.is_file():
        translation_banner_path = (
            docs_dir_path.parent.parent / "en" / "docs" / "translation-banner.md"
        )
    return translation_banner_path.read_text(encoding="utf-8")


@lru_cache
def get_mkdocs_material_langs() -> list[str]:
    material_path = Path(material.__file__).parent
    material_langs_path = material_path / "templates" / "partials" / "languages"
    langs = [file.stem for file in material_langs_path.glob("*.html")]
    return langs


class EnFile(File):
    pass


def on_config(config: MkDocsConfig, **kwargs: Any) -> MkDocsConfig:
    available_langs = get_mkdocs_material_langs()
    dir_path = Path(config.docs_dir)
    lang = dir_path.parent.name
    if lang in available_langs:
        config.theme["language"] = lang
    if not (config.site_url or "").endswith(f"{lang}/") and lang != "en":
        config.site_url = f"{config.site_url}{lang}/"
    return config
// ... (123 more lines)

Domain

Subdomains

Classes

Dependencies

  • functools
  • material
  • mkdocs.config.defaults
  • mkdocs.structure.files
  • mkdocs.structure.nav
  • mkdocs.structure.pages
  • pathlib
  • typing

Frequently Asked Questions

What does mkdocs_hooks.py do?
mkdocs_hooks.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Routing subdomain.
What functions are defined in mkdocs_hooks.py?
mkdocs_hooks.py defines 11 function(s): generate_renamed_section_items, get_missing_translation_content, get_mkdocs_material_langs, get_translation_banner_content, on_config, on_files, on_nav, on_page_markdown, on_pre_page, resolve_file, and 1 more.
What does mkdocs_hooks.py depend on?
mkdocs_hooks.py imports 8 module(s): functools, material, mkdocs.config.defaults, mkdocs.structure.files, mkdocs.structure.nav, mkdocs.structure.pages, pathlib, typing.
Where is mkdocs_hooks.py in the architecture?
mkdocs_hooks.py is located at scripts/mkdocs_hooks.py (domain: FastAPI, subdomain: Routing, directory: scripts).

Analyze Your Own Codebase

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

Try Supermodel Free