Description
Generate descriptive directory trees dynamically, ready for your project's REAMDE.
The descriptions are specified in the same files with a specific tag tag:
e.g. [treesource] The main readme
Directories descriptions are specified in the respective treesource.txt file
Files and folder which are not specifically described are omitted from the tree by default.
Example
$ python -m treesource
.
├── example_folder/
│ ├── first_subfolder/ (a documented folder)
│ │ ├── sub-sub1/
│ │ │ └── file3.sh (this is file 3)
│ │ ├── sub-sub2/
│ │ │ └── file4.cpp (this is file 4)
│ │ └── random_file.rdm (a documented file)
│ ├── second_subfolder/ (a documented folder with no documented files)
│ ├── a_text_file.txt (a text file)
│ ├── my_javascript.js (this is file 1)
│ └── test.py (a python script)
└── README.md (The main readme)
Install
with pip pip install treesource.
Usage
Execute the python module from the root folder: python -m treesource
usage: python -m treesource [-h] [-u] [-a] [-r PATH] [-f FORMAT]
Source file-trees generator.
optional arguments:
-h, --help show this help message and exit
-u use special unicode symbols as icons
-a show all files and folder, not only documented ones
-r PATH, --root PATH the root directory of the tree
-f FORMAT, --format FORMAT
the rendering format [txt|md|ascii]
Output formats
At the moment only txt and markdown are supported as output formats.
If you experience encoding-related problems, use the -f ascii.
The data is represented as anytree, therefore implementing other renderings is easy.
How to implement new rendering formats:
Rendering formats are specified in treesource/render/formats.py
- Write a new rendering function starting from one of the existing
- update the command line argument parsing in main.py
Use in a python script
This example shows the use of treesource in a python script, and the definition of a custom export format.
import treesource as ts
# Generate the tree
root_path='./example_folder'
tree = ts.generate_tree(root_path)
# === Render as pure text
rendered = ts.render.as_text(tree, use_unicode=False)
print(rendered)
# === Render as specific format
# The rendering FORMATS use special tokens which are replaced by the values:
# pre: the ASCII chars that represent the tree
# icon: an icon displayed is use_unicode is true
# name: the file/directory name
# doc: the documentation string
rendered = ts.render.engine.render_tree(
tree,
folder_icon='D', file_icon='F',
doc_folder_format="{pre}[{icon}]/{name}/ --> {doc}",
no_doc_folder_format="{pre}[{icon}][{name}]",
doc_file_format="{pre}[{icon}][{name}] --> {doc}",
no_doc_file_format="{pre}[{icon}][{name}]")
print(rendered)
The output is
.
├── first_subfolder\ (a documented folder)
│ ├── sub-sub1\
│ │ └── file3.sh (this is file 3)
│ ├── sub-sub2\
│ │ └── file4.cpp (this is file 4)
│ └── random_file.rdm (a documented file)
├── second_subfolder\ (a documented folder with no documented files)
├── a_text_file.txt (a text file)
├── my_javascript.js (this is file 1)
└── test.py (a python script)
.
├── [D]/first_subfolder/ --> a documented folder
│ ├── [D][sub-sub1]
│ │ └── [F][file3.sh] --> this is file 3
│ ├── [D][sub-sub2]
│ │ └── [F][file4.cpp] --> this is file 4
│ └── [F][random_file.rdm] --> a documented file
├── [D]/second_subfolder/ --> a documented folder with no documented files
├── [F][a_text_file.txt] --> a text file
├── [F][my_javascript.js] --> this is file 1
└── [F][test.py] --> a python script
Metadata
Release files for treesource 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| treesource-0.0.6.tar.gz | 7.5 kB | Without provenance | Details for treesource-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| treesource-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for treesource-0.0.6-py3-none-any.whl |
Total release size: 15.5 kB
Release files / treesource-0.0.6.tar.gz
| Download URL | treesource-0.0.6.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26c45a5734dff90474c814f8d6aeceba39498e5b2ad3d1aa1b49fa142e4ef780
|
|
BLAKE2b-256 checksum How to use checksums |
c8d279581740108b9a9d9994e462e5358c66b1c45c4bdcc50c735c9b571cf152
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
|
Release files / treesource-0.0.6-py3-none-any.whl
| Download URL | treesource-0.0.6-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8c9e858d011df84397ac57a4333ef4067d8bf6f322eb4451dec047d538c397e
|
|
BLAKE2b-256 checksum How to use checksums |
1c6c5ca4ce272760e6490dd8091157de0cdd1605ecbb86f2b8a3e71575364bc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
|
Security for treesource 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.