👷 Upgrade build docs configs (#914)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sebastián Ramírez · committed by GitHub · parent b24cf43 · Browse files · 10 files·+137 added−38 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+137 added−38 removed
- other:+137 added−38 removed
Provenance
- Commit
5b82463- Tree
09a4f31- Author
Sebastián Ramírez <tiangolo@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
b24cf43
10 files changed+137 added−38 removed
modified:.github/workflows/build-docs.yml+8 added-6 removed
16 unmodified lines1718192021212223242526272829303132333435363738394014 unmodified lines5556575856596061626364626364656566676869707121 unmodified lines16 unmodified lines outputs: docs: ${{ steps.filter.outputs.docs }} steps: - uses: actions/checkout@v4 # For pull requests it's not necessary to checkout the code but for master it is # For pull requests it's not necessary to checkout the code but for the main branch it is - uses: dorny/paths-filter@v3 id: filter with: filters: | docs: - README.md - docs/** - docs_src/** - requirements-docs.txt - requirements-docs-insiders.txt - pyproject.toml - mkdocs.yml - mkdocs.insiders.yml - mkdocs.maybe-insiders.yml - mkdocs.no-insiders.yml - .github/workflows/build-docs.yml - .github/workflows/deploy-docs.yml
build-docs:14 unmodified lines - uses: actions/cache@v4 id: cache with: path: ${{ env.pythonLocation }} key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v02 key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt', 'requirements-docs-insiders.txt') }}-v02 - name: Install docs extras if: steps.cache.outputs.cache-hit != 'true' run: pip install -r requirements-docs.txt - name: Install Material for MkDocs Insiders if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) && steps.cache.outputs.cache-hit != 'true' run: | pip install git+https://${{ secrets.TYPER_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git pip install git+https://${{ secrets.TYPER_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git pip install git+https://${{ secrets.TYPER_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git run: pip install -r requirements-docs-insiders.txt env: TOKEN: ${{ secrets.TYPER_MKDOCS_MATERIAL_INSIDERS }} - uses: actions/cache@v4 with: key: mkdocs-cards-${{ github.ref }}-v1 path: .cache21 unmodified linesmodified:docs/css/termynal.css+1 added
24 unmodified lines25 padding: 75px 45px 35px;26 position: relative;27 -webkit-box-sizing: border-box;28 box-sizing: border-box;29+ /* Custom line-height */30 line-height: 1.2;31 }32 33 [data-termynal]:before {78 unmodified linesmodified:docs/js/custom.js+3 added-1 removed
108 unmodified lines109 async function main() {110 setupTermynal()111 }112 113+document$.subscribe(() => {113-main()114+ main()115+})modified:docs/js/termynal.js-1 removed
247 unmodified lines248 } else if (prop !== 'value') {249 attrs += `${this.pfx}-${prop}="${line[prop]}" `250 }251 }252-252 return attrs;253 }254 }255 8 unmodified linesmodified:scripts/docs.py+5 added-6 removed
5 unmodified lines6 from http.server import HTTPServer, SimpleHTTPRequestHandler7 from importlib import metadata8 from pathlib import Path9 10-import mkdocs.commands.build11-import mkdocs.commands.serve12-import mkdocs.config13-import mkdocs.utils10 import typer11 12 logging.basicConfig(level=logging.INFO)13 74 unmodified lines88 Takes an optional LANG argument with the name of the language to serve, by default89 en.90 """91 # Enable line numbers during local development to make it easier to highlight96- os.environ["LINENUMS"] = "true"97- mkdocs.commands.serve.serve(dev_addr="127.0.0.1:8008")92+ subprocess.run(93+ ["mkdocs", "serve", "--dev-addr", "127.0.0.1:8008", "--dirty"],94+ env={**os.environ, "LINENUMS": "true"},95+ check=True,96+ )97 98 99 @app.command()100 def build() -> None:36 unmodified linesadded:scripts/mkdocs_hooks.py+38 added
1+from typing import Any, List, Union2+3+from mkdocs.config.defaults import MkDocsConfig4+from mkdocs.structure.files import Files5+from mkdocs.structure.nav import Link, Navigation, Section6+from mkdocs.structure.pages import Page7+8+9+def generate_renamed_section_items(10+ items: List[Union[Page, Section, Link]], *, config: MkDocsConfig11+) -> List[Union[Page, Section, Link]]:12+ new_items: List[Union[Page, Section, Link]] = []13+ for item in items:14+ if isinstance(item, Section):15+ new_title = item.title16+ new_children = generate_renamed_section_items(item.children, config=config)17+ first_child = new_children[0]18+ if isinstance(first_child, Page):19+ if first_child.file.src_path.endswith("index.md"):20+ # Read the source so that the title is parsed and available21+ first_child.read_source(config=config)22+ new_title = first_child.title or new_title23+ # Creating a new section makes it render it collapsed by default24+ # no idea why, so, let's just modify the existing one25+ # new_section = Section(title=new_title, children=new_children)26+ item.title = new_title27+ item.children = new_children28+ new_items.append(item)29+ else:30+ new_items.append(item)31+ return new_items32+33+34+def on_nav(35+ nav: Navigation, *, config: MkDocsConfig, files: Files, **kwargs: Any36+) -> Navigation:37+ new_items = generate_renamed_section_items(nav.items, config=config)38+ return Navigation(items=new_items, pages=nav.pages)modified:mkdocs.insiders.yml+5 added-1 removed
12234567plugins: social: typeset:markdown_extensions: material.extensions.preview: targets: include: - ./*modified:mkdocs.yml+67 added-17 removed
24 unmodified lines25 toggle:26 icon: material/lightbulb-outline27 name: Switch to system preference28 features:29- - search.suggest30- - search.highlight29+ - content.code.annotate30+ - content.code.copy31+ # - content.code.select32+ - content.footnote.tooltips33 - content.tabs.link32- - navigation.indexes34 - content.tooltips35+ - navigation.footer36+ - navigation.indexes37+ - navigation.instant38+ - navigation.instant.prefetch39+ - navigation.instant.preview40+ - navigation.instant.progress41 - navigation.path35- - content.code.annotate36- - content.code.copy37- - content.code.select42 # - navigation.tabs43+ # - navigation.tabs.sticky44+ - navigation.top45+ - navigation.tracking46+ - search.highlight47+ - search.share48+ - search.suggest49+ - toc.follow50+51 icon:52 repo: fontawesome/brands/github-alt53 logo: img/icon.svg54 favicon: img/favicon.png55 language: en56 repo_name: tiangolo/typer57 repo_url: https://github.com/tiangolo/typer46-edit_uri: ""58 plugins:59+ # Material for MkDocs48- search: null60+ search:61+ social:62+ # Other plugins63 redirects:64 redirect_maps:65 typer-cli.md: tutorial/typer-command.md66 67 unmodified lines134 - contributing.md135 - release-notes.md136 137 markdown_extensions:138+ # Python Markdown139+ abbr:140+ attr_list:141+ footnotes:142+ md_in_html:143+ tables:144 toc:145 permalink: true126- markdown.extensions.attr_list:127- markdown.extensions.tables:128- markdown.extensions.md_in_html:146 147+ # Python Markdown Extensions148+ pymdownx.betterem:149+ smart_enable: all150+ pymdownx.caret:151+ pymdownx.highlight:152+ line_spans: __span153+ pymdownx.inlinehilite:154+ pymdownx.keys:155+ pymdownx.mark:156 pymdownx.superfences:157 custom_fences:158 - name: mermaid159 class: mermaid134- format: !!python/name:pymdownx.superfences.fence_code_format ''135- pymdownx.betterem:136- pymdownx.blocks.details:160+ format: !!python/name:pymdownx.superfences.fence_code_format161+ pymdownx.tilde:162+163+ # pymdownx blocks164 pymdownx.blocks.admonition:165 types:166 - note140- - info167+ - attention168+ - caution169+ - danger170+ - error171 - tip172+ - hint173 - warning143- - danger144- - check174+ # Custom types175+ - info176+ pymdownx.blocks.details:177 pymdownx.blocks.tab:178 alternate_style: True179+180+ # Other extensions181 mdx_include:182 base_path: docs183 184 extra:185 analytics:186 provider: google187 property: G-T78C5GNRXK188+ feedback:189+ title: Was this page helpful?190+ ratings:191+ - icon: material/emoticon-happy-outline192+ name: This page was helpful193+ data: 1194+ note: >-195+ Thanks for your feedback!196+ - icon: material/emoticon-sad-outline197+ name: This page could be improved198+ data: 0199+ note: >-200+ Thanks for your feedback!201 social:202 - icon: fontawesome/brands/github-alt203 link: https://github.com/tiangolo/typer204 - icon: fontawesome/brands/twitter13 unmodified lines218 219 extra_javascript:220 - js/termynal.js221 - js/custom.js222+223+hooks:224+ - scripts/mkdocs_hooks.pyadded:requirements-docs-insiders.txt+3 added
1+git+https://${TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git@9.5.30-insiders-4.53.112+git+https://${TOKEN}@github.com/pawamoy-insiders/griffe-typing-deprecated.git3+git+https://${TOKEN}@github.com/pawamoy-insiders/mkdocstrings-python.gitmodified:requirements-docs.txt+7 added-6 removed
1 -e .2 3-mkdocs-material==9.4.73+mkdocs-material==9.5.184 mdx-include >=1.4.1,<2.0.05-mkdocs-markdownextradata-plugin >=0.1.7,<0.3.05 mkdocs-redirects>=1.2.1,<1.3.06 pyyaml >=5.3.1,<7.0.07 # For Material for MkDocs, Chinese search8 # jieba==0.42.19 # For image processing by Material for MkDocs10 pillow==10.3.011 # For image processing by Material for MkDocs13-cairosvg==2.7.014-mkdocstrings[python]==0.23.015-griffe-typingdoc==0.2.212+cairosvg==2.7.113+# mkdocstrings[python]==0.25.114+# Enable griffe-typingdoc once dropping Python 3.7 and upgrading typing-extensions15+# griffe-typingdoc==0.2.516 # For griffe, it formats with black17-black==24.3.017+# black==24.3.018+mkdocs-macros-plugin==1.0.5