Package for generating file trees in Markdown.
- Define file trees directly in markdown
- In-place update for existing files
- Options for output customization
MDFT can be installed from PyPI using pip
:
pip install mdft
Include a definition line in a .md
file with the following format:
<!-- mdft PATH [OPTIONS] -->
The file tree will be generated for the specified path and will be inserted in the line that follows the definition. If there is content following the definition line (such as a previous version of the file tree) it will get removed up to the next blank line and replaced with the updated file tree.
MDFT is executed as a module using:
python3 -m mdft FILE.md
The Path is relative to the .md
file. The file tree will include all of the files and folders under the specified path, but, by default, will not include an entry for the folder itself (the root folder).
The Options are comma-separated values that customize the output, but may be ommited.
Option | Description | Type | Default |
---|---|---|---|
filter | Exclude files listed in .gitignore |
bool | True |
include_files | Include files (not just directories) | bool | True |
include_hidden | Include hidden files | bool | False |
include_root | Include the root folder in the tree | bool | False |
keep_line | Keep the definition line in the output file | bool | True |
link | Create links to the files | bool | True |
max_depth | Maximum scan depth from the root folder | int | None |
Values for each option are specified in the form of option=value
, e.g. max_depth=2
. For bool
values, you can ommit the value to make it True
, or prepend a !
to make it False
, e.g. !include_files
.
The following file tree is automatically generated based on the contents of the following definition:
<!-- mdft src/ include_files,link -->
This generates a tree based on the src/
folder (relative to the current file) including files and generating links for each entry, like follows:
Guidelines for contributing to the project:
- Fork the repository.
- Create a feature branch (
git checkout -b feature-name
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-name
). - Open a Pull Request.