Skip to content

Commit 0262b66

Browse files
committed
chore: remove obsolete issue template and PdfPage.cs; add benchmark and analysis scripts
1 parent ea823be commit 0262b66

11 files changed

Lines changed: 31 additions & 83 deletions

File tree

.github_issue_body.md

Lines changed: 0 additions & 62 deletions
This file was deleted.

PdfPage.cs

Whitespace-only changes.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,7 @@ All test cases comparing MiniPdf output vs LibreOffice reference. Page 1 shown f
10371037

10381038

10391039

1040+
10401041
## License
10411042

10421043
This project is licensed under the [Apache License 2.0](LICENSE).
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
It installs Python dependencies, runs all steps, and opens the final report.
88
99
.EXAMPLE
10-
.\Run-Benchmark.ps1
11-
.\Run-Benchmark.ps1 -CompareOnly
12-
.\Run-Benchmark.ps1 -SkipReference
10+
.\scripts\Run-Benchmark.ps1
11+
.\scripts\Run-Benchmark.ps1 -CompareOnly
12+
.\scripts\Run-Benchmark.ps1 -SkipReference
1313
#>
1414

1515
param(
@@ -21,8 +21,8 @@ param(
2121
)
2222

2323
$ErrorActionPreference = "Continue"
24-
$ScriptRoot = $PSScriptRoot
25-
$BenchmarkDir = Join-Path $ScriptRoot "tests" "MiniPdf.Benchmark"
24+
$ScriptRoot = Split-Path -Parent $PSScriptRoot
25+
$BenchmarkDir = Join-Path (Join-Path $ScriptRoot "tests") "MiniPdf.Benchmark"
2626

2727
Write-Host "`n============================================================" -ForegroundColor Cyan
2828
Write-Host " MiniPdf Self-Evolution Benchmark Pipeline" -ForegroundColor Cyan
@@ -56,7 +56,7 @@ try {
5656
}
5757

5858
# Open the report if it exists
59-
$reportPath = Join-Path $BenchmarkDir "reports" "comparison_report.md"
59+
$reportPath = Join-Path (Join-Path $BenchmarkDir "reports") "comparison_report.md"
6060
if (Test-Path $reportPath) {
6161
Write-Host "`n[Done] Report: $reportPath" -ForegroundColor Green
6262
Write-Host "Opening report..." -ForegroundColor Cyan
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import zipfile, re, os, sys
44
sys.stdout.reconfigure(encoding='utf-8')
55

6-
output_dir = r'd:\git\MiniPdf\tests\MiniPdf.Scripts\output'
6+
_script_dir = os.path.dirname(os.path.abspath(__file__))
7+
_repo_root = os.path.dirname(_script_dir)
8+
output_dir = os.path.join(_repo_root, 'tests', 'MiniPdf.Scripts', 'output')
79

810
def analyze_xlsx(xlsx_path):
911
with zipfile.ZipFile(xlsx_path) as z:

analyze_xlsx.py renamed to scripts/analyze_xlsx.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"""Analyze xlsx files to understand column width requirements."""
33
import zipfile, re, os, sys
44

5-
output_dir = r'd:\git\MiniPdf\tests\MiniPdf.Scripts\output'
5+
_script_dir = os.path.dirname(os.path.abspath(__file__))
6+
_repo_root = os.path.dirname(_script_dir)
7+
output_dir = os.path.join(_repo_root, 'tests', 'MiniPdf.Scripts', 'output')
68

79
def get_col_content_widths(xlsx_path):
810
"""Get max content length per column and SheetFormatPr info."""
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#!/usr/bin/env python3
22
"""Extract text from reference PDFs to understand what LibreOffice renders."""
33
import os, sys
4-
sys.path.insert(0, r'd:\git\MiniPdf\tests\MiniPdf.Benchmark')
4+
_script_dir = os.path.dirname(os.path.abspath(__file__))
5+
_repo_root = os.path.dirname(_script_dir)
6+
sys.path.insert(0, os.path.join(_repo_root, 'tests', 'MiniPdf.Benchmark'))
57

68
try:
79
import fitz # pymupdf
810
except ImportError:
911
print("pymupdf not installed")
1012
sys.exit(1)
1113

12-
ref_dir = r'd:\git\MiniPdf\tests\MiniPdf.Benchmark\reference_pdfs'
14+
ref_dir = os.path.join(_repo_root, 'tests', 'MiniPdf.Benchmark', 'reference_pdfs')
1315

1416
tests = [
1517
('classic35_explicit_row_heights', ['Tall Header', 'Tall HeadeValue', 'Tall Heade']),

fix_code.py renamed to scripts/fix_code.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env python3
22
"""Apply targeted fixes to MiniPdf source files."""
3-
import re
3+
import os, re
4+
5+
_script_dir = os.path.dirname(os.path.abspath(__file__))
6+
_repo_root = os.path.dirname(_script_dir)
47

58
def fix_file(path, old, new, expect_found=True):
69
with open(path, encoding='utf-8') as f:
@@ -19,7 +22,7 @@ def fix_file(path, old, new, expect_found=True):
1922

2023
# ── 1. PdfWriter.cs: en/em-dash -> WinAnsiEncoding bytes ─────────────────────
2124
fix_file(
22-
'src/MiniPdf/PdfWriter.cs',
25+
os.path.join(_repo_root, 'src/MiniPdf/PdfWriter.cs'),
2326
r"'\u2013' or '\u2014' or '\u2012' => '-', // en-dash, em-dash",
2427
r"'\u2013' or '\u2012' => (char)0x96, // en-dash -> WinAnsiEncoding 0x96" + "\n" +
2528
r" '\u2014' => (char)0x97, // em-dash -> WinAnsiEncoding 0x97"
@@ -39,6 +42,6 @@ def fix_file(path, old, new, expect_found=True):
3942
var clipped = cellText.Length > maxChars ? cellText[..maxChars] : cellText;
4043
cellLines[i] = new[] { clipped };"""
4144

42-
fix_file('src/MiniPdf/ExcelToPdfConverter.cs', old_wrap, new_clip)
45+
fix_file(os.path.join(_repo_root, 'src/MiniPdf/ExcelToPdfConverter.cs'), old_wrap, new_clip)
4346

4447
print("All done.")
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
Uses comparison_report.json to get scores and image filenames (page 1 only).
66
77
Usage:
8-
python update_readme_images.py
8+
python scripts/update_readme_images.py
99
"""
1010

1111
import json
1212
import re
1313
from pathlib import Path
1414

15-
REPO_ROOT = Path(__file__).parent
15+
REPO_ROOT = Path(__file__).parent.parent
1616
README_PATH = REPO_ROOT / "README.md"
1717
REPORT_JSON = REPO_ROOT / "tests/MiniPdf.Benchmark/reports/comparison_report.json"
1818
IMAGE_DIR_REL = "tests/MiniPdf.Benchmark/reports/images"

tests/MiniPdf.Benchmark/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Automatically compares PDFs generated by MiniPdf against LibreOffice (reference
77
```
88
┌─────────────────────────────────────────────────────────────┐
99
│ run_benchmark.py (orchestrator) │
10-
│ Run-Benchmark.ps1 (one-click entry point) │
10+
scripts/Run-Benchmark.ps1 (one-click entry point) │
1111
├─────────────────────────────────────────────────────────────┤
1212
│ │
1313
│ Step 1: generate_classic_xlsx.py │
@@ -54,7 +54,7 @@ pip install openpyxl pymupdf
5454

5555
```powershell
5656
# Windows PowerShell
57-
.\Run-Benchmark.ps1
57+
.\scripts\Run-Benchmark.ps1
5858
5959
# Or run directly with Python
6060
cd tests/MiniPdf.Benchmark
@@ -202,7 +202,7 @@ When using an AI assistant (e.g., GitHub Copilot), follow this workflow:
202202

203203
1. **Run the Benchmark**:
204204
```
205-
.\Run-Benchmark.ps1
205+
.\scripts\Run-Benchmark.ps1
206206
```
207207

208208
2. **Feed the report to the AI**:
@@ -214,7 +214,7 @@ When using an AI assistant (e.g., GitHub Copilot), follow this workflow:
214214

215215
3. **Re-validate after AI makes changes**:
216216
```
217-
.\Run-Benchmark.ps1 --SkipGenerate --SkipReference
217+
.\scripts\Run-Benchmark.ps1 --SkipGenerate --SkipReference
218218
```
219219

220220
4. **Iterate until all scores ≥ 0.9**.
@@ -254,5 +254,5 @@ tests/
254254
│ │ └── images/ # Per-page rendering comparisons
255255
│ └── README.md # This document
256256
257-
Run-Benchmark.ps1 # Windows one-click entry point
257+
scripts/Run-Benchmark.ps1 # Windows one-click entry point
258258
```

0 commit comments

Comments
 (0)