Skip to main content

A tool to convert source code to text or docx

Project description

source-to-text-converter

A utility tool to convert the content of software codebases (local or GitHub) into a single structured text or .docx file for easy analysis, documentation, or processing.

Features

  • Supports local directories and GitHub repositories as input.
  • Preserves folder structure in the output.
  • Outputs consolidated content as plain text or .docx.
  • Option to exclude hidden files and directories.
  • Verbose mode for detailed processing logs.
  • File type filtering by extension.
  • Robust error handling and cleanup.

Limitations

  • Does not support private GitHub repositories requiring authentication.
  • Large repositories with thousands of files may experience slower processing times.
  • Binary and non-text files are skipped silently.
  • .docx output may not preserve complex code formatting perfectly.
  • No support for incremental updates; entire codebase is processed each time.

Installation

pip install source-to-text-converter

Usage

CLI

source-to-text-converter --input <input_path_or_url> --output <output_file> [options]

Options:

  • --input (required): Local directory path or GitHub repo URL.
  • --output (required): Output file path.
  • --output-type (optional): txt (default) or docx.
  • --exclude-hidden (optional): Exclude hidden files and directories.
  • --include-ext (optional): Comma-separated list of file extensions to include (e.g., .py,.js).
  • --verbose (optional): Show detailed logs.

Python API

from source_to_text_converter.source_to_text_converter import UnifiedSourceToTextConverter

# Example usage with a local directory
converter = UnifiedSourceToTextConverter(
    input_path="/path/to/repo",
    output_path="output.txt",
    output_type="txt",
    exclude_hidden=True,
    include_exts=[".py", ".js"],
    verbose=True
)
converter.get_file()

# Example usage with a GitHub repository URL and optional branch
github_converter = UnifiedSourceToTextConverter(
    input_path="https://github.com/username/repository.git",
    output_path="output.docx",
    output_type="docx",
    exclude_hidden=True,
    include_exts=[".py", ".js"],
    verbose=True,
    branch="main"  # Optional: specify branch to clone
)
github_converter.get_file()

License

Apache License 2.0

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

source_to_text_converter-0.1.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file source_to_text_converter-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for source_to_text_converter-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 024b79b8ec15c750a6bd1d92976e27243605c7034356cfbdb84a3bab11b5a5f7
MD5 deadaa63230dea86ba5d5b6d66f6fed4
BLAKE2b-256 12b91102ef90b1c60cb515c5361cca943a2fdb414cca96d71f78a8f796d232a9

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