PR2MD 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pr2md-1.0.1/LICENSE.md +70 -0
- pr2md-1.0.1/PKG-INFO +317 -0
- pr2md-1.0.1/README.md +296 -0
- pr2md-1.0.1/pyproject.toml +102 -0
- pr2md-1.0.1/setup.cfg +4 -0
- pr2md-1.0.1/src/PR2MD.egg-info/PKG-INFO +317 -0
- pr2md-1.0.1/src/PR2MD.egg-info/SOURCES.txt +20 -0
- pr2md-1.0.1/src/PR2MD.egg-info/dependency_links.txt +1 -0
- pr2md-1.0.1/src/PR2MD.egg-info/entry_points.txt +2 -0
- pr2md-1.0.1/src/PR2MD.egg-info/top_level.txt +1 -0
- pr2md-1.0.1/src/pr2md/__init__.py +21 -0
- pr2md-1.0.1/src/pr2md/__main__.py +6 -0
- pr2md-1.0.1/src/pr2md/cli.py +236 -0
- pr2md-1.0.1/src/pr2md/formatter.py +231 -0
- pr2md-1.0.1/src/pr2md/models.py +225 -0
- pr2md-1.0.1/src/pr2md/pr_extractor.py +190 -0
- pr2md-1.0.1/src/pr2md/py.typed +0 -0
- pr2md-1.0.1/tests/test_cli.py +480 -0
- pr2md-1.0.1/tests/test_formatter.py +548 -0
- pr2md-1.0.1/tests/test_integration.py +85 -0
- pr2md-1.0.1/tests/test_models.py +667 -0
- pr2md-1.0.1/tests/test_pr_extractor.py +240 -0
pr2md-1.0.1/LICENSE.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Commercial Restricted License (CRL)
|
|
2
|
+
|
|
3
|
+
**Version 1.1**
|
|
4
|
+
|
|
5
|
+
**Copyright (c) 2025 tboy1337**
|
|
6
|
+
|
|
7
|
+
## Grant of Rights
|
|
8
|
+
|
|
9
|
+
Subject to the terms and conditions of this license, the copyright holder grants you a worldwide, royalty-free, non-exclusive license to use, copy, modify, and distribute this software and associated documentation files (the "Software") for **Non-Commercial Use** only.
|
|
10
|
+
|
|
11
|
+
## Definitions
|
|
12
|
+
|
|
13
|
+
**"Non-Commercial Use"** means use of the Software that is not primarily intended for or directed toward commercial advantage or monetary compensation. Non-Commercial Use includes:
|
|
14
|
+
|
|
15
|
+
- Personal use, learning, and experimentation
|
|
16
|
+
- Academic research and education
|
|
17
|
+
- Open source projects that are not monetized
|
|
18
|
+
- Internal evaluation within a commercial organization (limited to 30 days)
|
|
19
|
+
- Use by registered non-profit organizations for their non-profit activities
|
|
20
|
+
|
|
21
|
+
**"Commercial Use"** means any use of the Software that is primarily intended for or directed toward commercial advantage or monetary compensation, including but not limited to:
|
|
22
|
+
|
|
23
|
+
- Use in any product or service that generates revenue
|
|
24
|
+
- Use by for-profit organizations in their business operations
|
|
25
|
+
- Integration into commercial software or services
|
|
26
|
+
- Use in providing paid consulting, support, or services
|
|
27
|
+
- Use in any business process that contributes to revenue generation
|
|
28
|
+
- Use by organizations with annual revenue exceeding $100,000 USD
|
|
29
|
+
|
|
30
|
+
**Note:** Any Commercial Use of the Software requires a separate commercial license from the copyright holder.
|
|
31
|
+
|
|
32
|
+
## Conditions
|
|
33
|
+
|
|
34
|
+
For Non-Commercial Use, you may:
|
|
35
|
+
|
|
36
|
+
- Use, copy, and modify the Software
|
|
37
|
+
- Distribute copies of the Software
|
|
38
|
+
- Distribute your modifications under this same license
|
|
39
|
+
|
|
40
|
+
You must:
|
|
41
|
+
|
|
42
|
+
- Include this license notice in all copies or substantial portions of the Software
|
|
43
|
+
- Not remove or alter any copyright notices
|
|
44
|
+
|
|
45
|
+
## Restrictions
|
|
46
|
+
|
|
47
|
+
You may not:
|
|
48
|
+
|
|
49
|
+
- Use the Software for Commercial Use without a commercial license
|
|
50
|
+
- Sublicense the Software under different terms
|
|
51
|
+
- Use the Software in any way that violates applicable laws
|
|
52
|
+
- Remove, obscure, or modify any licensing, copyright, or other legal notices
|
|
53
|
+
|
|
54
|
+
## No Warranty
|
|
55
|
+
|
|
56
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
57
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
58
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
59
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
60
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
61
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
62
|
+
SOFTWARE.
|
|
63
|
+
|
|
64
|
+
## Termination
|
|
65
|
+
|
|
66
|
+
This license terminates automatically if you violate any of its terms. Upon termination, you must cease all use and distribution of the Software and destroy all copies in your possession.
|
|
67
|
+
|
|
68
|
+
## Governing Law
|
|
69
|
+
|
|
70
|
+
This license shall be governed by and construed in accordance with the laws of the United Kingdom, without regard to its conflict of law provisions.
|
pr2md-1.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PR2MD
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Pull Request Markdown Generator
|
|
5
|
+
Author: tboy1337
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/tboy1337/PR2MD
|
|
8
|
+
Project-URL: Repository, https://github.com/tboy1337/PR2MD
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Python: >=3.13
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE.md
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# PR2MD - Pull Request to Markdown
|
|
23
|
+
|
|
24
|
+
[](https://www.python.org/downloads/)
|
|
25
|
+
[](LICENSE.md)
|
|
26
|
+
|
|
27
|
+
**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.
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- 📥 **Complete PR Data Extraction**: Retrieves all PR details including metadata, description, labels, and timestamps
|
|
32
|
+
- 💬 **Full Conversation Thread**: Captures all comments and discussions in chronological order
|
|
33
|
+
- ✅ **Review Information**: Includes all code reviews with approval status and reviewer comments
|
|
34
|
+
- 💻 **Code Comments**: Extracts inline review comments with their associated code context
|
|
35
|
+
- 📊 **Change Statistics**: Displays files changed, additions, deletions, and commit information
|
|
36
|
+
- 🔍 **Complete Diffs**: Includes the full unified diff of all changes
|
|
37
|
+
- 🎨 **Beautiful Formatting**: Generates clean, readable Markdown with proper structure and syntax highlighting
|
|
38
|
+
- ⚡ **Fast & Efficient**: Uses the official GitHub REST API with proper error handling
|
|
39
|
+
- 🔒 **Type-Safe**: Written in Python with comprehensive type annotations
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
### From Source
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Clone the repository
|
|
47
|
+
git clone https://github.com/tboy1337/PR2MD.git
|
|
48
|
+
cd PR2MD
|
|
49
|
+
|
|
50
|
+
# Install dependencies
|
|
51
|
+
pip install -r requirements.txt
|
|
52
|
+
|
|
53
|
+
# Install the package
|
|
54
|
+
pip install -e .
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Requirements
|
|
58
|
+
|
|
59
|
+
- Python 3.13 or higher
|
|
60
|
+
- `requests` library (for GitHub API communication)
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### Basic Usage
|
|
65
|
+
|
|
66
|
+
Extract a PR using its URL:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pr2md https://github.com/owner/repo/pull/123
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Or specify the owner, repository, and PR number separately:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pr2md owner repo 123
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Save to File
|
|
79
|
+
|
|
80
|
+
Output the Markdown to a file instead of stdout:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pr2md https://github.com/owner/repo/pull/123 -o pr-details.md
|
|
84
|
+
pr2md owner repo 123 --output pr-analysis.md
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Verbose Logging
|
|
88
|
+
|
|
89
|
+
Enable detailed logging for debugging:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pr2md https://github.com/owner/repo/pull/123 --verbose
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Help
|
|
96
|
+
|
|
97
|
+
View all available options:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pr2md --help
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Output Format
|
|
104
|
+
|
|
105
|
+
The generated Markdown document includes:
|
|
106
|
+
|
|
107
|
+
### 1. PR Header
|
|
108
|
+
- PR number, title, and status (Open/Closed/Merged)
|
|
109
|
+
- Author information with GitHub profile link
|
|
110
|
+
- Creation, update, closed, and merged timestamps
|
|
111
|
+
- Base and head branch information with commit SHAs
|
|
112
|
+
- Labels (if any)
|
|
113
|
+
|
|
114
|
+
### 2. Description
|
|
115
|
+
- The full PR description/body
|
|
116
|
+
|
|
117
|
+
### 3. Changes Summary
|
|
118
|
+
- Number of files changed
|
|
119
|
+
- Line additions and deletions
|
|
120
|
+
|
|
121
|
+
### 4. Code Diff
|
|
122
|
+
- Complete unified diff of all changes
|
|
123
|
+
- Syntax-highlighted code blocks
|
|
124
|
+
|
|
125
|
+
### 5. Conversation Thread
|
|
126
|
+
- All comments from the PR discussion
|
|
127
|
+
- Chronologically sorted
|
|
128
|
+
- Author attribution and timestamps
|
|
129
|
+
- Links back to GitHub
|
|
130
|
+
|
|
131
|
+
### 6. Reviews
|
|
132
|
+
- All submitted reviews
|
|
133
|
+
- Review state (Approved ✅, Changes Requested 🔴, Commented 💬, etc.)
|
|
134
|
+
- Review comments and timestamps
|
|
135
|
+
|
|
136
|
+
### 7. Review Comments (Code Comments)
|
|
137
|
+
- Inline code review comments
|
|
138
|
+
- Grouped by file
|
|
139
|
+
- Includes code context (diff hunk)
|
|
140
|
+
- Reply chains preserved
|
|
141
|
+
|
|
142
|
+
## Example
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Extract PR #42 from the PR2MD repository
|
|
146
|
+
pr2md tboy1337 PR2MD 42 -o pr-42.md
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
This creates a file `pr-42.md` containing all the PR information in a beautifully formatted Markdown document.
|
|
150
|
+
|
|
151
|
+
## GitHub API Rate Limiting
|
|
152
|
+
|
|
153
|
+
The tool uses the GitHub REST API without authentication by default. GitHub imposes rate limits:
|
|
154
|
+
|
|
155
|
+
- **Unauthenticated requests**: 60 requests per hour
|
|
156
|
+
- **Authenticated requests**: 5,000 requests per hour
|
|
157
|
+
|
|
158
|
+
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.
|
|
159
|
+
|
|
160
|
+
**Future Enhancement**: Authentication support is planned for a future release to enable higher rate limits and access to private repositories.
|
|
161
|
+
|
|
162
|
+
## Development
|
|
163
|
+
|
|
164
|
+
### Setup Development Environment
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Clone the repository
|
|
168
|
+
git clone https://github.com/tboy1337/PR2MD.git
|
|
169
|
+
cd PR2MD
|
|
170
|
+
|
|
171
|
+
# Install development dependencies
|
|
172
|
+
pip install -r requirements-dev.txt
|
|
173
|
+
|
|
174
|
+
# Install the package in editable mode
|
|
175
|
+
pip install -e .
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Running Tests
|
|
179
|
+
|
|
180
|
+
The project includes comprehensive tests using pytest:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Run all tests
|
|
184
|
+
pytest
|
|
185
|
+
|
|
186
|
+
# Run with coverage
|
|
187
|
+
pytest --cov=pr2md --cov-report=html
|
|
188
|
+
|
|
189
|
+
# Run specific test file
|
|
190
|
+
pytest tests/test_cli.py
|
|
191
|
+
|
|
192
|
+
# Run with verbose output
|
|
193
|
+
pytest -v
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Code Quality
|
|
197
|
+
|
|
198
|
+
The project maintains high code quality standards:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Type checking with mypy
|
|
202
|
+
mypy src/pr2md
|
|
203
|
+
|
|
204
|
+
# Linting with pylint
|
|
205
|
+
pylint src/pr2md
|
|
206
|
+
|
|
207
|
+
# Code formatting with black
|
|
208
|
+
black src/pr2md tests
|
|
209
|
+
|
|
210
|
+
# Import sorting with isort
|
|
211
|
+
isort src/pr2md tests
|
|
212
|
+
|
|
213
|
+
# Remove trailing whitespace
|
|
214
|
+
py -m autopep8 --in-place --select=W291,W293 src tests
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Project Structure
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
PR2MD/
|
|
221
|
+
├── src/
|
|
222
|
+
│ └── pr2md/
|
|
223
|
+
│ ├── __init__.py
|
|
224
|
+
│ ├── __main__.py # Entry point
|
|
225
|
+
│ ├── cli.py # Command-line interface
|
|
226
|
+
│ ├── models.py # Data models
|
|
227
|
+
│ ├── pr_extractor.py # GitHub API client
|
|
228
|
+
│ ├── formatter.py # Markdown formatter
|
|
229
|
+
│ └── py.typed # Type checking marker
|
|
230
|
+
├── tests/ # Comprehensive test suite
|
|
231
|
+
├── pyproject.toml # Project configuration
|
|
232
|
+
├── requirements.txt # Runtime dependencies
|
|
233
|
+
├── requirements-dev.txt # Development dependencies
|
|
234
|
+
├── mypy.ini # Type checking configuration
|
|
235
|
+
├── pytest.ini # Test configuration
|
|
236
|
+
└── README.md # This file
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Architecture
|
|
240
|
+
|
|
241
|
+
### Core Components
|
|
242
|
+
|
|
243
|
+
1. **CLI Module** (`cli.py`): Handles command-line argument parsing, logging setup, and orchestrates the extraction and formatting process.
|
|
244
|
+
|
|
245
|
+
2. **PR Extractor** (`pr_extractor.py`): Communicates with the GitHub REST API to fetch PR data, comments, reviews, and diffs. Includes comprehensive error handling.
|
|
246
|
+
|
|
247
|
+
3. **Models** (`models.py`): Type-safe data classes representing GitHub entities (PullRequest, Comment, Review, ReviewComment, User, Label).
|
|
248
|
+
|
|
249
|
+
4. **Formatter** (`formatter.py`): Converts structured PR data into beautifully formatted Markdown with proper sections and syntax highlighting.
|
|
250
|
+
|
|
251
|
+
### Design Principles
|
|
252
|
+
|
|
253
|
+
- **Type Safety**: Full type annotations throughout the codebase
|
|
254
|
+
- **Error Handling**: Graceful handling of API errors and edge cases
|
|
255
|
+
- **Logging**: Comprehensive logging for debugging and monitoring
|
|
256
|
+
- **Testability**: Modular design with clear separation of concerns
|
|
257
|
+
- **Extensibility**: Easy to add new features or output formats
|
|
258
|
+
|
|
259
|
+
## Use Cases
|
|
260
|
+
|
|
261
|
+
- **Code Review Documentation**: Archive code reviews for compliance or historical reference
|
|
262
|
+
- **Offline Analysis**: Review PRs without internet connectivity
|
|
263
|
+
- **Pull Request Templates**: Learn from well-structured PRs
|
|
264
|
+
- **Change Management**: Document significant changes in projects
|
|
265
|
+
- **Training Materials**: Create educational resources from real-world code reviews
|
|
266
|
+
- **Audit Trails**: Maintain records of development decisions
|
|
267
|
+
- **Report Generation**: Include PR details in project reports
|
|
268
|
+
|
|
269
|
+
## Limitations
|
|
270
|
+
|
|
271
|
+
- Currently supports only public GitHub repositories (authentication coming soon)
|
|
272
|
+
- Rate limited by GitHub API (60 requests/hour without authentication)
|
|
273
|
+
- Requires internet connection to fetch data
|
|
274
|
+
- Large PRs with extensive diffs may generate very large Markdown files
|
|
275
|
+
|
|
276
|
+
## Roadmap
|
|
277
|
+
|
|
278
|
+
- [ ] GitHub authentication support (personal access tokens)
|
|
279
|
+
- [ ] Support for GitHub Enterprise
|
|
280
|
+
- [ ] Private repository access
|
|
281
|
+
- [ ] Batch processing of multiple PRs
|
|
282
|
+
- [ ] Custom output templates
|
|
283
|
+
- [ ] Additional output formats (HTML, PDF)
|
|
284
|
+
- [ ] Diff filtering and summarization
|
|
285
|
+
- [ ] PR comparison tool
|
|
286
|
+
- [ ] Integration with CI/CD pipelines
|
|
287
|
+
|
|
288
|
+
## Contributing
|
|
289
|
+
|
|
290
|
+
This project is maintained by tboy1337. Contributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/tboy1337/PR2MD/issues).
|
|
291
|
+
|
|
292
|
+
## License
|
|
293
|
+
|
|
294
|
+
This project is licensed under the **Commercial Restricted License (CRL) Version 1.1**.
|
|
295
|
+
|
|
296
|
+
**Summary:**
|
|
297
|
+
- ✅ **Free for non-commercial use** (personal, educational, research, open source)
|
|
298
|
+
- ❌ **Commercial use requires a separate commercial license**
|
|
299
|
+
- 📧 Contact the copyright holder for commercial licensing inquiries
|
|
300
|
+
|
|
301
|
+
See the [LICENSE.md](LICENSE.md) file for the complete license text.
|
|
302
|
+
|
|
303
|
+
## Author
|
|
304
|
+
|
|
305
|
+
**tboy1337**
|
|
306
|
+
- GitHub: [@tboy1337](https://github.com/tboy1337)
|
|
307
|
+
|
|
308
|
+
## Acknowledgments
|
|
309
|
+
|
|
310
|
+
- Built with Python 3.13+
|
|
311
|
+
- Uses the [GitHub REST API](https://docs.github.com/en/rest)
|
|
312
|
+
- Inspired by the need for better PR documentation tools
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
**Made with ❤️ for the developer community**
|
|
317
|
+
|
pr2md-1.0.1/README.md
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# PR2MD - Pull Request to Markdown
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/downloads/)
|
|
4
|
+
[](LICENSE.md)
|
|
5
|
+
|
|
6
|
+
**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.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 📥 **Complete PR Data Extraction**: Retrieves all PR details including metadata, description, labels, and timestamps
|
|
11
|
+
- 💬 **Full Conversation Thread**: Captures all comments and discussions in chronological order
|
|
12
|
+
- ✅ **Review Information**: Includes all code reviews with approval status and reviewer comments
|
|
13
|
+
- 💻 **Code Comments**: Extracts inline review comments with their associated code context
|
|
14
|
+
- 📊 **Change Statistics**: Displays files changed, additions, deletions, and commit information
|
|
15
|
+
- 🔍 **Complete Diffs**: Includes the full unified diff of all changes
|
|
16
|
+
- 🎨 **Beautiful Formatting**: Generates clean, readable Markdown with proper structure and syntax highlighting
|
|
17
|
+
- ⚡ **Fast & Efficient**: Uses the official GitHub REST API with proper error handling
|
|
18
|
+
- 🔒 **Type-Safe**: Written in Python with comprehensive type annotations
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### From Source
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Clone the repository
|
|
26
|
+
git clone https://github.com/tboy1337/PR2MD.git
|
|
27
|
+
cd PR2MD
|
|
28
|
+
|
|
29
|
+
# Install dependencies
|
|
30
|
+
pip install -r requirements.txt
|
|
31
|
+
|
|
32
|
+
# Install the package
|
|
33
|
+
pip install -e .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Requirements
|
|
37
|
+
|
|
38
|
+
- Python 3.13 or higher
|
|
39
|
+
- `requests` library (for GitHub API communication)
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Basic Usage
|
|
44
|
+
|
|
45
|
+
Extract a PR using its URL:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pr2md https://github.com/owner/repo/pull/123
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or specify the owner, repository, and PR number separately:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pr2md owner repo 123
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Save to File
|
|
58
|
+
|
|
59
|
+
Output the Markdown to a file instead of stdout:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pr2md https://github.com/owner/repo/pull/123 -o pr-details.md
|
|
63
|
+
pr2md owner repo 123 --output pr-analysis.md
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Verbose Logging
|
|
67
|
+
|
|
68
|
+
Enable detailed logging for debugging:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pr2md https://github.com/owner/repo/pull/123 --verbose
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Help
|
|
75
|
+
|
|
76
|
+
View all available options:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pr2md --help
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Output Format
|
|
83
|
+
|
|
84
|
+
The generated Markdown document includes:
|
|
85
|
+
|
|
86
|
+
### 1. PR Header
|
|
87
|
+
- PR number, title, and status (Open/Closed/Merged)
|
|
88
|
+
- Author information with GitHub profile link
|
|
89
|
+
- Creation, update, closed, and merged timestamps
|
|
90
|
+
- Base and head branch information with commit SHAs
|
|
91
|
+
- Labels (if any)
|
|
92
|
+
|
|
93
|
+
### 2. Description
|
|
94
|
+
- The full PR description/body
|
|
95
|
+
|
|
96
|
+
### 3. Changes Summary
|
|
97
|
+
- Number of files changed
|
|
98
|
+
- Line additions and deletions
|
|
99
|
+
|
|
100
|
+
### 4. Code Diff
|
|
101
|
+
- Complete unified diff of all changes
|
|
102
|
+
- Syntax-highlighted code blocks
|
|
103
|
+
|
|
104
|
+
### 5. Conversation Thread
|
|
105
|
+
- All comments from the PR discussion
|
|
106
|
+
- Chronologically sorted
|
|
107
|
+
- Author attribution and timestamps
|
|
108
|
+
- Links back to GitHub
|
|
109
|
+
|
|
110
|
+
### 6. Reviews
|
|
111
|
+
- All submitted reviews
|
|
112
|
+
- Review state (Approved ✅, Changes Requested 🔴, Commented 💬, etc.)
|
|
113
|
+
- Review comments and timestamps
|
|
114
|
+
|
|
115
|
+
### 7. Review Comments (Code Comments)
|
|
116
|
+
- Inline code review comments
|
|
117
|
+
- Grouped by file
|
|
118
|
+
- Includes code context (diff hunk)
|
|
119
|
+
- Reply chains preserved
|
|
120
|
+
|
|
121
|
+
## Example
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Extract PR #42 from the PR2MD repository
|
|
125
|
+
pr2md tboy1337 PR2MD 42 -o pr-42.md
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
This creates a file `pr-42.md` containing all the PR information in a beautifully formatted Markdown document.
|
|
129
|
+
|
|
130
|
+
## GitHub API Rate Limiting
|
|
131
|
+
|
|
132
|
+
The tool uses the GitHub REST API without authentication by default. GitHub imposes rate limits:
|
|
133
|
+
|
|
134
|
+
- **Unauthenticated requests**: 60 requests per hour
|
|
135
|
+
- **Authenticated requests**: 5,000 requests per hour
|
|
136
|
+
|
|
137
|
+
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.
|
|
138
|
+
|
|
139
|
+
**Future Enhancement**: Authentication support is planned for a future release to enable higher rate limits and access to private repositories.
|
|
140
|
+
|
|
141
|
+
## Development
|
|
142
|
+
|
|
143
|
+
### Setup Development Environment
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Clone the repository
|
|
147
|
+
git clone https://github.com/tboy1337/PR2MD.git
|
|
148
|
+
cd PR2MD
|
|
149
|
+
|
|
150
|
+
# Install development dependencies
|
|
151
|
+
pip install -r requirements-dev.txt
|
|
152
|
+
|
|
153
|
+
# Install the package in editable mode
|
|
154
|
+
pip install -e .
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Running Tests
|
|
158
|
+
|
|
159
|
+
The project includes comprehensive tests using pytest:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Run all tests
|
|
163
|
+
pytest
|
|
164
|
+
|
|
165
|
+
# Run with coverage
|
|
166
|
+
pytest --cov=pr2md --cov-report=html
|
|
167
|
+
|
|
168
|
+
# Run specific test file
|
|
169
|
+
pytest tests/test_cli.py
|
|
170
|
+
|
|
171
|
+
# Run with verbose output
|
|
172
|
+
pytest -v
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Code Quality
|
|
176
|
+
|
|
177
|
+
The project maintains high code quality standards:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Type checking with mypy
|
|
181
|
+
mypy src/pr2md
|
|
182
|
+
|
|
183
|
+
# Linting with pylint
|
|
184
|
+
pylint src/pr2md
|
|
185
|
+
|
|
186
|
+
# Code formatting with black
|
|
187
|
+
black src/pr2md tests
|
|
188
|
+
|
|
189
|
+
# Import sorting with isort
|
|
190
|
+
isort src/pr2md tests
|
|
191
|
+
|
|
192
|
+
# Remove trailing whitespace
|
|
193
|
+
py -m autopep8 --in-place --select=W291,W293 src tests
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Project Structure
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
PR2MD/
|
|
200
|
+
├── src/
|
|
201
|
+
│ └── pr2md/
|
|
202
|
+
│ ├── __init__.py
|
|
203
|
+
│ ├── __main__.py # Entry point
|
|
204
|
+
│ ├── cli.py # Command-line interface
|
|
205
|
+
│ ├── models.py # Data models
|
|
206
|
+
│ ├── pr_extractor.py # GitHub API client
|
|
207
|
+
│ ├── formatter.py # Markdown formatter
|
|
208
|
+
│ └── py.typed # Type checking marker
|
|
209
|
+
├── tests/ # Comprehensive test suite
|
|
210
|
+
├── pyproject.toml # Project configuration
|
|
211
|
+
├── requirements.txt # Runtime dependencies
|
|
212
|
+
├── requirements-dev.txt # Development dependencies
|
|
213
|
+
├── mypy.ini # Type checking configuration
|
|
214
|
+
├── pytest.ini # Test configuration
|
|
215
|
+
└── README.md # This file
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Architecture
|
|
219
|
+
|
|
220
|
+
### Core Components
|
|
221
|
+
|
|
222
|
+
1. **CLI Module** (`cli.py`): Handles command-line argument parsing, logging setup, and orchestrates the extraction and formatting process.
|
|
223
|
+
|
|
224
|
+
2. **PR Extractor** (`pr_extractor.py`): Communicates with the GitHub REST API to fetch PR data, comments, reviews, and diffs. Includes comprehensive error handling.
|
|
225
|
+
|
|
226
|
+
3. **Models** (`models.py`): Type-safe data classes representing GitHub entities (PullRequest, Comment, Review, ReviewComment, User, Label).
|
|
227
|
+
|
|
228
|
+
4. **Formatter** (`formatter.py`): Converts structured PR data into beautifully formatted Markdown with proper sections and syntax highlighting.
|
|
229
|
+
|
|
230
|
+
### Design Principles
|
|
231
|
+
|
|
232
|
+
- **Type Safety**: Full type annotations throughout the codebase
|
|
233
|
+
- **Error Handling**: Graceful handling of API errors and edge cases
|
|
234
|
+
- **Logging**: Comprehensive logging for debugging and monitoring
|
|
235
|
+
- **Testability**: Modular design with clear separation of concerns
|
|
236
|
+
- **Extensibility**: Easy to add new features or output formats
|
|
237
|
+
|
|
238
|
+
## Use Cases
|
|
239
|
+
|
|
240
|
+
- **Code Review Documentation**: Archive code reviews for compliance or historical reference
|
|
241
|
+
- **Offline Analysis**: Review PRs without internet connectivity
|
|
242
|
+
- **Pull Request Templates**: Learn from well-structured PRs
|
|
243
|
+
- **Change Management**: Document significant changes in projects
|
|
244
|
+
- **Training Materials**: Create educational resources from real-world code reviews
|
|
245
|
+
- **Audit Trails**: Maintain records of development decisions
|
|
246
|
+
- **Report Generation**: Include PR details in project reports
|
|
247
|
+
|
|
248
|
+
## Limitations
|
|
249
|
+
|
|
250
|
+
- Currently supports only public GitHub repositories (authentication coming soon)
|
|
251
|
+
- Rate limited by GitHub API (60 requests/hour without authentication)
|
|
252
|
+
- Requires internet connection to fetch data
|
|
253
|
+
- Large PRs with extensive diffs may generate very large Markdown files
|
|
254
|
+
|
|
255
|
+
## Roadmap
|
|
256
|
+
|
|
257
|
+
- [ ] GitHub authentication support (personal access tokens)
|
|
258
|
+
- [ ] Support for GitHub Enterprise
|
|
259
|
+
- [ ] Private repository access
|
|
260
|
+
- [ ] Batch processing of multiple PRs
|
|
261
|
+
- [ ] Custom output templates
|
|
262
|
+
- [ ] Additional output formats (HTML, PDF)
|
|
263
|
+
- [ ] Diff filtering and summarization
|
|
264
|
+
- [ ] PR comparison tool
|
|
265
|
+
- [ ] Integration with CI/CD pipelines
|
|
266
|
+
|
|
267
|
+
## Contributing
|
|
268
|
+
|
|
269
|
+
This project is maintained by tboy1337. Contributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/tboy1337/PR2MD/issues).
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
This project is licensed under the **Commercial Restricted License (CRL) Version 1.1**.
|
|
274
|
+
|
|
275
|
+
**Summary:**
|
|
276
|
+
- ✅ **Free for non-commercial use** (personal, educational, research, open source)
|
|
277
|
+
- ❌ **Commercial use requires a separate commercial license**
|
|
278
|
+
- 📧 Contact the copyright holder for commercial licensing inquiries
|
|
279
|
+
|
|
280
|
+
See the [LICENSE.md](LICENSE.md) file for the complete license text.
|
|
281
|
+
|
|
282
|
+
## Author
|
|
283
|
+
|
|
284
|
+
**tboy1337**
|
|
285
|
+
- GitHub: [@tboy1337](https://github.com/tboy1337)
|
|
286
|
+
|
|
287
|
+
## Acknowledgments
|
|
288
|
+
|
|
289
|
+
- Built with Python 3.13+
|
|
290
|
+
- Uses the [GitHub REST API](https://docs.github.com/en/rest)
|
|
291
|
+
- Inspired by the need for better PR documentation tools
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
**Made with ❤️ for the developer community**
|
|
296
|
+
|