wexample-wex-addon-dev-python 0.0.47__py3-none-any.whl → 0.0.49__py3-none-any.whl

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 (20) hide show
  1. wexample_wex_addon_dev_python/__pycache__/__init__.py +0 -0
  2. wexample_wex_addon_dev_python/commands/code/check.py +1 -0
  3. wexample_wex_addon_dev_python/config_value/__pycache__/__init__.py +0 -0
  4. wexample_wex_addon_dev_python/config_value/python_package_readme_config_value.py +186 -35
  5. wexample_wex_addon_dev_python/const/__pycache__/__init__.py +0 -0
  6. wexample_wex_addon_dev_python/file/__pycache__/__init__.py +0 -0
  7. wexample_wex_addon_dev_python/file/python_package_toml_file.py +248 -152
  8. wexample_wex_addon_dev_python/middleware/__pycache__/__init__.py +0 -0
  9. wexample_wex_addon_dev_python/resources/__init__.py +0 -0
  10. wexample_wex_addon_dev_python/resources/readme_templates/__init__.py +0 -0
  11. wexample_wex_addon_dev_python/resources/readme_templates/title.md.j2 +5 -0
  12. wexample_wex_addon_dev_python/workdir/__pycache__/__init__.py +0 -0
  13. wexample_wex_addon_dev_python/workdir/python_package_workdir.py +228 -59
  14. wexample_wex_addon_dev_python/workdir/python_packages_suite_workdir.py +26 -13
  15. wexample_wex_addon_dev_python/workdir/python_workdir.py +129 -61
  16. wexample_wex_addon_dev_python-0.0.49.dist-info/METADATA +143 -0
  17. {wexample_wex_addon_dev_python-0.0.47.dist-info → wexample_wex_addon_dev_python-0.0.49.dist-info}/RECORD +19 -10
  18. wexample_wex_addon_dev_python-0.0.47.dist-info/METADATA +0 -60
  19. {wexample_wex_addon_dev_python-0.0.47.dist-info → wexample_wex_addon_dev_python-0.0.49.dist-info}/WHEEL +0 -0
  20. {wexample_wex_addon_dev_python-0.0.47.dist-info → wexample_wex_addon_dev_python-0.0.49.dist-info}/entry_points.txt +0 -0
File without changes
@@ -44,6 +44,7 @@ def python__code__check(
44
44
  ) -> bool:
45
45
  """Check a Python file using various code quality tools."""
46
46
  from wexample_app.response.failure_response import FailureResponse
47
+
47
48
  from wexample_wex_addon_dev_python.commands.code.check.mypy import _code_check_mypy
