-
-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 Upgrade build docs configs (#1047)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0678615
commit 9704924
Showing
9 changed files
with
146 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,4 +110,6 @@ async function main() { | |
setupTermynal() | ||
} | ||
|
||
main() | ||
document$.subscribe(() => { | ||
main() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
plugins: | ||
social: | ||
typeset: | ||
markdown_extensions: | ||
material.extensions.preview: | ||
targets: | ||
include: | ||
- ./* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
git+https://${TOKEN}@github.com/squidfunk/[email protected] | ||
git+https://${TOKEN}@github.com/pawamoy-insiders/griffe-typing-deprecated.git | ||
git+https://${TOKEN}@github.com/pawamoy-insiders/mkdocstrings-python.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
-e . | ||
-r requirements-docs-tests.txt | ||
mkdocs-material==9.4.7 | ||
mkdocs-material==9.5.18 | ||
mdx-include >=1.4.1,<2.0.0 | ||
mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0 | ||
mkdocs-redirects>=1.2.1,<1.3.0 | ||
pyyaml >=5.3.1,<7.0.0 | ||
# For Material for MkDocs, Chinese search | ||
jieba==0.42.1 | ||
# jieba==0.42.1 | ||
# For image processing by Material for MkDocs | ||
pillow==10.1.0 | ||
pillow==10.3.0 | ||
# For image processing by Material for MkDocs | ||
cairosvg==2.7.1 | ||
mkdocstrings[python]==0.25.1 | ||
# mkdocstrings[python]==0.25.1 | ||
# Enable griffe-typingdoc once dropping Python 3.7 and upgrading typing-extensions | ||
# griffe-typingdoc==0.2.5 | ||
# For griffe, it formats with black | ||
typer == 0.12.3 | ||
mkdocs-macros-plugin==1.0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import Any, List, Union | ||
|
||
from mkdocs.config.defaults import MkDocsConfig | ||
from mkdocs.structure.files import Files | ||
from mkdocs.structure.nav import Link, Navigation, Section | ||
from mkdocs.structure.pages import Page | ||
|
||
|
||
def generate_renamed_section_items( | ||
items: List[Union[Page, Section, Link]], *, config: MkDocsConfig | ||
) -> List[Union[Page, Section, Link]]: | ||
new_items: List[Union[Page, Section, Link]] = [] | ||
for item in items: | ||
if isinstance(item, Section): | ||
new_title = item.title | ||
new_children = generate_renamed_section_items(item.children, config=config) | ||
first_child = new_children[0] | ||
if isinstance(first_child, Page): | ||
if first_child.file.src_path.endswith("index.md"): | ||
# Read the source so that the title is parsed and available | ||
first_child.read_source(config=config) | ||
new_title = first_child.title or new_title | ||
# Creating a new section makes it render it collapsed by default | ||
# no idea why, so, let's just modify the existing one | ||
# new_section = Section(title=new_title, children=new_children) | ||
item.title = new_title | ||
item.children = new_children | ||
new_items.append(item) | ||
else: | ||
new_items.append(item) | ||
return new_items | ||
|
||
|
||
def on_nav( | ||
nav: Navigation, *, config: MkDocsConfig, files: Files, **kwargs: Any | ||
) -> Navigation: | ||
new_items = generate_renamed_section_items(nav.items, config=config) | ||
return Navigation(items=new_items, pages=nav.pages) |