AI Personal Learning
and practical guidance
豆包Marscode1

CodeWeaver: Automatically generate Markdown documents from code structure and content.

General Introduction

CodeWeaver is a command-line tool designed to weave a code base into a single, easy-to-navigate Markdown document. It generates a structured representation of a project's file hierarchy by recursively scanning through directories and embedding the contents of each file in code blocks. The tool is designed with the goal of simplifying codebase sharing and information extraction, and is particularly suited for making codebase information available to AI/ML code analysis tools for processing.

CodeWeaver:将代码结构和内容自动生成Markdown文档-1

Here's a sample generation: https://github.com/tesserato/CodeWeaver/blob/main/codebase.md


 

Function List

  • Comprehensive code base documentation generation: Generate a Markdown file detailing the project's directory and file structure in a clear tree format.
  • Code Content Embedding: Embed the full content of each file in the generated Markdown document, with syntax highlighting based on the file extension.
  • Flexible path filtering: Use regular expressions to define ignore patterns that allow the exclusion of specific files and directories (e.g., .git, build products, specific file types).
  • Optional path logging: Option to save separate lists of included and excluded file paths to a file for detailed tracking and debugging of ignore rules.
  • Simple command line interface: Provides an intuitive command line interface with straightforward customization options.

 

Using Help

Installation process

Installation using Go

If you have installed the Go language environment, you can run the following command to install the latest version of CodeWeaver:

go install github.com/tesserato/CodeWeaver@latest

Or install the specified version:

go install github.com/tesserato/CodeWeaver@vX.Y.Z

Download the pre-compiled executable

Download the appropriate pre-compiled executable from the release page.

If desired, you can use thechmodcommand gives the executable file execute permission:

chmod +x codeweaver

Usage Process

Getting Help

Run the following command for help information:

codeweaver -h

practical use

Run the following command to generate the documentation:

codeweaver [options]

Description of options

options (as in computer software settings) descriptive default value
-dir The root directory to be scanned and logged. Current directory (...)
-output Outputs the name of the Markdown file. codebase.md
-ignore "" Comma-separated list of path regular expression patterns to exclude specific paths. .git.*
-included-paths-file Saves the file containing the list of paths in the document. not have
-excluded-paths-file File that holds the list of paths excluded due to the ignore rule. not have
-help Display this help message and exit. not have

usage example

Generate documentation for the current directory

./codeweaver

This command will create a file in the current directory namedcodebase.mdfile that records the structure and contents of the current directory and its subdirectories (exclude matches the default ignore pattern).\.git.*(the path).

Specify different input directories and output files

./codeweaver -dir=my_project -output=project_docs.md

This command will process themy_projectdirectory and save the document to theproject_docs.mdThe

Ignore specific file types and directories

./codeweaver -ignore="\.log,temp,build" -output=detailed_docs.md

The example will generatedetailed_docs.md, excluding any name that contains.log,tempmaybebuildof files or directories. Regular expression patterns are separated by commas.

Save a list of included and excluded paths

./codeweaver -ignore="node_modules" -included-paths-file=included.txt -excluded-paths-file=excluded.txt -output=code_overview.md

This command will create thecode_overview.mdwhile saving the list of included paths to theincluded.txtwill be due tonode_modulesThe list of paths excluded by the ignore pattern is saved to theexcluded.txtThe

May not be reproduced without permission:Chief AI Sharing Circle " CodeWeaver: Automatically generate Markdown documents from code structure and content.
en_USEnglish