mkdocs-mknodes 0.4.6__tar.gz → 0.4.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mkdocs_mknodes-0.4.7/.github/dependabot.yml +10 -0
- mkdocs_mknodes-0.4.7/.github/workflows/build.yml +83 -0
- mkdocs_mknodes-0.4.7/.github/workflows/documentation.yml +61 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/.pre-commit-config.yaml +2 -2
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/PKG-INFO +2 -2
- mkdocs_mknodes-0.4.7/duties.py +67 -0
- mkdocs_mknodes-0.4.7/mkdocs.yml +97 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/__init__.py +1 -1
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/backends/markdownbackend.py +1 -1
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/backends/mkdocsbackend.py +3 -3
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/commands/build_page.py +11 -5
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/commands/serve.py +1 -1
- mkdocs_mknodes-0.4.7/mkdocs_mknodes/commands/utils.py +158 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/mkdocsconfig.py +6 -4
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/mknodesconfig.py +3 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/plugin/__init__.py +18 -5
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/plugin/mkdocsbuilder.py +5 -5
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/plugin/pluginconfig.py +6 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/pyproject.toml +50 -97
- mkdocs_mknodes-0.4.6/.github/workflows/build.yml +0 -72
- mkdocs_mknodes-0.4.6/.github/workflows/documentation.yml +0 -60
- mkdocs_mknodes-0.4.6/duties.py +0 -72
- mkdocs_mknodes-0.4.6/mkdocs.yml +0 -96
- mkdocs_mknodes-0.4.6/mkdocs_mknodes/commands/utils.py +0 -62
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/.editorconfig +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/.github/README.md +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/.gitignore +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/LICENSE +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/README.md +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/configs/mkdocs_mkdocs.yml +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/configs/mkdocs_shared.yml +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/docs/assets/cli.gif +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/docs/build_process.jinja +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/docs/cli_index.jinja +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/docs/github_index.jinja +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/docs/index.jinja +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/docs/plugin_configuration.jinja +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/docs/use_case_by_config.jinja +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/docs/use_case_default_website.jinja +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/docs/use_cases_index.jinja +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/docs/why_should_i_use_mknodes.jinja +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/backends/__init__.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/backends/buildbackend.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/buildcollector.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/buildcontext.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/cli/__init__.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/cli/richstate.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/commands/__init__.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/manual/__init__.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/manual/cli_section.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/manual/get_started_section.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/manual/github_index.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/manual/root.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/manual/use_cases_section.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/mkdefaultwebsite.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/paths.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/plugin/mkdocshelpers.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/plugin/rewriteloader.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/py.typed +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/resources/mkdocs_basic.yml +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes/resources/timeline_data.toml +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/mkdocs_mknodes.sublime-project +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/overrides/_dummy.txt +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/overrides/partials/actions.html +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/tests/__init__.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/tests/conftest.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/tests/data/objects.inv +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/tests/test_build.py +0 -0
- {mkdocs_mknodes-0.4.6 → mkdocs_mknodes-0.4.7}/tests/test_cli.py +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
strategy:
|
|
9
|
+
matrix:
|
|
10
|
+
python_version: ["3.11", "3.12", "3.13"]
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: Check out repository
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Set up Python ${{ matrix.python_version }}
|
|
17
|
+
uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python_version }}
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: yezz123/setup-uv@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Graphviz
|
|
25
|
+
uses: ts-graphviz/setup-graphviz@v2
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: |
|
|
29
|
+
uv sync --all-extras
|
|
30
|
+
|
|
31
|
+
- name: Lint and typecheck
|
|
32
|
+
run: |
|
|
33
|
+
uv run ruff check .
|
|
34
|
+
uv run ruff format --check .
|
|
35
|
+
uv run mypy mkdocs_mknodes/
|
|
36
|
+
|
|
37
|
+
- name: Test
|
|
38
|
+
run: |
|
|
39
|
+
uv run pytest --cov-report=xml
|
|
40
|
+
|
|
41
|
+
- uses: codecov/codecov-action@v4
|
|
42
|
+
with:
|
|
43
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
44
|
+
fail_ci_if_error: false
|
|
45
|
+
verbose: true
|
|
46
|
+
|
|
47
|
+
release:
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
needs: test
|
|
50
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
51
|
+
permissions:
|
|
52
|
+
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
53
|
+
id-token: write
|
|
54
|
+
contents: write
|
|
55
|
+
steps:
|
|
56
|
+
- name: Check out repository
|
|
57
|
+
uses: actions/checkout@v4
|
|
58
|
+
|
|
59
|
+
- name: Set up Python 3.12
|
|
60
|
+
uses: actions/setup-python@v5
|
|
61
|
+
with:
|
|
62
|
+
python-version: "3.12"
|
|
63
|
+
|
|
64
|
+
- name: Install uv
|
|
65
|
+
uses: yezz123/setup-uv@v4
|
|
66
|
+
|
|
67
|
+
- name: Build package
|
|
68
|
+
run: |
|
|
69
|
+
uv build
|
|
70
|
+
|
|
71
|
+
- name: Publish package on PyPI
|
|
72
|
+
env:
|
|
73
|
+
UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }}
|
|
74
|
+
run: |
|
|
75
|
+
uv publish
|
|
76
|
+
|
|
77
|
+
- name: Publish package on GitHub
|
|
78
|
+
uses: ncipollo/release-action@v1
|
|
79
|
+
with:
|
|
80
|
+
draft: true
|
|
81
|
+
body: ${{ github.event.head_commit.message }}
|
|
82
|
+
artifacts: dist/*.whl,dist/*.tar.gz
|
|
83
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: Build documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
pages: write
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
14
|
+
# Allow one concurrent deployment
|
|
15
|
+
concurrency:
|
|
16
|
+
group: "pages"
|
|
17
|
+
cancel-in-progress: true
|
|
18
|
+
|
|
19
|
+
# Default to bash
|
|
20
|
+
defaults:
|
|
21
|
+
run:
|
|
22
|
+
shell: bash
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
build:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 0
|
|
32
|
+
- name: Set up Python
|
|
33
|
+
uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.11"
|
|
36
|
+
- name: Setup Graphviz
|
|
37
|
+
uses: ts-graphviz/setup-graphviz@v2
|
|
38
|
+
- name: Install uv
|
|
39
|
+
uses: yezz123/setup-uv@v4
|
|
40
|
+
- name: Install dependencies
|
|
41
|
+
run: |
|
|
42
|
+
uv sync --all-extras
|
|
43
|
+
- name: Build
|
|
44
|
+
run: |
|
|
45
|
+
uv run mkdocs build -v
|
|
46
|
+
uv run mknodes build -d ../site/mkdocs -p configs/mkdocs_mkdocs.yml -v --clone-depth 100
|
|
47
|
+
- name: Upload artifact
|
|
48
|
+
uses: actions/upload-pages-artifact@v3
|
|
49
|
+
with:
|
|
50
|
+
path: ./site
|
|
51
|
+
|
|
52
|
+
deploy:
|
|
53
|
+
environment:
|
|
54
|
+
name: github-pages
|
|
55
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
needs: build
|
|
58
|
+
steps:
|
|
59
|
+
- name: Deploy to GitHub Pages
|
|
60
|
+
id: deployment
|
|
61
|
+
uses: actions/deploy-pages@v4
|
|
@@ -6,7 +6,7 @@ repos:
|
|
|
6
6
|
hooks:
|
|
7
7
|
- id: pytest-check
|
|
8
8
|
name: pytest-check
|
|
9
|
-
entry:
|
|
9
|
+
entry: uv run pytest
|
|
10
10
|
language: system
|
|
11
11
|
# stages: [push]
|
|
12
12
|
types: [python]
|
|
@@ -29,7 +29,7 @@ repos:
|
|
|
29
29
|
# https://pre-commit.com/hooks.html
|
|
30
30
|
|
|
31
31
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
32
|
-
rev: v1.
|
|
32
|
+
rev: v1.12.0
|
|
33
33
|
hooks:
|
|
34
34
|
- id: mypy
|
|
35
35
|
# args: [--ignore-missing-imports]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: mkdocs-mknodes
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.7
|
|
4
4
|
Summary: Don't write docs. Code them.
|
|
5
5
|
Project-URL: Documentation, https://phil65.github.io/mkdocs-mknodes/
|
|
6
6
|
Project-URL: Source, https://github.com/phil65/mkdocs_mknodes
|
|
@@ -11,7 +11,6 @@ License-File: LICENSE
|
|
|
11
11
|
Keywords: docs,docstrings,documentation,framework,internet,markdown
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
14
|
Classifier: Operating System :: OS Independent
|
|
16
15
|
Classifier: Programming Language :: Python :: 3
|
|
17
16
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
@@ -28,6 +27,7 @@ Requires-Dist: jinja2
|
|
|
28
27
|
Requires-Dist: jinjarope
|
|
29
28
|
Requires-Dist: mkdocs>=1.5
|
|
30
29
|
Requires-Dist: mknodes
|
|
30
|
+
Requires-Dist: pathspec
|
|
31
31
|
Requires-Dist: rich
|
|
32
32
|
Requires-Dist: typer
|
|
33
33
|
Requires-Dist: universal-pathlib
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from duty import duty
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@duty(capture=False)
|
|
7
|
+
def build(ctx, *args: str):
|
|
8
|
+
"""Build a MkNodes page."""
|
|
9
|
+
args_str = " " + " ".join(args) if args else ""
|
|
10
|
+
ctx.run(f"uv run mknodes build{args_str}")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@duty(capture=False)
|
|
14
|
+
def serve(ctx, *args: str):
|
|
15
|
+
"""Serve a MkNodes page."""
|
|
16
|
+
args_str = " " + " ".join(args) if args else ""
|
|
17
|
+
ctx.run(f"uv run mknodes serve{args_str}")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@duty(capture=False)
|
|
21
|
+
def test(ctx, *args: str):
|
|
22
|
+
"""Serve a MkNodes page."""
|
|
23
|
+
args_str = " " + " ".join(args) if args else ""
|
|
24
|
+
ctx.run(f"uv run pytest{args_str}")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@duty(capture=False)
|
|
28
|
+
def clean(ctx):
|
|
29
|
+
"""Clean all files from the Git directory except checked-in files."""
|
|
30
|
+
ctx.run("git clean -dfX")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@duty(capture=False)
|
|
34
|
+
def update(ctx):
|
|
35
|
+
"""Update all environment packages using pip directly."""
|
|
36
|
+
ctx.run("uv sync --all-extras")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@duty(capture=False)
|
|
40
|
+
def lint(ctx):
|
|
41
|
+
"""Lint the code and fix issues if possible."""
|
|
42
|
+
ctx.run("uv run ruff check --fix .")
|
|
43
|
+
ctx.run("uv run ruff format .")
|
|
44
|
+
ctx.run("uv run mypy mkdocs_mknodes/")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@duty(capture=False)
|
|
48
|
+
def lint_check(ctx):
|
|
49
|
+
"""Lint the code."""
|
|
50
|
+
ctx.run("uv run ruff check .")
|
|
51
|
+
ctx.run("uv run ruff format --check .")
|
|
52
|
+
ctx.run("uv run mypy mkdocs_mknodes/")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@duty(capture=False)
|
|
56
|
+
def docs_test_build(ctx):
|
|
57
|
+
"""Build some test pages."""
|
|
58
|
+
ctx.run("uv run mkdocs build -v")
|
|
59
|
+
opts = "-d ../site/mkdocs -p configs/mkdocs_mkdocs.yml -v --clone-depth 100"
|
|
60
|
+
ctx.run(f"uv run mknodes build {opts}")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@duty(capture=False)
|
|
64
|
+
def version(ctx, *args: str):
|
|
65
|
+
"""Bump package version."""
|
|
66
|
+
args_str = " " + " ".join(args) if args else ""
|
|
67
|
+
ctx.run(f"hatch version{args_str}")
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
site_name: MkNodes (MkDocs plugin)
|
|
2
|
+
site_description: "Don´t write docs. Code them."
|
|
3
|
+
repo_url: "https://github.com/phil65/mkdocs_mknodes/"
|
|
4
|
+
site_url: https://phil65.github.io/mkdocs-mknodes/
|
|
5
|
+
site_author: Philipp Temminghoff
|
|
6
|
+
copyright: Copyright © 2023 Philipp Temminghoff
|
|
7
|
+
|
|
8
|
+
theme:
|
|
9
|
+
name: material
|
|
10
|
+
custom_dir: overrides
|
|
11
|
+
icon:
|
|
12
|
+
logo: material/graph-outline
|
|
13
|
+
palette:
|
|
14
|
+
# Palette toggle for light mode
|
|
15
|
+
- media: "(prefers-color-scheme: light)"
|
|
16
|
+
scheme: default
|
|
17
|
+
primary: custom
|
|
18
|
+
toggle:
|
|
19
|
+
icon: material/brightness-7
|
|
20
|
+
name: Switch to dark mode
|
|
21
|
+
|
|
22
|
+
# Palette toggle for dark mode
|
|
23
|
+
- media: "(prefers-color-scheme: dark)"
|
|
24
|
+
scheme: slate
|
|
25
|
+
primary: custom
|
|
26
|
+
toggle:
|
|
27
|
+
icon: material/brightness-4
|
|
28
|
+
name: Switch to light mode
|
|
29
|
+
features:
|
|
30
|
+
- announce.dismiss
|
|
31
|
+
- content.action.edit
|
|
32
|
+
- content.code.copy
|
|
33
|
+
- content.code.select
|
|
34
|
+
- content.code.annotate
|
|
35
|
+
# - content.tooltips # for insiders..
|
|
36
|
+
# - content.tabs.link
|
|
37
|
+
- navigation.tracking # update URL based on current item in TOC
|
|
38
|
+
- navigation.path # shows breadcrumbs
|
|
39
|
+
- navigation.tabs # make top level tabs
|
|
40
|
+
- navigation.indexes # documents can be directly attached to sections (overview pages)
|
|
41
|
+
- navigation.footer # next/previous page buttons in footer
|
|
42
|
+
- navigation.top # adds back-to-top button
|
|
43
|
+
# - navigation.sections # top-level sections are rendered as groups
|
|
44
|
+
# - navigation.expand # expand all subsections in left sidebar by default
|
|
45
|
+
- toc.follow # makes toc follow scrolling
|
|
46
|
+
# - toc.integrate # integrates toc into left menu
|
|
47
|
+
- search.highlight
|
|
48
|
+
- search.suggest
|
|
49
|
+
# - search.share
|
|
50
|
+
|
|
51
|
+
plugins:
|
|
52
|
+
- search
|
|
53
|
+
- mknodes:
|
|
54
|
+
build_fn: mkdocs_mknodes.manual.root:Build.build
|
|
55
|
+
show_page_info: true
|
|
56
|
+
global_resources: false
|
|
57
|
+
- mkdocstrings:
|
|
58
|
+
default_handler: python
|
|
59
|
+
handlers:
|
|
60
|
+
python:
|
|
61
|
+
import:
|
|
62
|
+
- url: https://docs.python.org/3/objects.inv
|
|
63
|
+
domains: [std, py]
|
|
64
|
+
- url: https://phil65.github.io/mknodes/objects.inv
|
|
65
|
+
domains: [std, py]
|
|
66
|
+
options:
|
|
67
|
+
extensions:
|
|
68
|
+
- griffe_fieldz: { include_inherited: true }
|
|
69
|
+
# https://mkdocstrings.github.io/python/usage/
|
|
70
|
+
show_signature_annotations: true
|
|
71
|
+
show_symbol_type_toc: true
|
|
72
|
+
show_symbol_type_heading: true
|
|
73
|
+
show_root_toc_entry: false
|
|
74
|
+
# merge_init_into_class: true
|
|
75
|
+
ignore_init_summary: true
|
|
76
|
+
inherited_members: false
|
|
77
|
+
signature_crossrefs: true
|
|
78
|
+
separate_signature: true
|
|
79
|
+
line_length: 90
|
|
80
|
+
preload_modules:
|
|
81
|
+
- mknodes
|
|
82
|
+
markdown_extensions:
|
|
83
|
+
- attr_list
|
|
84
|
+
- pymdownx.emoji
|
|
85
|
+
- toc:
|
|
86
|
+
permalink: true
|
|
87
|
+
# extra:
|
|
88
|
+
# social:
|
|
89
|
+
# - icon: fontawesome/brands/github
|
|
90
|
+
# link: https://github.com/phil65
|
|
91
|
+
# - icon: fontawesome/brands/gitter
|
|
92
|
+
# link: https://matrix.to/#/#mknodes:gitter.im
|
|
93
|
+
# - icon: fontawesome/brands/python
|
|
94
|
+
# link: https://pypi.org/project/mknodes/
|
|
95
|
+
# generator: false disable "made with Material"
|
|
96
|
+
# version: # multiple doc versions
|
|
97
|
+
# provider: mike
|
|
@@ -14,7 +14,7 @@ logger = log.get_logger(__name__)
|
|
|
14
14
|
class MarkdownBackend(buildbackend.BuildBackend):
|
|
15
15
|
def __init__(
|
|
16
16
|
self,
|
|
17
|
-
directory: str | os.PathLike | None = None,
|
|
17
|
+
directory: str | os.PathLike[str] | None = None,
|
|
18
18
|
extension: str = ".md",
|
|
19
19
|
):
|
|
20
20
|
"""Constructor.
|
|
@@ -25,8 +25,8 @@ class MkDocsBackend(buildbackend.BuildBackend):
|
|
|
25
25
|
def __init__(
|
|
26
26
|
self,
|
|
27
27
|
files: files_.Files | None = None,
|
|
28
|
-
config: mkdocsconfig.Config | MkDocsConfig | str | os.PathLike | None = None,
|
|
29
|
-
directory: str | os.PathLike | None = None,
|
|
28
|
+
config: mkdocsconfig.Config | MkDocsConfig | str | os.PathLike[str] | None = None,
|
|
29
|
+
directory: str | os.PathLike[str] | None = None,
|
|
30
30
|
):
|
|
31
31
|
"""Constructor.
|
|
32
32
|
|
|
@@ -140,7 +140,7 @@ class MkDocsBackend(buildbackend.BuildBackend):
|
|
|
140
140
|
logger.info("Creating %s...", target_path.as_posix())
|
|
141
141
|
pathhelpers.write_file(html, target_path)
|
|
142
142
|
|
|
143
|
-
def _write_file(self, path: str | os.PathLike, content: str | bytes):
|
|
143
|
+
def _write_file(self, path: str | os.PathLike[str], content: str | bytes):
|
|
144
144
|
path = pathlib.PurePath(path).as_posix()
|
|
145
145
|
file_for_path = self.builder.get_file(path, src_dir=self.directory)
|
|
146
146
|
new_path = upath.UPath(file_for_path.abs_src_path)
|
|
@@ -10,7 +10,7 @@ from urllib.parse import urljoin
|
|
|
10
10
|
from mkdocs.commands import build as mkdocs_build
|
|
11
11
|
from mkdocs.config import load_config
|
|
12
12
|
from mkdocs.plugins import get_plugin_logger
|
|
13
|
-
from mkdocs.structure.files import InclusionLevel
|
|
13
|
+
from mkdocs.structure.files import InclusionLevel
|
|
14
14
|
from mkdocs.structure.nav import get_navigation
|
|
15
15
|
from mkdocs.structure.pages import Page
|
|
16
16
|
from mknodes.info import mkdocsconfigfile
|
|
@@ -27,7 +27,7 @@ logger = get_plugin_logger(__name__)
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
def build(
|
|
30
|
-
config_path: str | os.PathLike,
|
|
30
|
+
config_path: str | os.PathLike[str],
|
|
31
31
|
repo_path: str,
|
|
32
32
|
build_fn: str | None,
|
|
33
33
|
site_dir: str | None = None,
|
|
@@ -97,17 +97,17 @@ def _build(
|
|
|
97
97
|
logger.info("The directory contains stale files. Use --clean to remove them.")
|
|
98
98
|
# First gather all data from all files/pages to ensure all data is
|
|
99
99
|
# consistent across all pages.
|
|
100
|
-
files = get_files(config)
|
|
100
|
+
files = utils.get_files(config)
|
|
101
101
|
env = config.theme.get_env()
|
|
102
102
|
files.add_files_from_theme(env, config)
|
|
103
103
|
files = config.plugins.on_files(files, config=config)
|
|
104
104
|
# If plugins have added files without setting inclusion level, calculate it again.
|
|
105
|
-
set_exclusions(files._files, config)
|
|
105
|
+
utils.set_exclusions(files._files, config)
|
|
106
106
|
nav = get_navigation(files, config)
|
|
107
107
|
# Run `nav` plugin events.
|
|
108
108
|
nav = config.plugins.on_nav(nav, config=config, files=files)
|
|
109
109
|
logger.debug("Reading markdown pages.")
|
|
110
|
-
excluded = []
|
|
110
|
+
excluded: list[str] = []
|
|
111
111
|
for file in files.documentation_pages(inclusion=inclusion):
|
|
112
112
|
logger.debug("Reading: %s", file.src_uri)
|
|
113
113
|
if file.page is None and file.inclusion.is_not_in_nav():
|
|
@@ -146,3 +146,9 @@ def _build(
|
|
|
146
146
|
file.page.validate_anchor_links(files=files, log_level=log_level)
|
|
147
147
|
# Run `post_build` plugin events.
|
|
148
148
|
config.plugins.on_post_build(config=config)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
if __name__ == "__main__":
|
|
152
|
+
config = mkdocsconfigfile.MkDocsConfigFile("mkdocs.yml")
|
|
153
|
+
print(config.dump_config())
|
|
154
|
+
build("mkdocs.yml", ".", "mkdocs_mknodes.manual.root:Build.build")
|
|
@@ -26,7 +26,7 @@ logger = log.get_logger(__name__)
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
def serve(
|
|
29
|
-
config_path: str | os.PathLike = paths.CFG_DEFAULT,
|
|
29
|
+
config_path: str | os.PathLike[str] = paths.CFG_DEFAULT,
|
|
30
30
|
repo_path: str = ".",
|
|
31
31
|
build_fn: str = paths.DEFAULT_BUILD_FN,
|
|
32
32
|
clone_depth: int = 100,
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""The Mkdocs Plugin."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import collections
|
|
6
|
+
from collections.abc import Callable, Iterable
|
|
7
|
+
import contextlib
|
|
8
|
+
import functools
|
|
9
|
+
import logging
|
|
10
|
+
import os
|
|
11
|
+
import pathlib
|
|
12
|
+
import time
|
|
13
|
+
from typing import TYPE_CHECKING, Any, TypeVar
|
|
14
|
+
|
|
15
|
+
from mkdocs import exceptions
|
|
16
|
+
from mkdocs.plugins import get_plugin_logger
|
|
17
|
+
from mkdocs.structure.files import File, Files, InclusionLevel, _file_sort_key
|
|
18
|
+
import pathspec
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from mkdocs.config.defaults import MkDocsConfig
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
logger = get_plugin_logger(__name__)
|
|
26
|
+
|
|
27
|
+
_default_exclude = pathspec.gitignore.GitIgnoreSpec.from_lines([".*", "/templates/"])
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
T = TypeVar("T")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class CountHandler(logging.NullHandler):
|
|
34
|
+
"""Counts all logged messages >= level."""
|
|
35
|
+
|
|
36
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
37
|
+
self.counts: dict[int, int] = collections.defaultdict(int)
|
|
38
|
+
super().__init__(**kwargs)
|
|
39
|
+
|
|
40
|
+
def handle(self, record):
|
|
41
|
+
rv = self.filter(record)
|
|
42
|
+
if rv:
|
|
43
|
+
# Use levelno for keys so they can be sorted later
|
|
44
|
+
self.counts[record.levelno] += 1
|
|
45
|
+
return rv
|
|
46
|
+
|
|
47
|
+
def get_counts(self) -> list[tuple[str, int]]:
|
|
48
|
+
return [
|
|
49
|
+
(logging.getLevelName(k), v)
|
|
50
|
+
for k, v in sorted(self.counts.items(), reverse=True)
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def count_warnings(fn: Callable[..., T]) -> Callable[..., T]:
|
|
55
|
+
@functools.wraps(fn)
|
|
56
|
+
def wrapped(config: MkDocsConfig, *args, **kwargs) -> T:
|
|
57
|
+
start = time.monotonic()
|
|
58
|
+
warning_counter = CountHandler()
|
|
59
|
+
warning_counter.setLevel(logging.WARNING)
|
|
60
|
+
if config.strict:
|
|
61
|
+
logging.getLogger("mkdocs").addHandler(warning_counter)
|
|
62
|
+
result = fn(config, *args, **kwargs)
|
|
63
|
+
counts = warning_counter.get_counts()
|
|
64
|
+
if counts:
|
|
65
|
+
msg = ", ".join(f"{v} {k.lower()}s" for k, v in counts)
|
|
66
|
+
msg = f"Aborted with {msg} in strict mode!"
|
|
67
|
+
raise exceptions.Abort(msg)
|
|
68
|
+
duration = time.monotonic() - start
|
|
69
|
+
logger.info("Documentation built in %.2f seconds", duration)
|
|
70
|
+
logging.getLogger("mkdocs").removeHandler(warning_counter)
|
|
71
|
+
|
|
72
|
+
return result
|
|
73
|
+
|
|
74
|
+
return wrapped
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def handle_exceptions(fn: Callable[..., T]) -> Callable[..., T]:
|
|
78
|
+
@functools.wraps(fn)
|
|
79
|
+
def wrapped(config: MkDocsConfig, *args, **kwargs) -> T:
|
|
80
|
+
try:
|
|
81
|
+
return fn(config, *args, **kwargs)
|
|
82
|
+
except Exception as e:
|
|
83
|
+
# Run `build_error` plugin events.
|
|
84
|
+
config.plugins.on_build_error(error=e)
|
|
85
|
+
if isinstance(e, exceptions.BuildError):
|
|
86
|
+
msg = "Aborted with a BuildError!"
|
|
87
|
+
logger.exception(msg)
|
|
88
|
+
raise exceptions.Abort(msg) from e
|
|
89
|
+
raise
|
|
90
|
+
# finally:
|
|
91
|
+
# logging.getLogger("mkdocs").removeHandler(warning_counter)
|
|
92
|
+
|
|
93
|
+
return wrapped
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def set_exclusions(files: Iterable[File], config: MkDocsConfig) -> None:
|
|
97
|
+
"""Re-calculate which files are excluded, based on the patterns in the config."""
|
|
98
|
+
exclude: pathspec.gitignore.GitIgnoreSpec | None = config.get("exclude_docs")
|
|
99
|
+
exclude = _default_exclude + exclude if exclude else _default_exclude
|
|
100
|
+
drafts: pathspec.gitignore.GitIgnoreSpec | None = config.get("draft_docs")
|
|
101
|
+
nav_exclude: pathspec.gitignore.GitIgnoreSpec | None = config.get("not_in_nav")
|
|
102
|
+
|
|
103
|
+
for file in files:
|
|
104
|
+
if file.inclusion == InclusionLevel.UNDEFINED:
|
|
105
|
+
if exclude.match_file(file.src_uri):
|
|
106
|
+
file.inclusion = InclusionLevel.EXCLUDED
|
|
107
|
+
elif drafts and drafts.match_file(file.src_uri):
|
|
108
|
+
file.inclusion = InclusionLevel.DRAFT
|
|
109
|
+
elif nav_exclude and nav_exclude.match_file(file.src_uri):
|
|
110
|
+
file.inclusion = InclusionLevel.NOT_IN_NAV
|
|
111
|
+
else:
|
|
112
|
+
file.inclusion = InclusionLevel.INCLUDED
|
|
113
|
+
|
|
114
|
+
file.inclusion = InclusionLevel.INCLUDED
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def get_files(config: MkDocsConfig) -> Files:
|
|
118
|
+
"""Walk the `docs_dir` and return a Files collection."""
|
|
119
|
+
files: list[File] = []
|
|
120
|
+
conflicting_files: list[tuple[File, File]] = []
|
|
121
|
+
for source_dir, dirnames, filenames in os.walk(config["docs_dir"], followlinks=True):
|
|
122
|
+
relative_dir = os.path.relpath(source_dir, config["docs_dir"])
|
|
123
|
+
dirnames.sort()
|
|
124
|
+
filenames.sort(key=_file_sort_key)
|
|
125
|
+
|
|
126
|
+
files_by_dest: dict[str, File] = {}
|
|
127
|
+
for filename in filenames:
|
|
128
|
+
path = pathlib.Path(relative_dir) / filename
|
|
129
|
+
file = File(
|
|
130
|
+
str(path),
|
|
131
|
+
config["docs_dir"],
|
|
132
|
+
config["site_dir"],
|
|
133
|
+
config["use_directory_urls"],
|
|
134
|
+
)
|
|
135
|
+
# Skip README.md if an index file also exists in dir (part 1)
|
|
136
|
+
prev_file = files_by_dest.setdefault(file.dest_uri, file)
|
|
137
|
+
if prev_file is not file:
|
|
138
|
+
conflicting_files.append((prev_file, file))
|
|
139
|
+
files.append(file)
|
|
140
|
+
prev_file = file
|
|
141
|
+
|
|
142
|
+
set_exclusions(files, config)
|
|
143
|
+
# Skip README.md if an index file also exists in dir (part 2)
|
|
144
|
+
for a, b in conflicting_files:
|
|
145
|
+
if b.inclusion.is_included():
|
|
146
|
+
if a.inclusion.is_included():
|
|
147
|
+
logger.warning(
|
|
148
|
+
"Excluding '%s' from site because it conflicts with '%s'.",
|
|
149
|
+
a.src_uri,
|
|
150
|
+
b.src_uri,
|
|
151
|
+
)
|
|
152
|
+
# avoid errors if attempting to remove the same file twice.
|
|
153
|
+
with contextlib.suppress(ValueError):
|
|
154
|
+
files.remove(a)
|
|
155
|
+
else:
|
|
156
|
+
with contextlib.suppress(ValueError):
|
|
157
|
+
files.remove(b)
|
|
158
|
+
return Files(files)
|
|
@@ -8,7 +8,7 @@ import io
|
|
|
8
8
|
import os
|
|
9
9
|
import pathlib
|
|
10
10
|
import sys
|
|
11
|
-
from typing import
|
|
11
|
+
from typing import Any, TextIO
|
|
12
12
|
from urllib import parse
|
|
13
13
|
|
|
14
14
|
import jinjarope
|
|
@@ -24,7 +24,9 @@ logger = get_plugin_logger(__name__)
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
@contextlib.contextmanager
|
|
27
|
-
def _open_config_file(
|
|
27
|
+
def _open_config_file(
|
|
28
|
+
config_file: str | os.PathLike[str] | TextIO | None,
|
|
29
|
+
) -> Iterator[TextIO]:
|
|
28
30
|
"""A context manager which yields an open file descriptor ready to be read.
|
|
29
31
|
|
|
30
32
|
Accepts a filename as a string, an open or closed file descriptor, or None.
|
|
@@ -73,7 +75,7 @@ def _open_config_file(config_file: str | os.PathLike | IO | None) -> Iterator[IO
|
|
|
73
75
|
|
|
74
76
|
@functools.cache
|
|
75
77
|
def load_config(
|
|
76
|
-
config_file: str |
|
|
78
|
+
config_file: str | TextIO | None = None,
|
|
77
79
|
*,
|
|
78
80
|
config_file_path: str | None = None,
|
|
79
81
|
**kwargs,
|
|
@@ -116,7 +118,7 @@ def load_config(
|
|
|
116
118
|
class Config:
|
|
117
119
|
"""MkDocs config file wrapper."""
|
|
118
120
|
|
|
119
|
-
def __init__(self, config: Mapping | str | os.PathLike | None = None):
|
|
121
|
+
def __init__(self, config: Mapping | str | os.PathLike[str] | None = None):
|
|
120
122
|
"""Constructor.
|
|
121
123
|
|
|
122
124
|
Arguments:
|
|
@@ -101,3 +101,6 @@ class MkNodesConfig:
|
|
|
101
101
|
watch: list[pathlib.Path] = dataclasses.field(default_factory=list)
|
|
102
102
|
"""A list of extra paths to watch while running `mkdocs serve`."""
|
|
103
103
|
validation: dict = dataclasses.field(default_factory=dict)
|
|
104
|
+
llm_base_url: str = "http://localhost:11434"
|
|
105
|
+
llm_token: str = ""
|
|
106
|
+
llm_model: str = ""
|