codeannex 0.3.7__tar.gz → 0.4.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.
Files changed (25) hide show
  1. {codeannex-0.3.7 → codeannex-0.4.1}/PKG-INFO +16 -14
  2. {codeannex-0.3.7 → codeannex-0.4.1}/README.md +15 -13
  3. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/__main__.py +5 -10
  4. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/core/config.py +1 -1
  5. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/core/pdf_builder.py +22 -11
  6. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/io/git_utils.py +2 -2
  7. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex.egg-info/PKG-INFO +16 -14
  8. {codeannex-0.3.7 → codeannex-0.4.1}/pyproject.toml +1 -1
  9. {codeannex-0.3.7 → codeannex-0.4.1}/LICENSE +0 -0
  10. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/__init__.py +0 -0
  11. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/core/__init__.py +0 -0
  12. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/interface/__init__.py +0 -0
  13. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/interface/cli.py +0 -0
  14. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/io/__init__.py +0 -0
  15. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/io/file_utils.py +0 -0
  16. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/renderer/__init__.py +0 -0
  17. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/renderer/fonts.py +0 -0
  18. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/renderer/highlight.py +0 -0
  19. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex/renderer/text_utils.py +0 -0
  20. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex.egg-info/SOURCES.txt +0 -0
  21. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex.egg-info/dependency_links.txt +0 -0
  22. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex.egg-info/entry_points.txt +0 -0
  23. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex.egg-info/requires.txt +0 -0
  24. {codeannex-0.3.7 → codeannex-0.4.1}/codeannex.egg-info/top_level.txt +0 -0
  25. {codeannex-0.3.7 → codeannex-0.4.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codeannex
3
- Version: 0.3.7
3
+ Version: 0.4.1
4
4
  Summary: Generates a professional PDF source code annex with Smart Index, Images and Emoji support.
5
5
  License: MIT
6
6
  Project-URL: Repository, https://github.com/tanhleno/codeannex
@@ -31,22 +31,22 @@ Dynamic: license-file
31
31
 
32
32
  # 📂 codeannex
33
33
 
34
- Generates a professional PDF annex from a project's source code — with syntax highlighting, a hierarchical table of contents, image rendering, and intelligent font discovery.
34
+ Generates a professional PDF annex from a project's source code — featuring syntax highlighting, a hierarchical table of contents, image rendering, and version tracking.
35
35
 
36
36
  ## 🚀 Key Features
37
37
 
38
- - **Interactive Wizard 2.0** — Organized by sections (Project, Style, Typography, Layout, Filters) with smart defaults and explicit (Y/n) prompts.
39
- - **Git Integration & Version Tracking** — Automatically detects Repository URL, Branch, and **Commit SHA**. Supports subdirectories by intelligently ignoring Git metadata if not at the root.
40
- - **Subdirectories First** — Improved document organization by listing subdirectories and their contents before root files.
38
+ - **Interactive Wizard 2.0** — Step-by-step configuration with smart sections (Project, Style, Typography, Layout, Filters) and explicit default prompts.
39
+ - **Git Version Tracking** — Automatically detects **Repository URL**, **Branch**, and **Commit SHA**. Smart root detection avoids Git metadata on subdirectories.
40
+ - **Smart SVG Rendering** — Files are rendered as both a high-quality image and XML code. Entries are intelligently deduplicated in the summary.
41
+ - **Improved Document Structure** — Subdirectories and their contents are listed before root files for better organization.
42
+ - **High-Contrast Design** — Redesigned cover page, thickened image frames, and optimized line number legibility.
43
+ - **Intelligent Font Discovery** — Automatically finds fonts from your system or custom directories via `--font-path`.
41
44
  - **Flexible File Filtering** — Multi-pattern include and exclude glob filters (e.g., `--include "src/*" --exclude "tests/*"`).
42
- - **Intelligent Font Discovery** — Automatically finds fonts from your system (Windows, Linux, macOS) or custom paths via `--font-path`.
43
- - **Fully Customizable UI** — Control everything: paper size (mm), margins (cm), colors (HEX), and font sizes.
44
- - **Hierarchical Summary** — Real tree-structured Table of Contents with increasing page numbers and terminal-like connection lines.
45
- - **Professional Design** — High-contrast line numbers, clean cover page, and smart contrast (auto-switching text between black/white based on accent brightness).
45
+ - **Pro-Level UI** — Control paper size (mm), margins (cm), accent colors (HEX), and font sizes.
46
46
 
47
47
  ## 🛠 Installation
48
48
 
49
- The recommended way to install **codeannex** is via [pipx](https://github.com/pypa/pipx), which installs the tool in an isolated environment:
49
+ The recommended way to install **codeannex** is via [pipx](https://github.com/pypa/pipx):
50
50
 
51
51
  ```bash
52
52
  pipx install codeannex
@@ -63,7 +63,7 @@ pipx install "codeannex[svg]"
63
63
  ## 📖 Usage
64
64
 
65
65
  ### Interactive Mode (Wizard)
66
- Simply run without arguments to start the step-by-step configuration:
66
+ Simply run without arguments to start the configuration:
67
67
  ```bash
68
68
  python3 -m codeannex
69
69
  ```
@@ -79,13 +79,15 @@ python3 -m codeannex . \
79
79
  --no-input
80
80
  ```
81
81
 
82
+ Default output filename is `{project_name}_code_annex.pdf`.
83
+
82
84
  ## ⚙️ Configuration Options
83
85
 
84
86
  ### Git & Metadata
85
87
  - `--repo-url URL` — Manual repository URL.
86
88
  - `--branch NAME` — Manual branch name.
87
89
  - `--no-git` — Force disable Git integration.
88
- - `--repo-label LABEL` — Label for repo (default: "Repository Name: ").
90
+ - `--repo-label LABEL` — Label for repo (default: "Repository: ").
89
91
 
90
92
  ### File Selection
91
93
  - `--include PATTERN` — Include glob pattern (can be used multiple times).
@@ -94,7 +96,7 @@ python3 -m codeannex . \
94
96
  ### Design & Layout
95
97
  - `--page-width MM` / `--page-height MM` — Custom paper size in mm (default: A4).
96
98
  - `--margin CM` — General margin (top, bottom, left, right).
97
- - `--primary-color HEX` — Accent color for headers and summary icons.
99
+ - `--primary-color HEX` — Accent color for headers, summary icons, and links.
98
100
  - `--code-size N` — Font size for code and line numbers.
99
101
 
100
102
  ### Fonts
@@ -104,7 +106,7 @@ python3 -m codeannex . \
104
106
  ## 🧪 Testing
105
107
 
106
108
  ```bash
107
- PYTHONPATH=. pytest
109
+ PYTHONPATH=. pytest tests --cov=codeannex
108
110
  ```
109
111
 
110
112
  ## 📄 License
@@ -1,21 +1,21 @@
1
1
  # 📂 codeannex
2
2
 
3
- Generates a professional PDF annex from a project's source code — with syntax highlighting, a hierarchical table of contents, image rendering, and intelligent font discovery.
3
+ Generates a professional PDF annex from a project's source code — featuring syntax highlighting, a hierarchical table of contents, image rendering, and version tracking.
4
4
 
5
5
  ## 🚀 Key Features
6
6
 
7
- - **Interactive Wizard 2.0** — Organized by sections (Project, Style, Typography, Layout, Filters) with smart defaults and explicit (Y/n) prompts.
8
- - **Git Integration & Version Tracking** — Automatically detects Repository URL, Branch, and **Commit SHA**. Supports subdirectories by intelligently ignoring Git metadata if not at the root.
9
- - **Subdirectories First** — Improved document organization by listing subdirectories and their contents before root files.
7
+ - **Interactive Wizard 2.0** — Step-by-step configuration with smart sections (Project, Style, Typography, Layout, Filters) and explicit default prompts.
8
+ - **Git Version Tracking** — Automatically detects **Repository URL**, **Branch**, and **Commit SHA**. Smart root detection avoids Git metadata on subdirectories.
9
+ - **Smart SVG Rendering** — Files are rendered as both a high-quality image and XML code. Entries are intelligently deduplicated in the summary.
10
+ - **Improved Document Structure** — Subdirectories and their contents are listed before root files for better organization.
11
+ - **High-Contrast Design** — Redesigned cover page, thickened image frames, and optimized line number legibility.
12
+ - **Intelligent Font Discovery** — Automatically finds fonts from your system or custom directories via `--font-path`.
10
13
  - **Flexible File Filtering** — Multi-pattern include and exclude glob filters (e.g., `--include "src/*" --exclude "tests/*"`).
11
- - **Intelligent Font Discovery** — Automatically finds fonts from your system (Windows, Linux, macOS) or custom paths via `--font-path`.
12
- - **Fully Customizable UI** — Control everything: paper size (mm), margins (cm), colors (HEX), and font sizes.
13
- - **Hierarchical Summary** — Real tree-structured Table of Contents with increasing page numbers and terminal-like connection lines.
14
- - **Professional Design** — High-contrast line numbers, clean cover page, and smart contrast (auto-switching text between black/white based on accent brightness).
14
+ - **Pro-Level UI** — Control paper size (mm), margins (cm), accent colors (HEX), and font sizes.
15
15
 
16
16
  ## 🛠 Installation
17
17
 
18
- The recommended way to install **codeannex** is via [pipx](https://github.com/pypa/pipx), which installs the tool in an isolated environment:
18
+ The recommended way to install **codeannex** is via [pipx](https://github.com/pypa/pipx):
19
19
 
20
20
  ```bash
21
21
  pipx install codeannex
@@ -32,7 +32,7 @@ pipx install "codeannex[svg]"
32
32
  ## 📖 Usage
33
33
 
34
34
  ### Interactive Mode (Wizard)
35
- Simply run without arguments to start the step-by-step configuration:
35
+ Simply run without arguments to start the configuration:
36
36
  ```bash
37
37
  python3 -m codeannex
38
38
  ```
@@ -48,13 +48,15 @@ python3 -m codeannex . \
48
48
  --no-input
49
49
  ```
50
50
 
51
+ Default output filename is `{project_name}_code_annex.pdf`.
52
+
51
53
  ## ⚙️ Configuration Options
52
54
 
53
55
  ### Git & Metadata
54
56
  - `--repo-url URL` — Manual repository URL.
55
57
  - `--branch NAME` — Manual branch name.
56
58
  - `--no-git` — Force disable Git integration.
57
- - `--repo-label LABEL` — Label for repo (default: "Repository Name: ").
59
+ - `--repo-label LABEL` — Label for repo (default: "Repository: ").
58
60
 
59
61
  ### File Selection
60
62
  - `--include PATTERN` — Include glob pattern (can be used multiple times).
@@ -63,7 +65,7 @@ python3 -m codeannex . \
63
65
  ### Design & Layout
64
66
  - `--page-width MM` / `--page-height MM` — Custom paper size in mm (default: A4).
65
67
  - `--margin CM` — General margin (top, bottom, left, right).
66
- - `--primary-color HEX` — Accent color for headers and summary icons.
68
+ - `--primary-color HEX` — Accent color for headers, summary icons, and links.
67
69
  - `--code-size N` — Font size for code and line numbers.
68
70
 
69
71
  ### Fonts
@@ -73,7 +75,7 @@ python3 -m codeannex . \
73
75
  ## 🧪 Testing
74
76
 
75
77
  ```bash
76
- PYTHONPATH=. pytest
78
+ PYTHONPATH=. pytest tests --cov=codeannex
77
79
  ```
78
80
 
79
81
  ## 📄 License
@@ -106,20 +106,15 @@ def main():
106
106
  )
107
107
 
108
108
  all_files = sort_files(get_project_files(root, includes=args.include, excludes=args.exclude, use_git=use_git), root)
109
-
110
- # Early Filter: Remove the output file and the script itself from processing
111
- def is_self_or_output(fp):
112
- try:
113
- res = fp.resolve()
114
- return res == output_path or res == script_path
115
- except: return False
116
-
117
- all_files = [fp for fp in all_files if not is_self_or_output(fp)]
118
-
119
109
  included = []
120
110
  from .core.config import IMAGE_EXTENSIONS, BINARY_EXTENSIONS
121
111
 
122
112
  for fp in all_files:
113
+ # We only silently skip the script itself to avoid infinite recursion if it's in the same folder
114
+ try:
115
+ if fp.resolve() == script_path: continue
116
+ except: pass
117
+
123
118
  if not fp.is_file(): continue
124
119
 
125
120
  ext = fp.suffix.lower()
@@ -72,7 +72,7 @@ class PDFConfig:
72
72
  page_bg_color: str = "#ffffff"
73
73
 
74
74
  summary_title: str = "Summary / File Index"
75
- repo_label: str = "Repository Name: "
75
+ repo_label: str = "Repository: "
76
76
  project_label: str = "Project: "
77
77
  file_part_format: str = "(part {current}/{total})"
78
78
 
@@ -55,12 +55,12 @@ class ModernAnnexPDF:
55
55
  self.c.setTitle(f"Source code: {project_name}")
56
56
 
57
57
  def _dtf(self, x, y, text, font, size, color=None):
58
- draw_text_with_fallback(self.c, x, y, text, font, size, self.emoji_font, color,
59
- emoji_description=self.config.emoji_description)
58
+ return draw_text_with_fallback(self.c, x, y, text, font, size, self.emoji_font, color,
59
+ emoji_description=self.config.emoji_description)
60
60
 
61
61
  def _dctf(self, x, y, text, font, size, color=None):
62
- draw_centred_text_with_fallback(self.c, x, y, text, font, size, self.emoji_font, color,
63
- emoji_description=self.config.emoji_description)
62
+ return draw_centred_text_with_fallback(self.c, x, y, text, font, size, self.emoji_font, color,
63
+ emoji_description=self.config.emoji_description)
64
64
 
65
65
  def _gsw(self, text, font, size) -> float:
66
66
  return get_safe_string_width(text, font, size, self.emoji_font,
@@ -133,16 +133,27 @@ class ModernAnnexPDF:
133
133
  curr_y = self.config.page_height * 0.45
134
134
 
135
135
  if project_name:
136
- display_repo = f"{self.config.repo_label}{project_name}"
137
- name_w = self._gsw(display_repo, self.config.normal_font, 14)
138
- start_x = mid_x - name_w / 2
136
+ label = self.config.repo_label
137
+ name = project_name
139
138
 
140
- # Draw the name (blue if it has a link)
141
- final_color = colors.HexColor(self.config.primary_color) if self.config.repo_url else text_color
142
- self._dtf(start_x, curr_y, display_repo, self.config.normal_font, 14, final_color)
139
+ # Calculate total block width for initial centering
140
+ label_w = self._gsw(label, self.config.normal_font, 14)
141
+ name_w = self._gsw(name, self.config.normal_font, 14)
142
+ total_w = label_w + name_w
143
143
 
144
+ start_x = mid_x - total_w / 2
145
+
146
+ # 1. Draw the label and capture EXACT end position
147
+ name_x = self._dtf(start_x, curr_y, label, self.config.normal_font, 14, text_color)
148
+
149
+ # 2. Draw the name starting exactly where label ended
150
+ final_name_color = colors.HexColor(self.config.primary_color) if self.config.repo_url else text_color
151
+ end_x = self._dtf(name_x, curr_y, name, self.config.normal_font, 14, final_name_color)
152
+
153
+ # 3. Apply link using the real coordinates
144
154
  if self.config.repo_url:
145
- self.c.linkURL(self.config.repo_url, (start_x, curr_y - 2, start_x + name_w, curr_y + 12), relative=0, thickness=0, border=None)
155
+ # Coordinates are (x1, y1, x2, y2)
156
+ self.c.linkURL(self.config.repo_url, (name_x, curr_y - 2, end_x, curr_y + 12), relative=0, thickness=0, border=None)
146
157
 
147
158
  curr_y -= 8*mm
148
159
 
@@ -31,8 +31,8 @@ def get_git_info(root: Path, use_git: bool = True) -> tuple[str | None, str | No
31
31
  branch_name = res_branch.stdout.strip()
32
32
  if branch_name == "HEAD": branch_name = None
33
33
 
34
- # 3. Get commit SHA (short)
35
- res_sha = subprocess.run(["git", "rev-parse", "--short", "HEAD"], cwd=root, capture_output=True, text=True)
34
+ # 3. Get commit SHA (8 chars)
35
+ res_sha = subprocess.run(["git", "rev-parse", "--short=8", "HEAD"], cwd=root, capture_output=True, text=True)
36
36
  if res_sha.returncode == 0: commit_sha = res_sha.stdout.strip()
37
37
 
38
38
  except (subprocess.CalledProcessError, FileNotFoundError): pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codeannex
3
- Version: 0.3.7
3
+ Version: 0.4.1
4
4
  Summary: Generates a professional PDF source code annex with Smart Index, Images and Emoji support.
5
5
  License: MIT
6
6
  Project-URL: Repository, https://github.com/tanhleno/codeannex
@@ -31,22 +31,22 @@ Dynamic: license-file
31
31
 
32
32
  # 📂 codeannex
33
33
 
34
- Generates a professional PDF annex from a project's source code — with syntax highlighting, a hierarchical table of contents, image rendering, and intelligent font discovery.
34
+ Generates a professional PDF annex from a project's source code — featuring syntax highlighting, a hierarchical table of contents, image rendering, and version tracking.
35
35
 
36
36
  ## 🚀 Key Features
37
37
 
38
- - **Interactive Wizard 2.0** — Organized by sections (Project, Style, Typography, Layout, Filters) with smart defaults and explicit (Y/n) prompts.
39
- - **Git Integration & Version Tracking** — Automatically detects Repository URL, Branch, and **Commit SHA**. Supports subdirectories by intelligently ignoring Git metadata if not at the root.
40
- - **Subdirectories First** — Improved document organization by listing subdirectories and their contents before root files.
38
+ - **Interactive Wizard 2.0** — Step-by-step configuration with smart sections (Project, Style, Typography, Layout, Filters) and explicit default prompts.
39
+ - **Git Version Tracking** — Automatically detects **Repository URL**, **Branch**, and **Commit SHA**. Smart root detection avoids Git metadata on subdirectories.
40
+ - **Smart SVG Rendering** — Files are rendered as both a high-quality image and XML code. Entries are intelligently deduplicated in the summary.
41
+ - **Improved Document Structure** — Subdirectories and their contents are listed before root files for better organization.
42
+ - **High-Contrast Design** — Redesigned cover page, thickened image frames, and optimized line number legibility.
43
+ - **Intelligent Font Discovery** — Automatically finds fonts from your system or custom directories via `--font-path`.
41
44
  - **Flexible File Filtering** — Multi-pattern include and exclude glob filters (e.g., `--include "src/*" --exclude "tests/*"`).
42
- - **Intelligent Font Discovery** — Automatically finds fonts from your system (Windows, Linux, macOS) or custom paths via `--font-path`.
43
- - **Fully Customizable UI** — Control everything: paper size (mm), margins (cm), colors (HEX), and font sizes.
44
- - **Hierarchical Summary** — Real tree-structured Table of Contents with increasing page numbers and terminal-like connection lines.
45
- - **Professional Design** — High-contrast line numbers, clean cover page, and smart contrast (auto-switching text between black/white based on accent brightness).
45
+ - **Pro-Level UI** — Control paper size (mm), margins (cm), accent colors (HEX), and font sizes.
46
46
 
47
47
  ## 🛠 Installation
48
48
 
49
- The recommended way to install **codeannex** is via [pipx](https://github.com/pypa/pipx), which installs the tool in an isolated environment:
49
+ The recommended way to install **codeannex** is via [pipx](https://github.com/pypa/pipx):
50
50
 
51
51
  ```bash
52
52
  pipx install codeannex
@@ -63,7 +63,7 @@ pipx install "codeannex[svg]"
63
63
  ## 📖 Usage
64
64
 
65
65
  ### Interactive Mode (Wizard)
66
- Simply run without arguments to start the step-by-step configuration:
66
+ Simply run without arguments to start the configuration:
67
67
  ```bash
68
68
  python3 -m codeannex
69
69
  ```
@@ -79,13 +79,15 @@ python3 -m codeannex . \
79
79
  --no-input
80
80
  ```
81
81
 
82
+ Default output filename is `{project_name}_code_annex.pdf`.
83
+
82
84
  ## ⚙️ Configuration Options
83
85
 
84
86
  ### Git & Metadata
85
87
  - `--repo-url URL` — Manual repository URL.
86
88
  - `--branch NAME` — Manual branch name.
87
89
  - `--no-git` — Force disable Git integration.
88
- - `--repo-label LABEL` — Label for repo (default: "Repository Name: ").
90
+ - `--repo-label LABEL` — Label for repo (default: "Repository: ").
89
91
 
90
92
  ### File Selection
91
93
  - `--include PATTERN` — Include glob pattern (can be used multiple times).
@@ -94,7 +96,7 @@ python3 -m codeannex . \
94
96
  ### Design & Layout
95
97
  - `--page-width MM` / `--page-height MM` — Custom paper size in mm (default: A4).
96
98
  - `--margin CM` — General margin (top, bottom, left, right).
97
- - `--primary-color HEX` — Accent color for headers and summary icons.
99
+ - `--primary-color HEX` — Accent color for headers, summary icons, and links.
98
100
  - `--code-size N` — Font size for code and line numbers.
99
101
 
100
102
  ### Fonts
@@ -104,7 +106,7 @@ python3 -m codeannex . \
104
106
  ## 🧪 Testing
105
107
 
106
108
  ```bash
107
- PYTHONPATH=. pytest
109
+ PYTHONPATH=. pytest tests --cov=codeannex
108
110
  ```
109
111
 
110
112
  ## 📄 License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "codeannex"
7
- version = "0.3.7"
7
+ version = "0.4.1"
8
8
  description = "Generates a professional PDF source code annex with Smart Index, Images and Emoji support."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
File without changes
File without changes