48
49
  from wexample_wex_addon_dev_python.commands.code.check.pylint import (
49
50
  _code_check_pylint,
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- import os
4
3
  from typing import TYPE_CHECKING
5
4
 
6
5
  from wexample_filestate.config_value.readme_content_config_value import (
@@ -8,9 +7,6 @@ from wexample_filestate.config_value.readme_content_config_value import (
8
7
  )
9
8
  from wexample_helpers.classes.field import public_field
10
9
  from wexample_helpers.decorator.base_class import base_class
11
- from wexample_wex_addon_dev_python.workdir.python_package_workdir import (
12
- PythonPackageWorkdir,
13
- )
14
10
 
15
11
  if TYPE_CHECKING:
16
12
  from wexample_wex_addon_dev_python.workdir.python_package_workdir import (
@@ -49,44 +45,199 @@ class PythonPackageReadmeContentConfigValue(ReadmeContentConfigValue):
49
45
  # Format dependencies list
50
46
  deps_list = "\n".join([f"- {dep}" for dep in dependencies])
51
47
 
52
- package_name = self.workdir.get_package_name()
53
- return [
54
- f"# {package_name}\n\n"
55
- f"{description}\n\n"
56
- f"Version: {self.workdir.get_project_version()}\n\n"
57
- f'{self._add_section_if_exists("features")}'
58
- "## Requirements\n\n"
59
- f"- Python {python_version}\n\n"
60
- "## Dependencies\n\n"
61
- f"{deps_list}\n\n"
62
- "## Installation\n\n"
63
- "```bash\n"
64
- f"pip install {package_name}\n"
65
- "```\n\n"
66
- f'{self._add_section_if_exists("usage")}'
67
- "## Links\n\n"
68
- f"- Homepage: {homepage}\n\n"
69
- "## License\n\n"
70
- f"{license_info}"
48
+ # Prepare context for Jinja2 rendering
49
+ context = {
50
+ "package_name": self.workdir.get_package_name(),
51
+ "version": self.workdir.get_project_version(),
52
+ "description": description,
53
+ "python_version": python_version,
54
+ "dependencies": dependencies,
55
+ "deps_list": deps_list,
56
+ "homepage": homepage,
57
+ "license_info": license_info,
58
+ }
59
+
60
+ # Define fixed order of README sections
61
+ section_names = [
62
+ "title",
63
+ "table-of-contents",
64
+ "status-compatibility",
65
+ "prerequisites",
66
+ "installation",
67
+ "quickstart",
68
+ "basic-usage",
69
+ "configuration",
70
+ "logging",
71
+ "api-reference",
72
+ "examples",
73
+ "tests",
74
+ "code-quality",
75
+ "versioning",
76
+ "changelog",
77
+ "migration-notes",
78
+ "roadmap",
79
+ "troubleshooting",
80
+ "security",
81
+ "privacy",
82
+ "support",
83
+ "contribution-guidelines",
84
+ "maintainers",
85
+ "license",
86
+ "useful-links",
87
+ "suite-integration",
88
+ "compatibility-matrix",
89
+ "requirements",
90
+ "dependencies",
91
+ "links",
92
+ "suite-signature",
71
93
  ]
72
94
 
73
- def _add_section_if_exists(self, section: str) -> str:
95
+ # First pass: collect available sections (excluding title and table-of-contents)
96
+ available_sections = []
97
+ for section_name in section_names:
98
+ if section_name not in ["title", "table-of-contents"]:
99
+ # Check if section exists
100
+ if self._section_exists(section_name):
101
+ available_sections.append(
102
+ {
103
+ "name": section_name,
104
+ "title": self._section_name_to_title(section_name),
105
+ "anchor": section_name.replace("_", "-"),
106
+ }
107
+ )
108
+
109
+ # Add available sections to context for table-of-contents
110
+ context["available_sections"] = available_sections
111
+
112
+ # Render ordered sections (supports both .md and .md.j2)
113
+ rendered_content = ""
114
+ for section_name in section_names:
115
+ section_content = self._render_readme_section(section_name, context)
116
+ if section_content:
117
+ rendered_content += f"{section_content}\n\n"
118
+
119
+ return [rendered_content]
120
+
121
+ def _render_readme_section(self, section_name: str, context: dict) -> str | None:
74
122
  """
75
- Returns section content if the documentation file exists
123
+ Render a README section from .md or .md.j2 file with Jinja2 support.
124
+
125
+ Searches in three levels (in order):
126
+ 1. Package-level templates
127
+ 2. Suite-level templates
128
+ 3. Default templates (bundled with the module)
129
+
130
+ Tries .md.j2 first, then .md. Both formats support Jinja2 variables.
131
+
132
+ Args:
133
+ section_name: Name of the section (without extension)
134
+ context: Jinja2 context variables for rendering
135
+
136
+ Returns:
137
+ Rendered content or None if section file not found
76
138
  """
77
- doc_path = self._get_doc_path(section)
139
+ from pathlib import Path
140
+ from jinja2 import Environment, FileSystemLoader, TemplateNotFound
141
+ from wexample_app.const.globals import WORKDIR_SETUP_DIR
142
+
143
+ workdir_path = self.workdir.get_path()
144
+
145
+ search_paths = [
146
+ workdir_path / WORKDIR_SETUP_DIR / "knowledge" / "readme", # Package-level
147
+ ]
148
+
149
+ # Package may have a suite.
150
+ suite_path = self.workdir.find_suite_workdir_path()
151
+ if suite_path is not None:
152
+ search_paths.append(
153
+ suite_path
154
+ / WORKDIR_SETUP_DIR
155
+ / "knowledge"
156
+ / "package-readme", # Suite-level
157
+ )
158
+
159
+ # Add default templates path (bundled with the module)
160
+ default_templates_path = (
161
+ Path(__file__).parent.parent / "resources" / "readme_templates"
162
+ )
163
+ search_paths.append(default_templates_path)
164
+
165
+ # Try .md.j2 first (Jinja2 template)
166
+ for search_path in search_paths:
167
+ if not search_path.exists():
168
+ continue
78
169
 
79
- if os.path.exists(doc_path):
80
- with open(doc_path, encoding="utf-8") as file:
81
- content = file.read()
82
- return f"## {section.title()}\n\n{content}\n\n"
170
+ env = Environment(loader=FileSystemLoader(str(search_path)))
171
+ try:
172
+ template = env.get_template(f"{section_name}.md.j2")
173
+ return template.render(context)
174
+ except TemplateNotFound:
175
+ pass
83
176
 
84
- return ""
177
+ # Try .md (static markdown, still rendered with Jinja2)
178
+ for search_path in search_paths:
179
+ md_path = search_path / f"{section_name}.md"
180
+ if md_path.exists():
181
+ content = md_path.read_text(encoding="utf-8")
182
+ env = Environment(loader=FileSystemLoader(str(search_path)))
183
+ template = env.from_string(content)
184
+ return template.render(context)
85
185
 
86
- def _get_doc_path(self, section: str) -> str:
186
+ return None
187
+
188
+ def _section_exists(self, section_name: str) -> bool:
87
189
  """
88
- Returns the path to a documentation section file
190
+ Check if a section file exists (.md or .md.j2).
191
+
192
+ Searches in three levels:
193
+ 1. Package-level templates
194
+ 2. Suite-level templates
195
+ 3. Default templates (bundled with the module)
196
+
197
+ Args:
198
+ section_name: Name of the section (without extension)
199
+
200
+ Returns:
201
+ True if section file exists, False otherwise
89
202
  """
90
- return os.path.join(
91
- self.workdir.get_path(), ".wex", "doc", "readme", f"{section}.md"
203
+ from pathlib import Path
204
+ from wexample_app.const.globals import WORKDIR_SETUP_DIR
205
+
206
+ workdir_path = self.workdir.get_path()
207
+
208
+ search_paths = [
209
+ workdir_path / WORKDIR_SETUP_DIR / "knowledge" / "readme",
210
+ ]
211
+
212
+ # Package may have a suite.
213
+ suite_path = self.workdir.find_suite_workdir_path()
214
+ if suite_path is not None:
215
+ search_paths.append(
216
+ suite_path / WORKDIR_SETUP_DIR / "knowledge" / "package-readme",
217
+ )
218
+
219
+ # Add default templates path (bundled with the module)
220
+ default_templates_path = (
221
+ Path(__file__).parent.parent / "resources" / "readme_templates"
92
222
  )
223
+ search_paths.append(default_templates_path)
224
+
225
+ for search_path in search_paths:
226
+ if (search_path / f"{section_name}.md.j2").exists():
227
+ return True
228
+ if (search_path / f"{section_name}.md").exists():
229
+ return True
230
+
231
+ return False
232
+
233
+ def _section_name_to_title(self, section_name: str) -> str:
234
+ """
235
+ Convert section name to human-readable title.
236
+
237
+ Args:
238
+ section_name: Section name (e.g., "basic-usage")
239
+
240
+ Returns:
241
+ Human-readable title (e.g., "Basic Usage")
242
+ """
243
+ return section_name.replace("-", " ").replace("_", " ").title()