Skip to main content

Pull Request Markdown Generator

Project description

PR2MD - Pull Request to Markdown

Python 3.13+ PyPI version License: CRL

PR2MD is a powerful command-line tool that extracts GitHub Pull Request data and converts it into comprehensive, well-formatted Markdown documents. Perfect for documentation, archiving, code reviews, or offline analysis of pull requests.

Features

  • 📥 Complete PR Data Extraction: Retrieves all PR details including metadata, description, labels, and timestamps
  • 💬 Full Conversation Thread: Captures all comments and discussions in chronological order
  • Review Information: Includes all code reviews with approval status and reviewer comments
  • 💻 Code Comments: Extracts inline review comments with their associated code context
  • 📊 Change Statistics: Displays files changed, additions, deletions, and commit information
  • 🔍 Complete Diffs: Includes the full unified diff of all changes
  • 🎨 Beautiful Formatting: Generates clean, readable Markdown with proper structure and syntax highlighting
  • Fast & Efficient: Uses the official GitHub REST API with proper error handling
  • 🔒 Type-Safe: Written in Python with comprehensive type annotations

Installation

Using pip (Recommended)

The easiest way to install PR2MD is directly from PyPI:

pip install PR2MD

That's it! The pr2md command will be available in your terminal.

From Source

Alternatively, you can install from source for development or to get the latest unreleased features:

# Clone the repository
git clone https://github.com/tboy1337/PR2MD.git
cd PR2MD

# Install dependencies
pip install -r requirements.txt

# Install the package
pip install -e .

Requirements

  • Python 3.13 or higher
  • requests library (automatically installed with pip)

Quick Start

After installing via pip, you can immediately start using PR2MD:

# Extract a PR by URL
pr2md https://github.com/owner/repo/pull/123

# Save to a file
pr2md https://github.com/owner/repo/pull/123 -o output.md

Usage

Basic Usage

Extract a PR using its URL:

pr2md https://github.com/owner/repo/pull/123

Or specify the owner, repository, and PR number separately:

pr2md owner repo 123

Save to File

Output the Markdown to a file instead of stdout:

pr2md https://github.com/owner/repo/pull/123 -o pr-details.md
pr2md owner repo 123 --output pr-analysis.md

Verbose Logging

Enable detailed logging for debugging:

pr2md https://github.com/owner/repo/pull/123 --verbose

Help

View all available options:

pr2md --help

Output Format

The generated Markdown document includes:

1. PR Header

  • PR number, title, and status (Open/Closed/Merged)
  • Author information with GitHub profile link
  • Creation, update, closed, and merged timestamps
  • Base and head branch information with commit SHAs
  • Labels (if any)

2. Description

  • The full PR description/body

3. Changes Summary

  • Number of files changed
  • Line additions and deletions

4. Code Diff

  • Complete unified diff of all changes
  • Syntax-highlighted code blocks

5. Conversation Thread

  • All comments from the PR discussion
  • Chronologically sorted
  • Author attribution and timestamps
  • Links back to GitHub

6. Reviews

  • All submitted reviews
  • Review state (Approved ✅, Changes Requested 🔴, Commented 💬, etc.)
  • Review comments and timestamps

7. Review Comments (Code Comments)

  • Inline code review comments
  • Grouped by file
  • Includes code context (diff hunk)
  • Reply chains preserved

Example

# Extract PR #42 from the PR2MD repository
pr2md tboy1337 PR2MD 42 -o pr-42.md

This creates a file pr-42.md containing all the PR information in a beautifully formatted Markdown document.

GitHub API Rate Limiting

The tool uses the GitHub REST API without authentication by default. GitHub imposes rate limits:

  • Unauthenticated requests: 60 requests per hour
  • Authenticated requests: 5,000 requests per hour

For most use cases, unauthenticated access is sufficient as the tool makes only a few API calls per PR. If you encounter rate limiting issues, the tool will provide clear error messages.

Future Enhancement: Authentication support is planned for a future release to enable higher rate limits and access to private repositories.

Development

Setup Development Environment

For development work, you'll need to install from source:

# Clone the repository
git clone https://github.com/tboy1337/PR2MD.git
cd PR2MD

# Install the package in editable mode with development dependencies
pip install -e .
pip install -r requirements-dev.txt

Design Principles

  • Type Safety: Full type annotations throughout the codebase
  • Error Handling: Graceful handling of API errors and edge cases
  • Logging: Comprehensive logging for debugging and monitoring
  • Testability: Modular design with clear separation of concerns
  • Extensibility: Easy to add new features or output formats

Use Cases

  • Code Review Documentation: Archive code reviews for compliance or historical reference
  • Offline Analysis: Review PRs without internet connectivity
  • Pull Request Templates: Learn from well-structured PRs
  • Change Management: Document significant changes in projects
  • Training Materials: Create educational resources from real-world code reviews
  • Audit Trails: Maintain records of development decisions
  • Report Generation: Include PR details in project reports

Limitations

  • Currently supports only public GitHub repositories (authentication coming soon)
  • Rate limited by GitHub API (60 requests/hour without authentication)
  • Requires internet connection to fetch data
  • Large PRs with extensive diffs may generate very large Markdown files

Roadmap

  • GitHub authentication support (personal access tokens)
  • Support for GitHub Enterprise
  • Private repository access
  • Batch processing of multiple PRs
  • Custom output templates
  • Additional output formats (HTML, PDF)
  • Diff filtering and summarization
  • PR comparison tool
  • Integration with CI/CD pipelines

Contributing

This project is maintained by tboy1337. Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

License

This project is licensed under the CRL License - see LICENSE.md for details.

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

pr2md-1.0.2.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

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

pr2md-1.0.2-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file pr2md-1.0.2.tar.gz.

File metadata

  • Download URL: pr2md-1.0.2.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pr2md-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4bc52034ab515b2227b685ecfeaf683566b8a75d6e2e8d2527cdd713c3ae65f3
MD5 d1a3225424febaa3458a9947ae17f49f
BLAKE2b-256 4807fc76939abfb33abd64a997f58b82b2c8a964e7be2b2d8cd50bc35a81484b

See more details on using hashes here.

File details

Details for the file pr2md-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pr2md-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pr2md-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 947e36fb11db252d9ade9e74c8f5c5d9346ac6c26cae3453adea0228210aa10d
MD5 27b438071f25b9bad9588dea247a4e3a
BLAKE2b-256 11ac7f48af7b2eccef090d9dea3d06204b1128bca9ebfb983700da674fce08cc

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