/MDFT

Package for generating file trees in Markdown

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

MDFT - Markdown File Trees

PyPI Version License: GPL v3 Python Version

Overview

Package for generating file trees in Markdown.

  • Define file trees directly in markdown
  • In-place update for existing files
  • Options for output customization

Installation

MDFT can be installed from PyPI using pip:

pip install mdft

Usage

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

Path

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).

Options

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.

Example

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:

Contributing

Guidelines for contributing to the project:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature-name).
  3. Commit your changes (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature-name).
  5. Open a Pull Request.