Generate a Markdown file with all contents of your project
Project description
RepoSnap
Overview
reposnap is a Python tool designed to generate a Markdown file that documents the structure and contents of a Git project. It provides both a command-line interface (CLI) and a graphical user interface (GUI) for ease of use. This tool is particularly useful for creating a quick overview of a project's file hierarchy, including optional syntax-highlighted code snippets.
Features
- Command-Line Interface (CLI): Quickly generate documentation from the terminal.
- Graphical User Interface (GUI): A user-friendly GUI if you want to select files and directories interactively.
- Syntax Highlighting: Includes syntax highlighting for known file types in the generated Markdown file.
- Structure Only Option: The
--structure-onlyflag can be used to generate the Markdown file with just the directory structure, omitting the contents of the files. - Gitignore Support: Automatically respects
.gitignorepatterns to exclude files and directories. - Include and Exclude Patterns: Use
--includeand--excludeto specify patterns for files and directories to include or exclude. - Content Filtering: Use
--containsto filter files based on their content, including only files that contain specific substrings or code patterns. - Changes Only Mode: Use
-cor--changesto snapshot only uncommitted files (staged, unstaged, untracked, and stashed changes).
Installation
You can install reposnap using pip:
pip install reposnap
Alternatively, you can clone the repository and install the required dependencies:
git clone https://github.com/username/reposnap.git
cd reposnap
pip install -r requirements.lock
Usage
Command-Line Interface
To use reposnap from the command line, run it with the following options:
reposnap [-h] [-o OUTPUT] [--structure-only] [--debug] [-i INCLUDE [INCLUDE ...]] [-e EXCLUDE [EXCLUDE ...]] [-c] [-S CONTAINS [CONTAINS ...]] [--contains-case] paths [paths ...]
paths: One or more paths (files or directories) within the repository whose content and structure should be rendered.-h, --help: Show help message and exit.-o, --output: The name of the output Markdown file. Defaults tooutput.md.--structure-only: Generate a Markdown file that includes only the project structure, without file contents.--debug: Enable debug-level logging.-i, --include: File/folder patterns to include. For example,-i "*.py"includes only Python files.-e, --exclude: File/folder patterns to exclude. For example,-e "*.md"excludes all Markdown files.-c, --changes: Use only files that are added/modified/untracked/stashed but not yet committed.-S, --contains: Only include files whose contents contain these substrings. Multiple patterns can be specified.--contains-case: Make--containscase-sensitive (default is case-insensitive).
Pattern Matching
-
Pattern Interpretation: Patterns follow gitignore-style syntax but with a twist.
- Patterns without Wildcards: If a pattern does not contain any wildcard characters (
*,?, or[), it is treated as*pattern*. This means it will match any file or directory containingpatternin its name. - Patterns with Wildcards: If a pattern contains wildcard characters, it retains its original behavior.
- Patterns without Wildcards: If a pattern does not contain any wildcard characters (
-
Examples:
-e "gui": Excludes any files or directories containing"gui"in their names.-i "*.py": Includes only files ending with.py.-e "*.test.*": Excludes files with.test.in their names.
Content Filtering
The --contains (or -S) flag allows you to filter files based on their content, including only files that contain specific substrings. This is particularly useful for focusing on files that contain certain code patterns, imports, or keywords.
- Case Sensitivity: By default, content matching is case-insensitive. Use the
--contains-caseflag to enable case-sensitive matching. - Multiple Patterns: You can specify multiple patterns, and files containing any of the patterns will be included (OR logic).
- Performance: Large files (>5MB) and binary files are automatically skipped for performance and safety reasons.
Examples:
-
Find files containing specific imports:
reposnap . -S "import logging"
-
Search for multiple patterns (OR logic):
reposnap . -S "TODO" "FIXME" "import requests"
-
Case-sensitive content search:
reposnap . -S "TODO" --contains-case
-
Combine content filtering with other filters:
reposnap . -S "class " -i "*.py" --structure-only
-
Find files with specific function calls:
reposnap . -S "logger.error" "raise Exception"
Only Snapshot Your Current Work
The -c or --changes flag allows you to generate documentation for only the files that have been modified but not yet committed. This includes:
- Staged changes: Files that have been added to the index with
git add - Unstaged changes: Files that have been modified but not yet staged
- Untracked files: New files that haven't been added to Git yet
- Stashed changes: Files that are stored in Git stash entries
This is particularly useful when you want to:
- Document only your current work-in-progress
- Create a snapshot of changes before committing
- Review what files you've been working on
Examples:
-
Generate documentation for only your uncommitted changes:
reposnap . -c
-
Combine with structure-only for a quick overview:
reposnap . -c --structure-only
-
Filter uncommitted changes by file type:
reposnap . -c -i "*.py"
-
Exclude test files from uncommitted changes:
reposnap . -c -e "*test*"
Examples
-
Generate a full project structure with file contents:
reposnap . -
Generate a project structure only:
reposnap my_project/ --structure-only
-
Generate a Markdown file including only Python files:
reposnap my_project/ -i "*.py"
-
Generate a Markdown file excluding certain files and directories:
reposnap my_project_folder my_project_folder_2 -e "tests" -e "*.md"
-
Exclude files and directories containing a substring:
reposnap my_project/ -e "gui"
-
Document only your current uncommitted work:
reposnap . -c
-
Find and document files containing specific code patterns:
reposnap . -S "import logging" "logger."
-
Combine content filtering with file type filtering:
reposnap . -S "class " -i "*.py" --structure-only
Graphical User Interface
reposnap also provides a GUI for users who prefer an interactive interface.
To launch the GUI, simply run:
reposnap-gui
Using the GUI
-
Select Root Directory: When the GUI opens, you can specify the root directory of your Git project. By default, it uses the current directory.
-
Scan the Project: Click the "Scan" button to analyze the project. The GUI will display the file tree of your project.
-
Select Files and Directories: Use the checkboxes to select which files and directories you want to include in the Markdown documentation. Toggling a directory checkbox will toggle all its child files and directories.
-
Generate Markdown: After selecting the desired files, click the "Render" button. The Markdown file will be generated and saved as
output.mdin the current directory. -
Exit: Click the "Exit" button to close the GUI.
Testing
To run the tests, use the following command:
pytest tests/
Ensure that you have the pytest library installed:
pip install pytest
License
This project is licensed under the MIT License.
Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reposnap-0.8.0.tar.gz.
File metadata
- Download URL: reposnap-0.8.0.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
339470656926cb8010939dfe56f047a1bff07d029a8429a1595d07b9e60db6c3
|
|
| MD5 |
ec7934cab1c73ac63d6ab18e9c8e2991
|
|
| BLAKE2b-256 |
468d38553c3c0cacd08423233fe12f3e611aecf7f744d9ce676039bd268a1c2f
|
Provenance
The following attestation bundles were made for reposnap-0.8.0.tar.gz:
Publisher:
release.yml on agoloborodko/reposnap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
reposnap-0.8.0.tar.gz -
Subject digest:
339470656926cb8010939dfe56f047a1bff07d029a8429a1595d07b9e60db6c3 - Sigstore transparency entry: 255571099
- Sigstore integration time:
-
Permalink:
agoloborodko/reposnap@348167b99c5f8277833e4a0498ffd2789fd8e247 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/agoloborodko
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@348167b99c5f8277833e4a0498ffd2789fd8e247 -
Trigger Event:
push
-
Statement type:
File details
Details for the file reposnap-0.8.0-py3-none-any.whl.
File metadata
- Download URL: reposnap-0.8.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8cc02c3888a182e67717afdb3d595dd5a06eaffe166d6342112e34969e7701f
|
|
| MD5 |
6550beda39602a2b8cce261ab21def23
|
|
| BLAKE2b-256 |
ab562d4eaa81edac13a7e595c6e23f96f54ebf581af47ba11d4f2410087ffbbc
|
Provenance
The following attestation bundles were made for reposnap-0.8.0-py3-none-any.whl:
Publisher:
release.yml on agoloborodko/reposnap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
reposnap-0.8.0-py3-none-any.whl -
Subject digest:
e8cc02c3888a182e67717afdb3d595dd5a06eaffe166d6342112e34969e7701f - Sigstore transparency entry: 255571100
- Sigstore integration time:
-
Permalink:
agoloborodko/reposnap@348167b99c5f8277833e4a0498ffd2789fd8e247 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/agoloborodko
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@348167b99c5f8277833e4a0498ffd2789fd8e247 -
Trigger Event:
push
-
Statement type: