markdownizer 0.0.1__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.
- markdownizer-0.0.1/.editorconfig +11 -0
- markdownizer-0.0.1/.github/workflows/build.yml +65 -0
- markdownizer-0.0.1/.github/workflows/documentation.yml +56 -0
- markdownizer-0.0.1/.gitignore +111 -0
- markdownizer-0.0.1/.pre-commit-config.yaml +53 -0
- markdownizer-0.0.1/LICENSE +22 -0
- markdownizer-0.0.1/PKG-INFO +85 -0
- markdownizer-0.0.1/README.md +73 -0
- markdownizer-0.0.1/__linkreplacer/__init__.py +3 -0
- markdownizer-0.0.1/__linkreplacer/linkreplacer.py +73 -0
- markdownizer-0.0.1/docs/SUMMARY.md +1 -0
- markdownizer-0.0.1/docs/gen_pages.py +31 -0
- markdownizer-0.0.1/docs/index.md +1 -0
- markdownizer-0.0.1/docs/markdownizer/Admonition.md +21 -0
- markdownizer-0.0.1/docs/markdownizer/BaseSection.md +29 -0
- markdownizer-0.0.1/docs/markdownizer/BinaryImage.md +21 -0
- markdownizer-0.0.1/docs/markdownizer/ClassDocument.md +21 -0
- markdownizer-0.0.1/docs/markdownizer/Code.md +29 -0
- markdownizer-0.0.1/docs/markdownizer/DocStrings.md +21 -0
- markdownizer-0.0.1/docs/markdownizer/Docs.md +21 -0
- markdownizer-0.0.1/docs/markdownizer/Document.md +27 -0
- markdownizer-0.0.1/docs/markdownizer/Image.md +26 -0
- markdownizer-0.0.1/docs/markdownizer/List.md +19 -0
- markdownizer-0.0.1/docs/markdownizer/MermaidDiagram.md +23 -0
- markdownizer-0.0.1/docs/markdownizer/ModuleDocument.md +21 -0
- markdownizer-0.0.1/docs/markdownizer/Nav.md +26 -0
- markdownizer-0.0.1/docs/markdownizer/SUMMARY.md +16 -0
- markdownizer-0.0.1/docs/markdownizer/Table.md +19 -0
- markdownizer-0.0.1/docs/markdownizer/Text.md +28 -0
- markdownizer-0.0.1/markdownizer/__init__.py +178 -0
- markdownizer-0.0.1/markdownizer/admonition.py +61 -0
- markdownizer-0.0.1/markdownizer/basesection.py +90 -0
- markdownizer-0.0.1/markdownizer/classhelpers.py +219 -0
- markdownizer-0.0.1/markdownizer/docs.py +98 -0
- markdownizer-0.0.1/markdownizer/docstrings.py +172 -0
- markdownizer-0.0.1/markdownizer/document.py +171 -0
- markdownizer-0.0.1/markdownizer/image.py +43 -0
- markdownizer-0.0.1/markdownizer/list.py +46 -0
- markdownizer-0.0.1/markdownizer/mermaid.py +111 -0
- markdownizer-0.0.1/markdownizer/mermaiddiagram.py +115 -0
- markdownizer-0.0.1/markdownizer/nav.py +135 -0
- markdownizer-0.0.1/markdownizer/node.py +564 -0
- markdownizer-0.0.1/markdownizer/table.py +152 -0
- markdownizer-0.0.1/markdownizer/utils.py +139 -0
- markdownizer-0.0.1/mkdocs.yml +129 -0
- markdownizer-0.0.1/pyproject.toml +226 -0
- markdownizer-0.0.1/tests/__init__.py +0 -0
- markdownizer-0.0.1/tests/conftest.py +0 -0
- markdownizer-0.0.1/tests/test_add.py +15 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
strategy:
|
|
10
|
+
matrix:
|
|
11
|
+
python_version: ['3.10', '3.11']
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
- name: Set up Python
|
|
16
|
+
uses: actions/setup-python@v4
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python_version }}
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install --upgrade pip
|
|
22
|
+
pip install hatch
|
|
23
|
+
hatch env create
|
|
24
|
+
- name: Lint and typecheck
|
|
25
|
+
run: |
|
|
26
|
+
hatch run lint-check
|
|
27
|
+
- name: Test
|
|
28
|
+
run: |
|
|
29
|
+
hatch run test-cov-xml
|
|
30
|
+
- uses: codecov/codecov-action@v3
|
|
31
|
+
with:
|
|
32
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
33
|
+
fail_ci_if_error: true
|
|
34
|
+
verbose: true
|
|
35
|
+
|
|
36
|
+
release:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
needs: test
|
|
39
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
40
|
+
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v3
|
|
43
|
+
- name: Set up Python
|
|
44
|
+
uses: actions/setup-python@v4
|
|
45
|
+
with:
|
|
46
|
+
python-version: '3.11'
|
|
47
|
+
- name: Install dependencies
|
|
48
|
+
shell: bash
|
|
49
|
+
run: |
|
|
50
|
+
python -m pip install --upgrade pip
|
|
51
|
+
pip install hatch
|
|
52
|
+
- name: Build and publish on PyPI
|
|
53
|
+
env:
|
|
54
|
+
HATCH_INDEX_USER: ${{ secrets.HATCH_INDEX_USER }}
|
|
55
|
+
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }}
|
|
56
|
+
run: |
|
|
57
|
+
hatch build
|
|
58
|
+
hatch publish
|
|
59
|
+
- name: Create release
|
|
60
|
+
uses: ncipollo/release-action@v1
|
|
61
|
+
with:
|
|
62
|
+
draft: true
|
|
63
|
+
body: ${{ github.event.head_commit.message }}
|
|
64
|
+
artifacts: dist/*.whl,dist/*.tar.gz
|
|
65
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v3
|
|
31
|
+
- name: Set up Python
|
|
32
|
+
uses: actions/setup-python@v4
|
|
33
|
+
with:
|
|
34
|
+
python-version: '3.11'
|
|
35
|
+
- name: Install dependencies
|
|
36
|
+
run: |
|
|
37
|
+
python -m pip install --upgrade pip
|
|
38
|
+
pip install hatch
|
|
39
|
+
hatch env create
|
|
40
|
+
- name: Build
|
|
41
|
+
run: hatch run docs-build
|
|
42
|
+
- name: Upload artifact
|
|
43
|
+
uses: actions/upload-pages-artifact@v1
|
|
44
|
+
with:
|
|
45
|
+
path: ./site
|
|
46
|
+
|
|
47
|
+
deploy:
|
|
48
|
+
environment:
|
|
49
|
+
name: github-pages
|
|
50
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
needs: build
|
|
53
|
+
steps:
|
|
54
|
+
- name: Deploy to GitHub Pages
|
|
55
|
+
id: deployment
|
|
56
|
+
uses: actions/deploy-pages@v1
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
env/
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
|
|
28
|
+
# PyInstaller
|
|
29
|
+
# Usually these files are written by a python script from a template
|
|
30
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Installer logs
|
|
35
|
+
pip-log.txt
|
|
36
|
+
pip-delete-this-directory.txt
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
.hypothesis/
|
|
48
|
+
.pytest_cache/
|
|
49
|
+
junit/
|
|
50
|
+
junit.xml
|
|
51
|
+
test.db
|
|
52
|
+
|
|
53
|
+
# Translations
|
|
54
|
+
*.mo
|
|
55
|
+
*.pot
|
|
56
|
+
|
|
57
|
+
# Django stuff:
|
|
58
|
+
*.log
|
|
59
|
+
local_settings.py
|
|
60
|
+
|
|
61
|
+
# Flask stuff:
|
|
62
|
+
instance/
|
|
63
|
+
.webassets-cache
|
|
64
|
+
|
|
65
|
+
# Scrapy stuff:
|
|
66
|
+
.scrapy
|
|
67
|
+
|
|
68
|
+
# Sphinx documentation
|
|
69
|
+
docs/_build/
|
|
70
|
+
|
|
71
|
+
# PyBuilder
|
|
72
|
+
target/
|
|
73
|
+
|
|
74
|
+
# Jupyter Notebook
|
|
75
|
+
.ipynb_checkpoints
|
|
76
|
+
|
|
77
|
+
# pyenv
|
|
78
|
+
.python-version
|
|
79
|
+
|
|
80
|
+
# celery beat schedule file
|
|
81
|
+
celerybeat-schedule
|
|
82
|
+
|
|
83
|
+
# SageMath parsed files
|
|
84
|
+
*.sage.py
|
|
85
|
+
|
|
86
|
+
# dotenv
|
|
87
|
+
.env
|
|
88
|
+
|
|
89
|
+
# virtualenv
|
|
90
|
+
.venv
|
|
91
|
+
venv/
|
|
92
|
+
ENV/
|
|
93
|
+
|
|
94
|
+
# Spyder project settings
|
|
95
|
+
.spyderproject
|
|
96
|
+
.spyproject
|
|
97
|
+
|
|
98
|
+
# Rope project settings
|
|
99
|
+
.ropeproject
|
|
100
|
+
|
|
101
|
+
# mkdocs documentation
|
|
102
|
+
/site
|
|
103
|
+
|
|
104
|
+
# mypy
|
|
105
|
+
.mypy_cache/
|
|
106
|
+
|
|
107
|
+
# .vscode
|
|
108
|
+
.vscode/
|
|
109
|
+
|
|
110
|
+
# OS files
|
|
111
|
+
.DS_Store
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
default_language_version:
|
|
2
|
+
python: python3.10
|
|
3
|
+
default_stages: [commit]
|
|
4
|
+
repos:
|
|
5
|
+
- repo: local
|
|
6
|
+
hooks:
|
|
7
|
+
- id: pytest-check
|
|
8
|
+
name: pytest-check
|
|
9
|
+
entry: poetry run pytest
|
|
10
|
+
language: system
|
|
11
|
+
# stages: [push]
|
|
12
|
+
types: [python]
|
|
13
|
+
pass_filenames: false
|
|
14
|
+
always_run: true
|
|
15
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
16
|
+
rev: v4.4.0
|
|
17
|
+
hooks:
|
|
18
|
+
# - id: trailing-whitespace
|
|
19
|
+
# - id: check-ast
|
|
20
|
+
- id: check-case-conflict
|
|
21
|
+
- id: check-docstring-first
|
|
22
|
+
- id: check-merge-conflict
|
|
23
|
+
# - id: check-yaml
|
|
24
|
+
- id: check-toml
|
|
25
|
+
- id: check-json
|
|
26
|
+
- id: detect-private-key
|
|
27
|
+
- id: forbid-new-submodules
|
|
28
|
+
# - id: check-added-large-files
|
|
29
|
+
# https://pre-commit.com/hooks.html
|
|
30
|
+
- repo: https://github.com/commitizen-tools/commitizen
|
|
31
|
+
rev: 3.5.2
|
|
32
|
+
hooks:
|
|
33
|
+
- id: commitizen
|
|
34
|
+
stages: [commit-msg]
|
|
35
|
+
additional_dependencies: [typing-extensions] # cz-github-convention]
|
|
36
|
+
- repo: https://github.com/ambv/black
|
|
37
|
+
rev: 23.7.0
|
|
38
|
+
hooks:
|
|
39
|
+
- id: black
|
|
40
|
+
args: [--preview]
|
|
41
|
+
|
|
42
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
43
|
+
rev: v1.4.1
|
|
44
|
+
hooks:
|
|
45
|
+
- id: mypy
|
|
46
|
+
# args: [--ignore-missing-imports]
|
|
47
|
+
additional_dependencies: [pyside6, types-Deprecated, types-docutils, types-orjson, types-toml, types-typed-ast, types-requests, types-python-dateutil]
|
|
48
|
+
exclude: '(sciscintilla)\.py'
|
|
49
|
+
|
|
50
|
+
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
51
|
+
rev: v0.0.278
|
|
52
|
+
hooks:
|
|
53
|
+
- id: ruff
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, Philipp Temminghoff
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: markdownizer
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Generate docs with ease.
|
|
5
|
+
Project-URL: Documentation, https://phil65.github.io/markdownizer/
|
|
6
|
+
Project-URL: Source, https://github.com/phil65/markdownizer
|
|
7
|
+
Author-email: markdownizer <philipptemminghoff@gmail.com>
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# Markdownizer
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<em>Generate docs with ease.</em>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
[](https://github.com/phil65/markdownizer/actions)
|
|
20
|
+
[](https://codecov.io/gh/phil65/markdownizer)
|
|
21
|
+
[](https://badge.fury.io/py/markdownizer)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
**Documentation**: <a href="https://phil65.github.io/markdownizer/" target="_blank">https://phil65.github.io/markdownizer/</a>
|
|
26
|
+
|
|
27
|
+
**Source Code**: <a href="https://github.com/phil65/markdownizer" target="_blank">https://github.com/phil65/markdownizer</a>
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Development
|
|
32
|
+
|
|
33
|
+
### Setup environment
|
|
34
|
+
|
|
35
|
+
We use [Hatch](https://hatch.pypa.io/latest/install/) to manage the development environment and production build. Ensure it's installed on your system.
|
|
36
|
+
|
|
37
|
+
### Run unit tests
|
|
38
|
+
|
|
39
|
+
You can run all the tests with:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
hatch run test
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Format the code
|
|
46
|
+
|
|
47
|
+
Execute the following command to apply linting and check typing:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
hatch run lint
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Publish a new version
|
|
54
|
+
|
|
55
|
+
You can bump the version, create a commit and associated tag with one command:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
hatch version patch
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
hatch version minor
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
hatch version major
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Your default Git text editor will open so you can add information about the release.
|
|
70
|
+
|
|
71
|
+
When you push the tag on GitHub, the workflow will automatically publish it on PyPi and a GitHub release will be created as draft.
|
|
72
|
+
|
|
73
|
+
## Serve the documentation
|
|
74
|
+
|
|
75
|
+
You can serve the Mkdocs documentation with:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
hatch run docs-serve
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
It'll automatically watch for changes in your code.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
This project is licensed under the terms of the MIT license.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Markdownizer
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<em>Generate docs with ease.</em>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
[](https://github.com/phil65/markdownizer/actions)
|
|
8
|
+
[](https://codecov.io/gh/phil65/markdownizer)
|
|
9
|
+
[](https://badge.fury.io/py/markdownizer)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
**Documentation**: <a href="https://phil65.github.io/markdownizer/" target="_blank">https://phil65.github.io/markdownizer/</a>
|
|
14
|
+
|
|
15
|
+
**Source Code**: <a href="https://github.com/phil65/markdownizer" target="_blank">https://github.com/phil65/markdownizer</a>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Development
|
|
20
|
+
|
|
21
|
+
### Setup environment
|
|
22
|
+
|
|
23
|
+
We use [Hatch](https://hatch.pypa.io/latest/install/) to manage the development environment and production build. Ensure it's installed on your system.
|
|
24
|
+
|
|
25
|
+
### Run unit tests
|
|
26
|
+
|
|
27
|
+
You can run all the tests with:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
hatch run test
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Format the code
|
|
34
|
+
|
|
35
|
+
Execute the following command to apply linting and check typing:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
hatch run lint
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Publish a new version
|
|
42
|
+
|
|
43
|
+
You can bump the version, create a commit and associated tag with one command:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
hatch version patch
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
hatch version minor
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
hatch version major
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Your default Git text editor will open so you can add information about the release.
|
|
58
|
+
|
|
59
|
+
When you push the tag on GitHub, the workflow will automatically publish it on PyPi and a GitHub release will be created as draft.
|
|
60
|
+
|
|
61
|
+
## Serve the documentation
|
|
62
|
+
|
|
63
|
+
You can serve the Mkdocs documentation with:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
hatch run docs-serve
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
It'll automatically watch for changes in your code.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
This project is licensed under the terms of the MIT license.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import collections
|
|
4
|
+
import logging
|
|
5
|
+
import os
|
|
6
|
+
import pathlib
|
|
7
|
+
import re
|
|
8
|
+
import urllib.parse
|
|
9
|
+
|
|
10
|
+
from mkdocs.plugins import BasePlugin
|
|
11
|
+
import mkdocs.utils
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(f"mkdocs.plugins.{__name__}")
|
|
15
|
+
logger.addFilter(mkdocs.utils.warning_filter)
|
|
16
|
+
|
|
17
|
+
# For Regex, match groups are:
|
|
18
|
+
# 0: Whole markdown link e.g. [Alt-text](url)
|
|
19
|
+
# 1: Alt text
|
|
20
|
+
# 2: Full URL e.g. url + hash anchor
|
|
21
|
+
# 3: Filename e.g. filename.md
|
|
22
|
+
# 4: File extension e.g. .md, .png, etc.
|
|
23
|
+
# 5. hash anchor e.g. #my-sub-heading-link
|
|
24
|
+
AUTOLINK_RE = r"\[([^\]]+)\]\((([^)/]+\.(md|png|jpg))(#.*)*)\)"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class AutoLinkReplacerPlugin:
|
|
28
|
+
def __init__(self, base_docs_url, page_url, mapping):
|
|
29
|
+
self.mapping = mapping
|
|
30
|
+
self.page_url = page_url
|
|
31
|
+
self.base_docs_url = pathlib.Path(base_docs_url)
|
|
32
|
+
# Absolute URL of the linker
|
|
33
|
+
self.linker_url = os.path.dirname(self.base_docs_url / page_url) # noqa: PTH120
|
|
34
|
+
|
|
35
|
+
def __call__(self, match):
|
|
36
|
+
# Name of the markdown file
|
|
37
|
+
filename = urllib.parse.unquote(match.group(3).strip())
|
|
38
|
+
if filename not in self.mapping:
|
|
39
|
+
return f"`{match.group(3).replace('.md', '')}`"
|
|
40
|
+
filenames = self.mapping[filename]
|
|
41
|
+
if len(filenames) > 1:
|
|
42
|
+
logger.warning(
|
|
43
|
+
f"{self.page_url}: {match.group(3)} has multiple targets: {filenames}"
|
|
44
|
+
)
|
|
45
|
+
abs_link_url = (self.base_docs_url / self.mapping[filename][0]).parent
|
|
46
|
+
# need os.replath here bc pathlib.relative_to throws an exception
|
|
47
|
+
# when linking across drives
|
|
48
|
+
rel_path = os.path.relpath(abs_link_url, self.linker_url)
|
|
49
|
+
# html_filename = filename.replace(".md", ".html")
|
|
50
|
+
rel_link_url = os.path.join(rel_path, filename) # noqa: PTH118
|
|
51
|
+
new_text = (
|
|
52
|
+
match.group(0).replace(match.group(2), rel_link_url)
|
|
53
|
+
if match.group(5) is None
|
|
54
|
+
else match.group(0).replace(match.group(2), rel_link_url + match.group(5))
|
|
55
|
+
)
|
|
56
|
+
new_text = new_text.replace("\\", "/")
|
|
57
|
+
logger.debug(
|
|
58
|
+
f"LinkReplacer: {self.page_url}: {match.group(3)=} -> {rel_link_url=}"
|
|
59
|
+
)
|
|
60
|
+
return new_text
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class LinkReplacerPlugin(BasePlugin):
|
|
64
|
+
def on_page_markdown(self, markdown, page, config, files, **kwargs):
|
|
65
|
+
base_docs_url = config["docs_dir"]
|
|
66
|
+
page_url = page.file.src_path
|
|
67
|
+
mapping = collections.defaultdict(list)
|
|
68
|
+
for file_ in files:
|
|
69
|
+
filename = os.path.basename(file_.abs_src_path) # noqa: PTH119
|
|
70
|
+
mapping[filename].append(file_.url)
|
|
71
|
+
plugin = AutoLinkReplacerPlugin(base_docs_url, page_url, mapping)
|
|
72
|
+
markdown = re.sub(AUTOLINK_RE, plugin, markdown)
|
|
73
|
+
return markdown
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* [markdownizer](SUMMARY.md)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Generate the code reference pages and navigation."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
import markdownizer
|
|
10
|
+
import mkdocs
|
|
11
|
+
from markdownizer import classhelpers
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
|
|
16
|
+
|
|
17
|
+
docs = markdownizer.Docs(module=markdownizer)
|
|
18
|
+
nav = docs.create_nav(section="markdownizer")
|
|
19
|
+
# na2 = docs.create_nav(section="test")
|
|
20
|
+
|
|
21
|
+
nav[("overview",)] = "index.md"
|
|
22
|
+
# na2[("overview",)] = "index.md"
|
|
23
|
+
|
|
24
|
+
for klass in docs.iter_classes_for_module("markdownizer"):
|
|
25
|
+
nav.add_class_page(klass=klass, path=f"{klass.__name__}.md")
|
|
26
|
+
|
|
27
|
+
# nav.pretty_print()
|
|
28
|
+
print(str(docs))
|
|
29
|
+
|
|
30
|
+
# nav.write()
|
|
31
|
+
docs.write()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--8<-- "README.md"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## DocStrings
|
|
2
|
+
|
|
3
|
+
::: markdownizer..Admonition
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Inheritance diagram
|
|
9
|
+
|
|
10
|
+
```mermaid
|
|
11
|
+
graph TD
|
|
12
|
+
object
|
|
13
|
+
BaseNode
|
|
14
|
+
BaseSection
|
|
15
|
+
Text
|
|
16
|
+
Admonition
|
|
17
|
+
BaseNode --> BaseSection
|
|
18
|
+
Text --> Admonition
|
|
19
|
+
BaseSection --> Text
|
|
20
|
+
object --> BaseNode
|
|
21
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
## DocStrings
|
|
2
|
+
|
|
3
|
+
::: markdownizer..BaseSection
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Child classes
|
|
9
|
+
|
|
10
|
+
|Class|Module|Description|
|
|
11
|
+
|--|----|--|
|
|
12
|
+
|[Text](Text.md)|markdownizer.basesection|Class for any Markup text.|
|
|
13
|
+
|[Document](Document.md)|markdownizer.document||
|
|
14
|
+
|[Image](Image.md)|markdownizer.image||
|
|
15
|
+
|[List](List.md)|markdownizer.list||
|
|
16
|
+
|[Table](Table.md)|markdownizer.table||
|
|
17
|
+
|[Nav](Nav.md)|markdownizer.nav||
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Inheritance diagram
|
|
21
|
+
|
|
22
|
+
```mermaid
|
|
23
|
+
graph TD
|
|
24
|
+
BaseSection
|
|
25
|
+
BaseNode
|
|
26
|
+
object
|
|
27
|
+
BaseNode --> BaseSection
|
|
28
|
+
object --> BaseNode
|
|
29
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## DocStrings
|
|
2
|
+
|
|
3
|
+
::: markdownizer..BinaryImage
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Inheritance diagram
|
|
9
|
+
|
|
10
|
+
```mermaid
|
|
11
|
+
graph TD
|
|
12
|
+
object
|
|
13
|
+
BinaryImage
|
|
14
|
+
BaseNode
|
|
15
|
+
BaseSection
|
|
16
|
+
Image
|
|
17
|
+
BaseNode --> BaseSection
|
|
18
|
+
Image --> BinaryImage
|
|
19
|
+
BaseSection --> Image
|
|
20
|
+
object --> BaseNode
|
|
21
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## DocStrings
|
|
2
|
+
|
|
3
|
+
::: markdownizer..ClassDocument
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Inheritance diagram
|
|
9
|
+
|
|
10
|
+
```mermaid
|
|
11
|
+
graph TD
|
|
12
|
+
ClassDocument
|
|
13
|
+
object
|
|
14
|
+
Document
|
|
15
|
+
BaseNode
|
|
16
|
+
BaseSection
|
|
17
|
+
BaseNode --> BaseSection
|
|
18
|
+
BaseSection --> Document
|
|
19
|
+
Document --> ClassDocument
|
|
20
|
+
object --> BaseNode
|
|
21
|
+
```
|