Directory trees¶
prodockit.tree turns an indented list of folders and files into a directory
tree. Use it to show readers where files belong in a project.
Enable the extension¶
Add an empty extension table to zensical.toml when the defaults are suitable:
Write a tree¶
Write an indented file and folder list inside a tree block. The result tab
shows how the same source is presented to a reader.
/// tree
docs/ - the documentation source tree
index.md - the home page
stylesheets/ - style sheets for the website and PDF
pdk.css - managed website and PDF defaults
extra.css - project website and PDF changes
pdk-pdf.css - managed PDF defaults
print.css - project PDF changes
zensical.toml - project configuration
///
- docsthe documentation source tree
- index.mdthe home page
- stylesheetsstyle sheets for the website and PDF
- pdk.cssmanaged website and PDF defaults
- extra.cssproject website and PDF changes
- pdk-pdf.cssmanaged PDF defaults
- print.cssproject PDF changes
- zensical.tomlproject configuration
The complete block starts and ends with a three-slash fence. Its body follows three rules:
- Indentation is the structure. Two spaces per level by default.
- A trailing
/means a directory. Anything else is a file. Nothing else marks one, so nothing else can disagree with it. -starts a description, and it is optional. The spaces are required, which is what keepsharvard-cite-them-right.cslin one piece.
Configure indentation and icons¶
There are no additional prodockit.tree settings in zensical.toml.
Configure each tree inside its Markdown block. Put the options directly below
/// tree, indent them by at least four spaces, and leave a blank line before
the listing:
Table 25.1 shows the tree options for indentation and file or folder icons.
1. Configure indentation and icons
| Option | Default | What it does |
|---|---|---|
indent |
2 |
How many spaces one level costs. Set 4 for a listing written that way. |
directory_icon |
':lucide-folder:' |
Icon shortcode placed before every directory. |
file_icon |
':lucide-file:' |
Icon shortcode placed before every file. |
This example changes both the indentation and the icons:
Fix indentation errors¶
A listing is read for its shape, so an entry attached to the wrong parent is a diagram that is wrong and looks right. Rather than guess, the build stops:
TreeError: indent of 3 is not a multiple of 2: 'index.md'
TreeError: indented 2 levels at once: 'index.md'
A report project¶
Use the block for a structure readers need to understand. This example shows
the main files supplied by prodockit-template:
- docs
- index.mdcover page
- section1.mdfirst report section
- acronyms.mdacronym definitions
- glossary.mdglossary definitions
- references.mdgenerated reference list
- stylesheets
- pdk.cssmanaged website and PDF defaults
- extra.cssproject website and PDF changes
- pdk-pdf.cssmanaged PDF defaults
- print.cssproject PDF changes
- tools
- mermaiddiagram renderer
- mathjaxmaths renderer
- zensical.tomlnavigation and extension configuration
- references.bibbibliography source
The package's own source-code map now lives under Contributor internals.
Reference¶
Use Table 25.2 to look up the block syntax, options, and nesting markers.
2. Reference
| Syntax or option | Purpose |
|---|---|
/// tree |
Open or close a directory tree |
A trailing / |
Mark an entry as a directory |
- description |
Add an optional description |
indent: 4 |
Use four spaces for each level instead of two |
directory_icon: '…' |
Choose the directory icon |
file_icon: '…' |
Choose the file icon |
attrs: {...} |
Add an id, class, or other attribute to the tree |
The tree block follows the same fence, option, and nesting rules as
PyMdown Blocks.
Customise the appearance¶
The extension adds stable class names that you can target in your project's
CSS style sheet. Prodockit's managed docs/stylesheets/pdk.css contains the
default styles used by the examples on this page. Put project-specific
changes in docs/stylesheets/extra.css, which is loaded afterwards.
Generated HTML¶
The extension provides structure; your project supplies the appearance:
<div class="prodockit-tree">
<ul>
<li class="tree-directory">
<span class="tree-icon">…</span>
<span class="tree-name">docs</span>
<span class="tree-note">the documentation source tree</span>
<ul>
<li class="tree-file">
<span class="tree-icon">…</span>
<span class="tree-name">index.md</span>
</li>
</ul>
</li>
</ul>
</div>
Stable class names include .prodockit-tree, .tree-directory, .tree-file,
.tree-icon, .tree-name, and .tree-note.
docs/stylesheets/pdk.css carries the maintained starting point. When
overriding it in docs/stylesheets/extra.css, keep the rail and stub
positioned from one shared measurement, so changing indentation cannot pull
them apart, and stop the last child's rail at its own stub rather than
continuing past the final entry.