Skip to main content

A tool to generate comprehensive Markdown artifacts of directory structures and file contents

Project description

CodeMapper

Pylint TODO logo

Overview

CodeMapper is a powerful Python tool designed to generate comprehensive Markdown (pdf, xml, and json outputs are on the way) representations of codebases. It bridges the gap between human developers and AI systems by providing a clear, structured view of project architectures and their complete contents. Whether you're working with local directories or GitHub repositories, CodeMapper creates a single, navigable document that encapsulates the full structure and content of a project.

This tool is invaluable for rapid codebase comprehension, whether you're a developer onboarding to a new project or an AI system analyzing code structure.

For audio explanations of this project, see:

  • podcasts (Auto-generated by Gemini using NotebookLLM)

Features

  • Dual-Purpose Output: Generates content optimized for both human readers and AI analysis
  • Intelligent Content Parsing:
    • Respects .gitignore rules
    • Handles various file types appropriately
  • Comprehensive Structure Representation:
    • Creates an accurate, hierarchical file tree
    • Generates a smart table of contents for easy navigation
  • Code-Aware Processing:
    • Applies appropriate syntax highlighting for different file types
    • Intelligently handles large or binary files without bloating the output
  • Flexible Input Handling: Works with local directories and GitHub repositories
  • Encoding Detection: Ensures accurate content reading across various file encodings
  • Customizable Ignore Rules: Option to include files normally ignored by .gitignore
  • Efficient Output Management: Organizes generated documents in a '_codemaps' directory

Roadmap

Requirements

  • Python 3.6+
  • pathspec library (for handling .gitignore rules)
  • chardet library (for file encoding detection)

Installation

From PyPI

Install CodeMapper directly from PyPI:

pip install codemapper

From Source

  1. Clone this repository:

    git clone https://github.com/shaneholloman/codemapper.git
    
  2. Navigate to the cloned directory and install the package:

    cd codemapper
    pip install .
    

Building the Package

To build the package using pyproject.toml:

python -m build

This will create distribution files in the dist directory.

Usage

Run CodeMapper from the command line, providing the path to the directory or GitHub repository URL you want to analyze:

codemapper <path_to_directory_or_github_url> [--include-ignored]

Options

  • <path_to_directory_or_github_url>: The path to the directory or GitHub repository URL to analyze (required)
  • --include-ignored: Include files that are normally ignored by .gitignore (optional)

Output

CodeMapper generates a Markdown file named <directory_name>_codemap.md in the '_codemaps' directory. This file contains:

  1. A comprehensive table of contents for easy navigation
  2. An accurate file tree representation of the directory structure
  3. The contents of each file, formatted with appropriate syntax highlighting
  4. Information about large and binary files (type and size) without their contents

Example usage and output:

codemapper https://github.com/shaneholloman/ansible-role-apache

View example output here

Use Cases

  • Rapidly understand the structure and content of new or unfamiliar projects
  • Generate comprehensive documentation for code-based AI prompts
  • Facilitate thorough code reviews by providing a complete one-page overview
  • Assist AI systems in analyzing and understanding complex codebases
  • Analyze GitHub repositories without manual cloning

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to the pathspec and chardet libraries for enhancing CodeMapper's functionality.

Version History

For a detailed version history, please refer to the changelog.md.


If you find CodeMapper useful, don't forget to star this repository!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codemapper-0.1.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codemapper-0.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file codemapper-0.1.0.tar.gz.

File metadata

  • Download URL: codemapper-0.1.0.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for codemapper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bcd6672985ba901f4a39da8dbc677e342c8af031a718094bb804a0d144d819a7
MD5 dd8300e2f447b5d0f5d205b54a6b9bde
BLAKE2b-256 3a48f10ff1deda88c7cc1ca749669729ce33ca4a8bb84bf0e4506ab4fbfd313f

See more details on using hashes here.

File details

Details for the file codemapper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: codemapper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for codemapper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe30477b29e954037cc3d5efad25476720e270b13d5798048f9aa56ecde69d6f
MD5 e943ac3983c315789499a50ab1c77a80
BLAKE2b-256 bbe87f50990c588134db44e64b21dd87d58681d81e1e3e89e4e7b22555655ca6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page