Skip to main content

fsg logo

fsg

Version 0.3.0 Python 3.11+ No dependencies MIT License

Generates clean directory trees that respect .gitignore and keep your docs up to date.

Features

  • Inside a git repository, only files git tracks or would track are listed (.gitignore is respected)
  • Outside a repository, common generated and tool directories are skipped (.venv, __pycache__, node_modules, target, .idea, …)
  • Directories first, entries sorted case-insensitively, empty directories omitted
  • Keeps a marked section of your README up to date, with a check mode for CI
  • Sets up the commit hook for you: extends an existing .pre-commit-config.yaml or the native git hook, never overwrites
  • Limit the depth, render directories only, or include and exclude entries by glob pattern
  • Options can live in .fsg.toml or [tool.fsg] in pyproject.toml
  • Output is wrapped in a plaintext code fence (optional) and always written as UTF-8
  • Optional ASCII branches (|--, `--) for environments without Unicode support

Installation

Requires Python 3.11+ and git (optional, for .gitignore support).

uv tool install fsg   # or: pipx install fsg
uvx fsg               # run without installing

Usage

fsg [options] [path]
Argument Description
path Directory to render (default: current directory)
-d N, --depth N Render only the first N levels below the root
--dirs-only, --no-dirs-only Render directories only
-e, --exclude PATTERN Leave out entries whose name or relative path matches the glob (repeatable)
-i, --include PATTERN Show only entries whose name or relative path matches the glob (repeatable, exclude wins)
--fence, --no-fence Wrap the tree in a Markdown code fence (default: on)
--ascii, --no-ascii Draw the tree with ASCII instead of box-drawing characters
-u, --update FILE Write the tree between the fsg markers of FILE
-c, --check FILE Exit with status 1 when the tree in FILE is out of date
--setup-hook FILE Run fsg --update FILE on every commit
-h, --help Show the help text and exit
-V, --version Show the version and exit

Example:

fsg src --depth 2
src/
└── fsg/
    ├── hooks/
    ├── trees/
    ├── __init__.py
    ├── __main__.py
    ├── cli.py
    ├── config.py
    ├── console.py
    ├── constants.py
    ├── errors.py
    ├── git.py
    ├── readme_section.py
    └── text_file.py

Configuration

With --update and --check, the path and all options not given on the command line are read from .fsg.toml or the [tool.fsg] table in pyproject.toml, searched from the directory of the target file upwards. path is relative to the config file. Command line options take precedence, include and exclude patterns are combined. Plain fsg ignores the config.

[tool.fsg]
path = "src"
depth = 2
dirs-only = false
exclude = ["*.log", "docs/api"]
include = []
fence = true
ascii = false

Keep your README up to date

Add the markers where the tree should appear:

<!-- fsg:start -->
<!-- fsg:end -->
fsg --update README.md       # writes the tree between the markers
fsg --check README.md        # exit 1 if outdated, 2 if the file or markers are missing
fsg --setup-hook README.md   # updates the tree on every commit

--setup-hook adds fsg to an existing .pre-commit-config.yaml. Without one, it adds a step to the git pre-commit hook that updates the tree and stops the commit so you can stage the change.

pre-commit

To add the hook by hand:

repos:
  - repo: https://github.com/KarnesTH/fsg
    rev: v0.3.0
    hooks:
      - id: fsg          # updates README.md
      # - id: fsg-check  # only checks, e.g. in CI

Use args for another file, e.g. args: [--update, docs/structure.md].

Development

git clone https://github.com/KarnesTH/fsg.git
cd fsg
uv sync
uv run pytest

Metadata

Release files for fsg 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fsg 0.3.0
File Size Uploaded Provenance Actions
fsg-0.3.0.tar.gz 36.9 kB Without provenance Details for fsg-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fsg 0.3.0
File Interpreter ABI Platform Actions
fsg-0.3.0-py3-none-any.whl Python 3 none any Details for fsg-0.3.0-py3-none-any.whl

Total release size: 61.3 kB

Release files / fsg-0.3.0.tar.gz

Download URL fsg-0.3.0.tar.gz
Size 36.9 kB
Tags Source
SHA-256 checksum
How to use checksums
30437fdd3e4ba58035aabdf9728ae694367a38f4f7e155399860764fb97c52e6
BLAKE2b-256 checksum
How to use checksums
09311a66c7c7cec165207e629cc840948c70547d6e10403cace51ee5bb84f857
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fsg-0.3.0-py3-none-any.whl

Download URL fsg-0.3.0-py3-none-any.whl
Size 24.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
28719abd9aa1bdd98a17b09702d7be68b2737267297ad77af976da3f67793915
BLAKE2b-256 checksum
How to use checksums
998636969db33e3e7717f50a0af3a081992c939f83b63cba262d8bc26ef8f70b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for fsg 0.3.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page