mkdocs-treeblocks 0.1.0__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_treeblocks-0.1.0/.gitignore +37 -0
- mkdocs_treeblocks-0.1.0/CHANGELOG.md +58 -0
- mkdocs_treeblocks-0.1.0/LICENSE.md +21 -0
- mkdocs_treeblocks-0.1.0/PKG-INFO +241 -0
- mkdocs_treeblocks-0.1.0/README.md +193 -0
- mkdocs_treeblocks-0.1.0/docs/development.md +189 -0
- mkdocs_treeblocks-0.1.0/pyproject.toml +50 -0
- mkdocs_treeblocks-0.1.0/src/mkdocs_treeblocks/__init__.py +1 -0
- mkdocs_treeblocks-0.1.0/src/mkdocs_treeblocks/parser.py +101 -0
- mkdocs_treeblocks-0.1.0/src/mkdocs_treeblocks/plugin.py +30 -0
- mkdocs_treeblocks-0.1.0/src/mkdocs_treeblocks/renderer.py +38 -0
- mkdocs_treeblocks-0.1.0/src/mkdocs_treeblocks/transform.py +54 -0
- mkdocs_treeblocks-0.1.0/tests/fixtures/mkdocs_basic/docs/index.md +25 -0
- mkdocs_treeblocks-0.1.0/tests/fixtures/mkdocs_basic/mkdocs.yml +4 -0
- mkdocs_treeblocks-0.1.0/tests/fixtures/mkdocs_material/docs/index.md +25 -0
- mkdocs_treeblocks-0.1.0/tests/fixtures/mkdocs_material/mkdocs.yml +7 -0
- mkdocs_treeblocks-0.1.0/tests/test_mkdocs_plugin.py +117 -0
- mkdocs_treeblocks-0.1.0/tests/test_parser.py +82 -0
- mkdocs_treeblocks-0.1.0/tests/test_placeholder.py +2 -0
- mkdocs_treeblocks-0.1.0/tests/test_renderer.py +56 -0
- mkdocs_treeblocks-0.1.0/tests/test_transform.py +141 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Python bytecode / caches
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
.mypy_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
|
|
8
|
+
# Virtual environments
|
|
9
|
+
.venv/
|
|
10
|
+
venv/
|
|
11
|
+
env/
|
|
12
|
+
|
|
13
|
+
# Build / packaging output
|
|
14
|
+
build/
|
|
15
|
+
dist/
|
|
16
|
+
*.egg-info/
|
|
17
|
+
|
|
18
|
+
# Coverage
|
|
19
|
+
.coverage
|
|
20
|
+
htmlcov/
|
|
21
|
+
|
|
22
|
+
# MkDocs output
|
|
23
|
+
site/
|
|
24
|
+
|
|
25
|
+
# OS/editor files
|
|
26
|
+
.DS_Store
|
|
27
|
+
.vscode/
|
|
28
|
+
.idea/
|
|
29
|
+
._.DS_Store
|
|
30
|
+
|
|
31
|
+
# Test and local output artifacts
|
|
32
|
+
*.log
|
|
33
|
+
pytest.txt
|
|
34
|
+
|
|
35
|
+
# Test and local output artifacts
|
|
36
|
+
*.log
|
|
37
|
+
pytest.txt
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# mkdocs-treeblocks 0.1.0
|
|
2
|
+
|
|
3
|
+
## Initial alpha release of mkdocs-treeblocks.
|
|
4
|
+
|
|
5
|
+
mkdocs-treeblocks is a MkDocs extension for rendering simple tree-style code blocks as directory/file tree output during a MkDocs build.
|
|
6
|
+
|
|
7
|
+
Added
|
|
8
|
+
|
|
9
|
+
* Added support for fenced ` ```tree` code blocks in Markdown.
|
|
10
|
+
* Added parser support for indentation-based tree input.
|
|
11
|
+
* Added Unicode tree rendering using branch characters such as ├── and └──.
|
|
12
|
+
* Added Markdown transformation that converts source tree fences into rendered text fences.
|
|
13
|
+
* Added MkDocs plugin integration through the treeblocks plugin entry point.
|
|
14
|
+
* Added build-time diagnostics for invalid tree indentation.
|
|
15
|
+
* Added diagnostics that report the source Markdown file and starting line of the failing tree block.
|
|
16
|
+
* Added compatibility test coverage for both basic MkDocs and Material for MkDocs projects.
|
|
17
|
+
* Added package metadata for local wheel and source distribution builds.
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
### Example Usage
|
|
21
|
+
|
|
22
|
+
_Source Markdown:_
|
|
23
|
+
|
|
24
|
+
```tree
|
|
25
|
+
docs
|
|
26
|
+
index.md
|
|
27
|
+
guides
|
|
28
|
+
install.md
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
_Rendered output:_
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
docs
|
|
35
|
+
├── index.md
|
|
36
|
+
└── guides
|
|
37
|
+
└── install.md
|
|
38
|
+
```
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
`pip install mkdocs-treeblocks`
|
|
44
|
+
|
|
45
|
+
Enable the plugin in mkdocs.yml:
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
plugins:
|
|
49
|
+
- search
|
|
50
|
+
- treeblocks
|
|
51
|
+
```
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### Current limitations
|
|
55
|
+
|
|
56
|
+
* Tree blocks currently use four-space or single tab indentation levels.
|
|
57
|
+
* Error diagnostics report the source file and tree-block starting line, but not yet the exact malformed line inside the tree block.
|
|
58
|
+
* This is an early alpha release, so syntax and behavior may still change before a stable 1.0.0 release.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2026] [Joshua Mullenberg]
|
|
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 WITHOUT LIMITATION 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.
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mkdocs-treeblocks
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A MkDocs extension for rendering tree-style code blocks and directory structures.
|
|
5
|
+
Author: Joshua Mullenberg
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) [2026] [Joshua Mullenberg]
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
License-File: LICENSE.md
|
|
28
|
+
Keywords: directory-structure,documentation,markdown,mkdocs,tree
|
|
29
|
+
Classifier: Development Status :: 3 - Alpha
|
|
30
|
+
Classifier: Framework :: MkDocs
|
|
31
|
+
Classifier: Intended Audience :: Developers
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
37
|
+
Classifier: Topic :: Documentation
|
|
38
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
39
|
+
Requires-Python: >=3.10
|
|
40
|
+
Requires-Dist: markdown>=3.6
|
|
41
|
+
Requires-Dist: mkdocs>=1.6
|
|
42
|
+
Provides-Extra: dev
|
|
43
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
44
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'dev'
|
|
45
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
46
|
+
Requires-Dist: twine>=5.0; extra == 'dev'
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
|
|
49
|
+
# mkdocs-treeblocks
|
|
50
|
+
_Revised on: 06-13-2026 by: Joshua Mullenberg_
|
|
51
|
+
|
|
52
|
+
`mkdocs-treeblocks` is a MkDocs plugin for rendering readable tree-style blocks in documentation.
|
|
53
|
+
|
|
54
|
+
The goal is to make directory structures, file trees, project layouts, and related hierarchy examples easier to write, read, and maintain in MkDocs documentation.
|
|
55
|
+
|
|
56
|
+
> [!NOTE]
|
|
57
|
+
> This project is currently in development. Syntax, behavior, and package interfaces are still subject to change.
|
|
58
|
+
|
|
59
|
+
## Initial purpose
|
|
60
|
+
|
|
61
|
+
This project grew from a need to create clean, text-based tree-style blocks directly in documentation using simple Markdown syntax.
|
|
62
|
+
|
|
63
|
+
The goal is to avoid switching to a separate app, copying output from a web tool, manually inserting Unicode tree characters, or wrestling with tree command filters just to produce a curated directory structure for documentation.
|
|
64
|
+
|
|
65
|
+
mkdocs-treeblocks provides a small, predictable syntax that renders tree structures consistently in MkDocs sites.
|
|
66
|
+
|
|
67
|
+
## Syntax
|
|
68
|
+
|
|
69
|
+
Tree blocks are written as fenced Markdown code blocks. Use three backticks (` ``` `) to open and close the block, with `tree` as the language identifier.
|
|
70
|
+
|
|
71
|
+
The plugin converts the indentation into a tree structure, and then formats that structure into a fenced text-block using Unicode tree connectors.
|
|
72
|
+
|
|
73
|
+
Indentation may use either four spaces or one tab per level, but cannot use both indentation styles within the same tree block. Text and spacing after the structural indentation are preserved, allowing filenames, comments, and annotations to remain aligned.
|
|
74
|
+
|
|
75
|
+
Only one root node is allowed per tree block.
|
|
76
|
+
|
|
77
|
+
<table>
|
|
78
|
+
<tr>
|
|
79
|
+
<th>Syntax by example</th>
|
|
80
|
+
<th>Rendered output</th>
|
|
81
|
+
</tr>
|
|
82
|
+
<tr>
|
|
83
|
+
<td>
|
|
84
|
+
<pre><code>
|
|
85
|
+
```tree
|
|
86
|
+
mkdocs-project/
|
|
87
|
+
docs/
|
|
88
|
+
index.md
|
|
89
|
+
...
|
|
90
|
+
mkdocs.yml # mkdocs config
|
|
91
|
+
README.md
|
|
92
|
+
requirements.txt # dependencies
|
|
93
|
+
site/
|
|
94
|
+
404.html
|
|
95
|
+
assets/
|
|
96
|
+
index.html
|
|
97
|
+
...
|
|
98
|
+
```
|
|
99
|
+
</code></pre>
|
|
100
|
+
</td>
|
|
101
|
+
<td>
|
|
102
|
+
<pre><code>
|
|
103
|
+
```text
|
|
104
|
+
mkdocs-project/
|
|
105
|
+
├── docs/
|
|
106
|
+
│ ├── index.md
|
|
107
|
+
│ └── ...
|
|
108
|
+
├── mkdocs.yml # mkdocs config
|
|
109
|
+
├── README.md
|
|
110
|
+
├── requirements.txt # dependencies
|
|
111
|
+
└── site/
|
|
112
|
+
├── 404.html
|
|
113
|
+
├── assets/
|
|
114
|
+
├── index.html
|
|
115
|
+
└── ...
|
|
116
|
+
```
|
|
117
|
+
</code></pre>
|
|
118
|
+
</td>
|
|
119
|
+
</tr>
|
|
120
|
+
</table>
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Installation, testing, and usage
|
|
125
|
+
|
|
126
|
+
Clone the repository, create and activate a virtual environment, then install the project in editable mode with its development dependencies:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
python3 -m venv .venv
|
|
130
|
+
source .venv/bin/activate
|
|
131
|
+
python -m pip install --upgrade pip
|
|
132
|
+
python -m pip install -e ".[dev]"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The editable install registers the treeblocks plugin with MkDocs and allows local source changes to take effect without reinstalling the package.
|
|
136
|
+
|
|
137
|
+
Run the test suite:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
python -m pytest
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Enable the plugin in mkdocs.yml:
|
|
144
|
+
|
|
145
|
+
```yaml
|
|
146
|
+
plugins:
|
|
147
|
+
- treeblocks
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Then write a fenced tree block in a Markdown page:
|
|
151
|
+
|
|
152
|
+
````
|
|
153
|
+
```tree
|
|
154
|
+
docs/
|
|
155
|
+
index.md
|
|
156
|
+
guides/
|
|
157
|
+
install.md
|
|
158
|
+
```
|
|
159
|
+
````
|
|
160
|
+
|
|
161
|
+
During the MkDocs build, the plugin transforms the source into a fenced text block containing the rendered tree.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
## Current implementation status
|
|
165
|
+
|
|
166
|
+
Implemented:
|
|
167
|
+
|
|
168
|
+
- Parse indented text into a tree structure with `parse_tree()`.
|
|
169
|
+
- Render a parsed tree as plain text with `render_tree()`.
|
|
170
|
+
- Use Unicode tree connectors such as `├──`, `└──`, and `│`.
|
|
171
|
+
- Preserve original node text, including aligned comments and annotations.
|
|
172
|
+
- Transform fenced Markdown `tree` blocks into rendered fenced `text` blocks with `transform_markdown()`.
|
|
173
|
+
- Leave non-`tree` fenced code blocks unchanged.
|
|
174
|
+
- Integrate with MkDocs through the `treeblocks` plugin.
|
|
175
|
+
- Raise MkDocs `PluginError` for invalid tree blocks.
|
|
176
|
+
- Include the source file and tree-block starting line in MkDocs parse errors when page context is available.
|
|
177
|
+
- Test parser, renderer, Markdown transformer, MkDocs plugin behavior, and Material for MkDocs compatibility with `pytest`.
|
|
178
|
+
- Material for Mkdocs compatibility testing.
|
|
179
|
+
|
|
180
|
+
Potential future enhancements:
|
|
181
|
+
|
|
182
|
+
- Error messages include exact malformed line inside the tree block.
|
|
183
|
+
- Custom HTML rendering.
|
|
184
|
+
- Dedicated CSS styling.
|
|
185
|
+
- Optional automatic directory slash handling.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
## Project Roadmap
|
|
189
|
+
|
|
190
|
+
#### <s>Phase 1: Scaffold and concept</s>
|
|
191
|
+
- <s>Create the project</s>
|
|
192
|
+
- <s>Set up the GitHub repository</s>
|
|
193
|
+
- <s>Document the purpose and syntax</s>
|
|
194
|
+
- <s>Add placeholder tests</s>
|
|
195
|
+
- <s>Create the initial README</s>
|
|
196
|
+
- <s>Make the first commit</s>
|
|
197
|
+
|
|
198
|
+
#### <s>Phase 2: Parser MVP</s>
|
|
199
|
+
- <s>Choose the first supported syntax</s>
|
|
200
|
+
- <s>Parse a small indented tree</s>
|
|
201
|
+
- <s>Add parser tests</s>
|
|
202
|
+
- <s>Add incremental documentation in /docs/</s>
|
|
203
|
+
|
|
204
|
+
#### <s>Phase 3: Renderer MVP</s>
|
|
205
|
+
- <s>Define renderer MVP behavior</s>
|
|
206
|
+
- <s>Add renderer tests</s>
|
|
207
|
+
- <s>Implement a plain Python renderer</s>
|
|
208
|
+
- <s>Document renderer behavior</s>
|
|
209
|
+
|
|
210
|
+
#### <s>Phase 4: Markdown transform MVP</s>
|
|
211
|
+
- <s>Choose fenced `tree` blocks as the first supported Markdown source syntax</s>
|
|
212
|
+
- <s>Detect and transform tree blocks in Markdown</s>
|
|
213
|
+
- <s>Replace transformed tree blocks with fenced `text` blocks</s>
|
|
214
|
+
- <s>Keep the transformer independent from MkDocs integration</s>
|
|
215
|
+
|
|
216
|
+
#### </s>Phase 5: MkDocs plugin MVP</s>
|
|
217
|
+
- <s>Add a minimal MkDocs plugin</s>
|
|
218
|
+
- <s>Register the plugin with MkDocs</s>
|
|
219
|
+
- <s>Add a minimal MkDocs fixture.</s>
|
|
220
|
+
- <s>Add MkDocs integration tests.</s>
|
|
221
|
+
- <s>Wrap parser failures as MkDocs `PluginError`</s>
|
|
222
|
+
|
|
223
|
+
#### <s>Phase 6: Error handling & testing</s>
|
|
224
|
+
- <s>Add source file and tree-block starting line diagnostics for parse errors.</s>
|
|
225
|
+
- <s>Test with Material for MkDocs.</s>
|
|
226
|
+
|
|
227
|
+
#### Phase 7: Publish initial release
|
|
228
|
+
- Finalize package metadata in `pyproject.toml`.
|
|
229
|
+
- Install build tooling and create distribution packages.
|
|
230
|
+
- Test the built wheel in a clean virtual environment
|
|
231
|
+
- Publish the release to PyPI
|
|
232
|
+
|
|
233
|
+
#### Phase 8: Documentation Polish
|
|
234
|
+
- Update current documentation.
|
|
235
|
+
- Verify documentation includes installation, usage, and examples.
|
|
236
|
+
- Document limitations and troubleshooting notes.
|
|
237
|
+
- Set up GitHub issue and feature-request tracking.
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# mkdocs-treeblocks
|
|
2
|
+
_Revised on: 06-13-2026 by: Joshua Mullenberg_
|
|
3
|
+
|
|
4
|
+
`mkdocs-treeblocks` is a MkDocs plugin for rendering readable tree-style blocks in documentation.
|
|
5
|
+
|
|
6
|
+
The goal is to make directory structures, file trees, project layouts, and related hierarchy examples easier to write, read, and maintain in MkDocs documentation.
|
|
7
|
+
|
|
8
|
+
> [!NOTE]
|
|
9
|
+
> This project is currently in development. Syntax, behavior, and package interfaces are still subject to change.
|
|
10
|
+
|
|
11
|
+
## Initial purpose
|
|
12
|
+
|
|
13
|
+
This project grew from a need to create clean, text-based tree-style blocks directly in documentation using simple Markdown syntax.
|
|
14
|
+
|
|
15
|
+
The goal is to avoid switching to a separate app, copying output from a web tool, manually inserting Unicode tree characters, or wrestling with tree command filters just to produce a curated directory structure for documentation.
|
|
16
|
+
|
|
17
|
+
mkdocs-treeblocks provides a small, predictable syntax that renders tree structures consistently in MkDocs sites.
|
|
18
|
+
|
|
19
|
+
## Syntax
|
|
20
|
+
|
|
21
|
+
Tree blocks are written as fenced Markdown code blocks. Use three backticks (` ``` `) to open and close the block, with `tree` as the language identifier.
|
|
22
|
+
|
|
23
|
+
The plugin converts the indentation into a tree structure, and then formats that structure into a fenced text-block using Unicode tree connectors.
|
|
24
|
+
|
|
25
|
+
Indentation may use either four spaces or one tab per level, but cannot use both indentation styles within the same tree block. Text and spacing after the structural indentation are preserved, allowing filenames, comments, and annotations to remain aligned.
|
|
26
|
+
|
|
27
|
+
Only one root node is allowed per tree block.
|
|
28
|
+
|
|
29
|
+
<table>
|
|
30
|
+
<tr>
|
|
31
|
+
<th>Syntax by example</th>
|
|
32
|
+
<th>Rendered output</th>
|
|
33
|
+
</tr>
|
|
34
|
+
<tr>
|
|
35
|
+
<td>
|
|
36
|
+
<pre><code>
|
|
37
|
+
```tree
|
|
38
|
+
mkdocs-project/
|
|
39
|
+
docs/
|
|
40
|
+
index.md
|
|
41
|
+
...
|
|
42
|
+
mkdocs.yml # mkdocs config
|
|
43
|
+
README.md
|
|
44
|
+
requirements.txt # dependencies
|
|
45
|
+
site/
|
|
46
|
+
404.html
|
|
47
|
+
assets/
|
|
48
|
+
index.html
|
|
49
|
+
...
|
|
50
|
+
```
|
|
51
|
+
</code></pre>
|
|
52
|
+
</td>
|
|
53
|
+
<td>
|
|
54
|
+
<pre><code>
|
|
55
|
+
```text
|
|
56
|
+
mkdocs-project/
|
|
57
|
+
├── docs/
|
|
58
|
+
│ ├── index.md
|
|
59
|
+
│ └── ...
|
|
60
|
+
├── mkdocs.yml # mkdocs config
|
|
61
|
+
├── README.md
|
|
62
|
+
├── requirements.txt # dependencies
|
|
63
|
+
└── site/
|
|
64
|
+
├── 404.html
|
|
65
|
+
├── assets/
|
|
66
|
+
├── index.html
|
|
67
|
+
└── ...
|
|
68
|
+
```
|
|
69
|
+
</code></pre>
|
|
70
|
+
</td>
|
|
71
|
+
</tr>
|
|
72
|
+
</table>
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Installation, testing, and usage
|
|
77
|
+
|
|
78
|
+
Clone the repository, create and activate a virtual environment, then install the project in editable mode with its development dependencies:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
python3 -m venv .venv
|
|
82
|
+
source .venv/bin/activate
|
|
83
|
+
python -m pip install --upgrade pip
|
|
84
|
+
python -m pip install -e ".[dev]"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The editable install registers the treeblocks plugin with MkDocs and allows local source changes to take effect without reinstalling the package.
|
|
88
|
+
|
|
89
|
+
Run the test suite:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
python -m pytest
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Enable the plugin in mkdocs.yml:
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
plugins:
|
|
99
|
+
- treeblocks
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Then write a fenced tree block in a Markdown page:
|
|
103
|
+
|
|
104
|
+
````
|
|
105
|
+
```tree
|
|
106
|
+
docs/
|
|
107
|
+
index.md
|
|
108
|
+
guides/
|
|
109
|
+
install.md
|
|
110
|
+
```
|
|
111
|
+
````
|
|
112
|
+
|
|
113
|
+
During the MkDocs build, the plugin transforms the source into a fenced text block containing the rendered tree.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
## Current implementation status
|
|
117
|
+
|
|
118
|
+
Implemented:
|
|
119
|
+
|
|
120
|
+
- Parse indented text into a tree structure with `parse_tree()`.
|
|
121
|
+
- Render a parsed tree as plain text with `render_tree()`.
|
|
122
|
+
- Use Unicode tree connectors such as `├──`, `└──`, and `│`.
|
|
123
|
+
- Preserve original node text, including aligned comments and annotations.
|
|
124
|
+
- Transform fenced Markdown `tree` blocks into rendered fenced `text` blocks with `transform_markdown()`.
|
|
125
|
+
- Leave non-`tree` fenced code blocks unchanged.
|
|
126
|
+
- Integrate with MkDocs through the `treeblocks` plugin.
|
|
127
|
+
- Raise MkDocs `PluginError` for invalid tree blocks.
|
|
128
|
+
- Include the source file and tree-block starting line in MkDocs parse errors when page context is available.
|
|
129
|
+
- Test parser, renderer, Markdown transformer, MkDocs plugin behavior, and Material for MkDocs compatibility with `pytest`.
|
|
130
|
+
- Material for Mkdocs compatibility testing.
|
|
131
|
+
|
|
132
|
+
Potential future enhancements:
|
|
133
|
+
|
|
134
|
+
- Error messages include exact malformed line inside the tree block.
|
|
135
|
+
- Custom HTML rendering.
|
|
136
|
+
- Dedicated CSS styling.
|
|
137
|
+
- Optional automatic directory slash handling.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
## Project Roadmap
|
|
141
|
+
|
|
142
|
+
#### <s>Phase 1: Scaffold and concept</s>
|
|
143
|
+
- <s>Create the project</s>
|
|
144
|
+
- <s>Set up the GitHub repository</s>
|
|
145
|
+
- <s>Document the purpose and syntax</s>
|
|
146
|
+
- <s>Add placeholder tests</s>
|
|
147
|
+
- <s>Create the initial README</s>
|
|
148
|
+
- <s>Make the first commit</s>
|
|
149
|
+
|
|
150
|
+
#### <s>Phase 2: Parser MVP</s>
|
|
151
|
+
- <s>Choose the first supported syntax</s>
|
|
152
|
+
- <s>Parse a small indented tree</s>
|
|
153
|
+
- <s>Add parser tests</s>
|
|
154
|
+
- <s>Add incremental documentation in /docs/</s>
|
|
155
|
+
|
|
156
|
+
#### <s>Phase 3: Renderer MVP</s>
|
|
157
|
+
- <s>Define renderer MVP behavior</s>
|
|
158
|
+
- <s>Add renderer tests</s>
|
|
159
|
+
- <s>Implement a plain Python renderer</s>
|
|
160
|
+
- <s>Document renderer behavior</s>
|
|
161
|
+
|
|
162
|
+
#### <s>Phase 4: Markdown transform MVP</s>
|
|
163
|
+
- <s>Choose fenced `tree` blocks as the first supported Markdown source syntax</s>
|
|
164
|
+
- <s>Detect and transform tree blocks in Markdown</s>
|
|
165
|
+
- <s>Replace transformed tree blocks with fenced `text` blocks</s>
|
|
166
|
+
- <s>Keep the transformer independent from MkDocs integration</s>
|
|
167
|
+
|
|
168
|
+
#### </s>Phase 5: MkDocs plugin MVP</s>
|
|
169
|
+
- <s>Add a minimal MkDocs plugin</s>
|
|
170
|
+
- <s>Register the plugin with MkDocs</s>
|
|
171
|
+
- <s>Add a minimal MkDocs fixture.</s>
|
|
172
|
+
- <s>Add MkDocs integration tests.</s>
|
|
173
|
+
- <s>Wrap parser failures as MkDocs `PluginError`</s>
|
|
174
|
+
|
|
175
|
+
#### <s>Phase 6: Error handling & testing</s>
|
|
176
|
+
- <s>Add source file and tree-block starting line diagnostics for parse errors.</s>
|
|
177
|
+
- <s>Test with Material for MkDocs.</s>
|
|
178
|
+
|
|
179
|
+
#### Phase 7: Publish initial release
|
|
180
|
+
- Finalize package metadata in `pyproject.toml`.
|
|
181
|
+
- Install build tooling and create distribution packages.
|
|
182
|
+
- Test the built wheel in a clean virtual environment
|
|
183
|
+
- Publish the release to PyPI
|
|
184
|
+
|
|
185
|
+
#### Phase 8: Documentation Polish
|
|
186
|
+
- Update current documentation.
|
|
187
|
+
- Verify documentation includes installation, usage, and examples.
|
|
188
|
+
- Document limitations and troubleshooting notes.
|
|
189
|
+
- Set up GitHub issue and feature-request tracking.
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|