wexample-pseudocode 9.4.4__tar.gz → 9.4.6__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 (51) hide show
  1. wexample_pseudocode-9.4.6/PKG-INFO +291 -0
  2. wexample_pseudocode-9.4.6/README.md +272 -0
  3. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/pyproject.toml +3 -3
  4. wexample_pseudocode-9.4.4/tests/resources/__init__.py → wexample_pseudocode-9.4.6/tests/.gitkeep +0 -0
  5. wexample_pseudocode-9.4.6/tests/resources/item/function/__init__.py +0 -0
  6. wexample_pseudocode-9.4.4/PKG-INFO +0 -467
  7. wexample_pseudocode-9.4.4/README.md +0 -448
  8. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/__init__.py +0 -0
  9. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/common/__init__.py +0 -0
  10. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/common/docstring.py +0 -0
  11. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/common/type_normalizer.py +0 -0
  12. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/__init__.py +0 -0
  13. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/class_config.py +0 -0
  14. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/class_method_config.py +0 -0
  15. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/class_property_config.py +0 -0
  16. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/constant_config.py +0 -0
  17. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/doc_comment_config.py +0 -0
  18. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/doc_comment_parameter_config.py +0 -0
  19. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/doc_comment_return_config.py +0 -0
  20. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/function_config.py +0 -0
  21. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/function_parameter_config.py +0 -0
  22. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/generator_config.py +0 -0
  23. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/config/method_parameter_config.py +0 -0
  24. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/generator/__init__.py +0 -0
  25. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/generator/abstract_generator.py +0 -0
  26. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/generator/code_generator.py +0 -0
  27. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/generator/pseudocode_generator.py +0 -0
  28. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/parser/__init__.py +0 -0
  29. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/parser/class_parser.py +0 -0
  30. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/parser/function_parser.py +0 -0
  31. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/parser/module_parser.py +0 -0
  32. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/src/wexample_pseudocode/py.typed +0 -0
  33. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/conftest.py +0 -0
  34. {wexample_pseudocode-9.4.4/tests/resources/item → wexample_pseudocode-9.4.6/tests/resources}/__init__.py +0 -0
  35. {wexample_pseudocode-9.4.4/tests/resources/item/class → wexample_pseudocode-9.4.6/tests/resources/item}/__init__.py +0 -0
  36. {wexample_pseudocode-9.4.4/tests/resources/item/constant → wexample_pseudocode-9.4.6/tests/resources/item/class}/__init__.py +0 -0
  37. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/resources/item/class/basic_calculator.py.txt +0 -0
  38. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/resources/item/class/basic_calculator.yml +0 -0
  39. {wexample_pseudocode-9.4.4/tests/resources/item/function → wexample_pseudocode-9.4.6/tests/resources/item/constant}/__init__.py +0 -0
  40. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/resources/item/constant/constant_using_const.py.txt +0 -0
  41. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/resources/item/constant/constant_using_const.yml +0 -0
  42. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/resources/item/function/basic_function.py.txt +0 -0
  43. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/resources/item/function/basic_function.yml +0 -0
  44. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/resources/item/function/complex_function.py.txt +0 -0
  45. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/resources/item/function/complex_function.yml +0 -0
  46. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/test_class_basic_calculator.py +0 -0
  47. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/test_code_generator_class_basic_calculator.py +0 -0
  48. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/test_code_generator_constant.py +0 -0
  49. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/test_constant_using_const.py +0 -0
  50. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/test_function_items.py +0 -0
  51. {wexample_pseudocode-9.4.4 → wexample_pseudocode-9.4.6}/tests/test_php_yaml_compat.py +0 -0
@@ -0,0 +1,291 @@
1
+ Metadata-Version: 2.1
2
+ Name: wexample-pseudocode
3
+ Version: 9.4.6
4
+ Summary: Converts Python source to a YAML pseudocode schema of its classes, functions, and constants, and regenerates Python code from that schema
5
+ Author-Email: weeger <contact@wexample.com>
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Project-URL: homepage, https://github.com/wexample/python-pseudocode
11
+ Requires-Python: >=3.10
12
+ Requires-Dist: attrs>=23.1.0
13
+ Requires-Dist: cattrs>=23.1.0
14
+ Requires-Dist: wexample-helpers>=20.0.0
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest; extra == "dev"
17
+ Requires-Dist: pytest-cov; extra == "dev"
18
+ Description-Content-Type: text/markdown
19
+
20
+ # pseudocode
21
+
22
+ Version: 9.4.6
23
+
24
+ `wexample-pseudocode` parses Python source files into a YAML schema that describes their classes, functions, and constants, then regenerates Python code from that same schema. It targets Python developers who need a language-neutral intermediate representation of a module's public surface — for documentation, cross-language code generation, or schema-driven scaffolding.
25
+
26
+ ## Table of Contents
27
+
28
+ - [Installation](#installation)
29
+ - [Quickstart](#quickstart)
30
+ - [Tests](#tests)
31
+ - [Architecture](#architecture)
32
+ - [Integration in the Suite](#integration-in-the-suite)
33
+ - [Dependencies](#dependencies)
34
+ - [Versioning & Compatibility Policy](#versioning--compatibility-policy)
35
+ - [License](#license)
36
+ - [About us](#about-us)
37
+ - [Known Limitations & Roadmap](#known-limitations--roadmap)
38
+ - [Status & Compatibility](#status--compatibility)
39
+ - [Useful Links](#useful-links)
40
+ - [Migration Notes](#migration-notes)
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install wexample-pseudocode
46
+ ```
47
+
48
+ Requires Python >=3.10.
49
+
50
+ ## Quickstart
51
+
52
+ ```bash
53
+ pip install wexample-pseudocode
54
+ ```
55
+
56
+ Parse Python source into a YAML pseudocode schema:
57
+
58
+ ```python
59
+ from wexample_pseudocode.generator.pseudocode_generator import PseudocodeGenerator
60
+
61
+ source = "MAX_RETRIES = 3 # Maximum number of retries for API calls\n"
62
+
63
+ gen = PseudocodeGenerator()
64
+ data = gen.generate_config_data(source)
65
+ print(gen.dump_pseudocode(data))
66
+ ```
67
+
68
+ Output:
69
+
70
+ ```yaml
71
+ items:
72
+ - type: constant
73
+ name: MAX_RETRIES
74
+ value: 3
75
+ description: Maximum number of retries for API calls
76
+ ```
77
+
78
+ To go the other direction and regenerate Python from that YAML, use `CodeGenerator`:
79
+
80
+ ```python
81
+ from wexample_pseudocode.generator.code_generator import CodeGenerator
82
+
83
+ yaml_input = """\
84
+ items:
85
+ - type: constant
86
+ name: MAX_RETRIES
87
+ value: 3
88
+ description: Maximum number of retries for API calls
89
+ """
90
+
91
+ gen = CodeGenerator()
92
+ print(gen.generate(yaml_input))
93
+ # MAX_RETRIES = 3 # Maximum number of retries for API calls
94
+ ```
95
+
96
+ ## Tests
97
+
98
+ This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
99
+
100
+ ### Installation
101
+
102
+ First, install the required testing dependencies:
103
+ ```bash
104
+ .venv/bin/python -m pip install pytest pytest-cov
105
+ ```
106
+
107
+ ### Basic Usage
108
+
109
+ Run all tests with coverage:
110
+ ```bash
111
+ .venv/bin/python -m pytest --cov --cov-report=html
112
+ ```
113
+
114
+ ### Common Commands
115
+ ```bash
116
+ # Run tests with coverage for a specific module
117
+ .venv/bin/python -m pytest --cov=your_module
118
+
119
+ # Show which lines are not covered
120
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
121
+
122
+ # Generate an HTML coverage report
123
+ .venv/bin/python -m pytest --cov=your_module --cov-report=html
124
+
125
+ # Combine terminal and HTML reports
126
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
127
+
128
+ # Run specific test file with coverage
129
+ .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
130
+ ```
131
+
132
+ ### Viewing HTML Reports
133
+
134
+ After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
135
+
136
+ ### Coverage Threshold
137
+
138
+ To enforce a minimum coverage percentage:
139
+ ```bash
140
+ .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
141
+ ```
142
+
143
+ This will cause the test suite to fail if coverage drops below 80%.
144
+
145
+ ## Architecture
146
+
147
+ The package has four directories under `src/wexample_pseudocode/`, each owning a distinct responsibility. A call always enters through `generator/`, borrows from `common/`, then either walks through `parser/` (Python → YAML) or through `config/` (YAML → Python).
148
+
149
+ ### `generator/` — the public entry points
150
+
151
+ src/wexample_pseudocode/generator/abstract_generator.py defines `AbstractGenerator`. It provides one concrete static method — `dump_pseudocode(data: dict) -> str`, a thin wrapper around `yaml.safe_dump` bound with `sort_keys=False` — and one abstract contract: `generate_config_data(source_code: str) -> dict`.
152
+
153
+ Two subclasses implement the two directions of the pipeline:
154
+
155
+ - src/wexample_pseudocode/generator/pseudocode_generator.py — **Python → YAML**. `PseudocodeGenerator.generate_config_data()` calls all three parsers in order, applies `normalize_type()` to every annotation it touches, and returns `{"items": [...]}`. Passing that dict to `dump_pseudocode()` produces the YAML string.
156
+
157
+ - src/wexample_pseudocode/generator/code_generator.py — **YAML → Python**. `CodeGenerator.generate()` calls `yaml.safe_load()`, optionally builds a `GeneratorConfig` from a top-level `"generator"` key, then dispatches each item dict to a config class through a `Registry[type]` keyed by `"constant"`, `"class"`, and `"function"`. It calls `to_code()` on each config object and joins the results.
158
+
159
+ ### `parser/` — AST extraction
160
+
161
+ All three parsers accept a `source_code: str`, call `ast.parse()` once, and yield typed dataclass items.
162
+
163
+ - src/wexample_pseudocode/parser/module_parser.py — `parse_module_constants()` yields a `ConstantItem` for every top-level ALL_CAPS name. The inline `#` comment on the assignment line becomes `description`; the value is obtained via `ast.literal_eval` with an `ast.unparse` fallback.
164
+
165
+ - src/wexample_pseudocode/parser/class_parser.py — `parse_module_classes()` yields a `ClassItem` populated with `ClassProperty` and `ClassMethod` records. Dunder methods are skipped. Docstrings are forwarded to `parse_docstring()`; annotations are serialised with `_annotation_to_str()` (`ast.unparse` with an `ast.Name` fallback), which the function parser re-imports from this module.
166
+
167
+ - src/wexample_pseudocode/parser/function_parser.py — `parse_module_functions()` yields a `FunctionItem` for each top-level `ast.FunctionDef`. Default argument alignment is derived from `len(args) - len(defaults)`.
168
+
169
+ ### `common/` — shared utilities
170
+
171
+ - src/wexample_pseudocode/common/docstring.py — `parse_docstring(doc)` returns `{"params": {name: desc, …}, "return": {"description": …}}`. It handles reST/Sphinx (`:param name:`, `:return:`) and Google/NumPy (`Args:`, `Returns:`) blocks in a single pass over the lines.
172
+
173
+ - src/wexample_pseudocode/common/type_normalizer.py — `normalize_type()` maps Python type strings to schema-neutral names: `list` → `"array"`, `Optional[X]` → the inner type, `typing.` prefix stripped. `to_python_type()` is the inverse, used by config `to_code()` methods when regenerating Python source.
174
+
175
+ ### `config/` — schema items and code rendering
176
+
177
+ Each config dataclass represents one item kind from the YAML schema. `from_config(data, global_config)` constructs an instance from a parsed YAML dict; `to_code()` renders the item as a Python source fragment.
178
+
179
+ - src/wexample_pseudocode/config/constant_config.py — `ConstantConfig.to_code()` emits `NAME = value # description`.
180
+
181
+ - src/wexample_pseudocode/config/class_config.py — `ClassConfig.to_code()` assembles the class body from `ClassPropertyConfig` and `ClassMethodConfig` fragments.
182
+
183
+ - src/wexample_pseudocode/config/function_config.py — `FunctionConfig.to_code()` builds the function signature, docstring, and `pass` body from `FunctionParameterConfig` entries.
184
+
185
+ - src/wexample_pseudocode/config/generator_config.py — `GeneratorConfig` is a slots dataclass with no fields; it mirrors the PHP API and is threaded through `from_config()` calls as a placeholder for future global options.
186
+
187
+ Sub-item configs — src/wexample_pseudocode/config/class_method_config.py, src/wexample_pseudocode/config/class_property_config.py, src/wexample_pseudocode/config/function_parameter_config.py, src/wexample_pseudocode/config/method_parameter_config.py — each carry the per-item data and expose a `to_code()` that emits a single Python expression (a property annotation, method signature, or parameter fragment).
188
+
189
+ ### Call paths
190
+
191
+ **Python → YAML**
192
+
193
+ ```
194
+ source_code: str
195
+ └─► PseudocodeGenerator.generate_config_data()
196
+ ├─► parse_module_constants() → ConstantItem[]
197
+ ├─► parse_module_classes() → ClassItem[] (calls parse_docstring, _annotation_to_str)
198
+ └─► parse_module_functions() → FunctionItem[] (calls parse_docstring, _annotation_to_str)
199
+ │
200
+ │ normalize_type() applied to every type annotation
201
+ ▼
202
+ dict {"items": [...]}
203
+ │
204
+ ▼ AbstractGenerator.dump_pseudocode()
205
+ YAML string
206
+ ```
207
+
208
+ **YAML → Python**
209
+
210
+ ```
211
+ yaml_input: str
212
+ └─► CodeGenerator.generate()
213
+ └─► _generate_config()
214
+ ├─► yaml.safe_load()
215
+ ├─► GeneratorConfig.from_config() (if "generator" key present)
216
+ └─► Registry dispatch on item["type"]
217
+ └─► ConstantConfig | ClassConfig | FunctionConfig .from_config()
218
+ │
219
+ ▼ .to_code()
220
+ Python source (joined with "\n")
221
+ ```
222
+
223
+ ## Integration in the Suite
224
+
225
+ This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
226
+
227
+ ### Related Packages
228
+
229
+ The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
230
+
231
+ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
232
+
233
+ ## Dependencies
234
+
235
+ - attrs: >=23.1.0
236
+ - cattrs: >=23.1.0
237
+ - wexample-helpers: >=20.0.0
238
+
239
+ ## Versioning & Compatibility Policy
240
+
241
+ Wexample packages follow **Semantic Versioning** (SemVer):
242
+
243
+ - **MAJOR**: Breaking changes
244
+ - **MINOR**: New features, backward compatible
245
+ - **PATCH**: Bug fixes, backward compatible
246
+
247
+ We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
248
+
249
+ ## License
250
+
251
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
252
+
253
+ Free to use in both personal and commercial projects.
254
+
255
+ ## About us
256
+
257
+ [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
258
+
259
+ This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
260
+
261
+ Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
262
+
263
+ ## Known Limitations & Roadmap
264
+
265
+ Current limitations and planned features are tracked in the GitHub issues.
266
+
267
+ See the [project roadmap](https://github.com/wexample/python-pseudocode/issues) for upcoming features and improvements.
268
+
269
+ ## Status & Compatibility
270
+
271
+ **Maturity**: Production-ready
272
+
273
+ **Python Support**: >=3.10
274
+
275
+ **OS Support**: Linux, macOS, Windows
276
+
277
+ **Status**: Actively maintained
278
+
279
+ ## Useful Links
280
+
281
+ - **Homepage**: https://github.com/wexample/python-pseudocode
282
+ - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
283
+ - **Issue Tracker**: https://github.com/wexample/python-pseudocode/issues
284
+ - **Discussions**: https://github.com/wexample/python-pseudocode/discussions
285
+ - **PyPI**: [pypi.org/project/wexample-pseudocode](https://pypi.org/project/wexample-pseudocode/)
286
+
287
+ ## Migration Notes
288
+
289
+ When upgrading between major versions, refer to the migration guides in the documentation.
290
+
291
+ Breaking changes are clearly documented with upgrade paths and examples.
@@ -0,0 +1,272 @@
1
+ # pseudocode
2
+
3
+ Version: 9.4.6
4
+
5
+ `wexample-pseudocode` parses Python source files into a YAML schema that describes their classes, functions, and constants, then regenerates Python code from that same schema. It targets Python developers who need a language-neutral intermediate representation of a module's public surface — for documentation, cross-language code generation, or schema-driven scaffolding.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Quickstart](#quickstart)
11
+ - [Tests](#tests)
12
+ - [Architecture](#architecture)
13
+ - [Integration in the Suite](#integration-in-the-suite)
14
+ - [Dependencies](#dependencies)
15
+ - [Versioning & Compatibility Policy](#versioning--compatibility-policy)
16
+ - [License](#license)
17
+ - [About us](#about-us)
18
+ - [Known Limitations & Roadmap](#known-limitations--roadmap)
19
+ - [Status & Compatibility](#status--compatibility)
20
+ - [Useful Links](#useful-links)
21
+ - [Migration Notes](#migration-notes)
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pip install wexample-pseudocode
27
+ ```
28
+
29
+ Requires Python >=3.10.
30
+
31
+ ## Quickstart
32
+
33
+ ```bash
34
+ pip install wexample-pseudocode
35
+ ```
36
+
37
+ Parse Python source into a YAML pseudocode schema:
38
+
39
+ ```python
40
+ from wexample_pseudocode.generator.pseudocode_generator import PseudocodeGenerator
41
+
42
+ source = "MAX_RETRIES = 3 # Maximum number of retries for API calls\n"
43
+
44
+ gen = PseudocodeGenerator()
45
+ data = gen.generate_config_data(source)
46
+ print(gen.dump_pseudocode(data))
47
+ ```
48
+
49
+ Output:
50
+
51
+ ```yaml
52
+ items:
53
+ - type: constant
54
+ name: MAX_RETRIES
55
+ value: 3
56
+ description: Maximum number of retries for API calls
57
+ ```
58
+
59
+ To go the other direction and regenerate Python from that YAML, use `CodeGenerator`:
60
+
61
+ ```python
62
+ from wexample_pseudocode.generator.code_generator import CodeGenerator
63
+
64
+ yaml_input = """\
65
+ items:
66
+ - type: constant
67
+ name: MAX_RETRIES
68
+ value: 3
69
+ description: Maximum number of retries for API calls
70
+ """
71
+
72
+ gen = CodeGenerator()
73
+ print(gen.generate(yaml_input))
74
+ # MAX_RETRIES = 3 # Maximum number of retries for API calls
75
+ ```
76
+
77
+ ## Tests
78
+
79
+ This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
80
+
81
+ ### Installation
82
+
83
+ First, install the required testing dependencies:
84
+ ```bash
85
+ .venv/bin/python -m pip install pytest pytest-cov
86
+ ```
87
+
88
+ ### Basic Usage
89
+
90
+ Run all tests with coverage:
91
+ ```bash
92
+ .venv/bin/python -m pytest --cov --cov-report=html
93
+ ```
94
+
95
+ ### Common Commands
96
+ ```bash
97
+ # Run tests with coverage for a specific module
98
+ .venv/bin/python -m pytest --cov=your_module
99
+
100
+ # Show which lines are not covered
101
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
102
+
103
+ # Generate an HTML coverage report
104
+ .venv/bin/python -m pytest --cov=your_module --cov-report=html
105
+
106
+ # Combine terminal and HTML reports
107
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
108
+
109
+ # Run specific test file with coverage
110
+ .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
111
+ ```
112
+
113
+ ### Viewing HTML Reports
114
+
115
+ After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
116
+
117
+ ### Coverage Threshold
118
+
119
+ To enforce a minimum coverage percentage:
120
+ ```bash
121
+ .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
122
+ ```
123
+
124
+ This will cause the test suite to fail if coverage drops below 80%.
125
+
126
+ ## Architecture
127
+
128
+ The package has four directories under `src/wexample_pseudocode/`, each owning a distinct responsibility. A call always enters through `generator/`, borrows from `common/`, then either walks through `parser/` (Python → YAML) or through `config/` (YAML → Python).
129
+
130
+ ### `generator/` — the public entry points
131
+
132
+ src/wexample_pseudocode/generator/abstract_generator.py defines `AbstractGenerator`. It provides one concrete static method — `dump_pseudocode(data: dict) -> str`, a thin wrapper around `yaml.safe_dump` bound with `sort_keys=False` — and one abstract contract: `generate_config_data(source_code: str) -> dict`.
133
+
134
+ Two subclasses implement the two directions of the pipeline:
135
+
136
+ - src/wexample_pseudocode/generator/pseudocode_generator.py — **Python → YAML**. `PseudocodeGenerator.generate_config_data()` calls all three parsers in order, applies `normalize_type()` to every annotation it touches, and returns `{"items": [...]}`. Passing that dict to `dump_pseudocode()` produces the YAML string.
137
+
138
+ - src/wexample_pseudocode/generator/code_generator.py — **YAML → Python**. `CodeGenerator.generate()` calls `yaml.safe_load()`, optionally builds a `GeneratorConfig` from a top-level `"generator"` key, then dispatches each item dict to a config class through a `Registry[type]` keyed by `"constant"`, `"class"`, and `"function"`. It calls `to_code()` on each config object and joins the results.
139
+
140
+ ### `parser/` — AST extraction
141
+
142
+ All three parsers accept a `source_code: str`, call `ast.parse()` once, and yield typed dataclass items.
143
+
144
+ - src/wexample_pseudocode/parser/module_parser.py — `parse_module_constants()` yields a `ConstantItem` for every top-level ALL_CAPS name. The inline `#` comment on the assignment line becomes `description`; the value is obtained via `ast.literal_eval` with an `ast.unparse` fallback.
145
+
146
+ - src/wexample_pseudocode/parser/class_parser.py — `parse_module_classes()` yields a `ClassItem` populated with `ClassProperty` and `ClassMethod` records. Dunder methods are skipped. Docstrings are forwarded to `parse_docstring()`; annotations are serialised with `_annotation_to_str()` (`ast.unparse` with an `ast.Name` fallback), which the function parser re-imports from this module.
147
+
148
+ - src/wexample_pseudocode/parser/function_parser.py — `parse_module_functions()` yields a `FunctionItem` for each top-level `ast.FunctionDef`. Default argument alignment is derived from `len(args) - len(defaults)`.
149
+
150
+ ### `common/` — shared utilities
151
+
152
+ - src/wexample_pseudocode/common/docstring.py — `parse_docstring(doc)` returns `{"params": {name: desc, …}, "return": {"description": …}}`. It handles reST/Sphinx (`:param name:`, `:return:`) and Google/NumPy (`Args:`, `Returns:`) blocks in a single pass over the lines.
153
+
154
+ - src/wexample_pseudocode/common/type_normalizer.py — `normalize_type()` maps Python type strings to schema-neutral names: `list` → `"array"`, `Optional[X]` → the inner type, `typing.` prefix stripped. `to_python_type()` is the inverse, used by config `to_code()` methods when regenerating Python source.
155
+
156
+ ### `config/` — schema items and code rendering
157
+
158
+ Each config dataclass represents one item kind from the YAML schema. `from_config(data, global_config)` constructs an instance from a parsed YAML dict; `to_code()` renders the item as a Python source fragment.
159
+
160
+ - src/wexample_pseudocode/config/constant_config.py — `ConstantConfig.to_code()` emits `NAME = value # description`.
161
+
162
+ - src/wexample_pseudocode/config/class_config.py — `ClassConfig.to_code()` assembles the class body from `ClassPropertyConfig` and `ClassMethodConfig` fragments.
163
+
164
+ - src/wexample_pseudocode/config/function_config.py — `FunctionConfig.to_code()` builds the function signature, docstring, and `pass` body from `FunctionParameterConfig` entries.
165
+
166
+ - src/wexample_pseudocode/config/generator_config.py — `GeneratorConfig` is a slots dataclass with no fields; it mirrors the PHP API and is threaded through `from_config()` calls as a placeholder for future global options.
167
+
168
+ Sub-item configs — src/wexample_pseudocode/config/class_method_config.py, src/wexample_pseudocode/config/class_property_config.py, src/wexample_pseudocode/config/function_parameter_config.py, src/wexample_pseudocode/config/method_parameter_config.py — each carry the per-item data and expose a `to_code()` that emits a single Python expression (a property annotation, method signature, or parameter fragment).
169
+
170
+ ### Call paths
171
+
172
+ **Python → YAML**
173
+
174
+ ```
175
+ source_code: str
176
+ └─► PseudocodeGenerator.generate_config_data()
177
+ ├─► parse_module_constants() → ConstantItem[]
178
+ ├─► parse_module_classes() → ClassItem[] (calls parse_docstring, _annotation_to_str)
179
+ └─► parse_module_functions() → FunctionItem[] (calls parse_docstring, _annotation_to_str)
180
+ │
181
+ │ normalize_type() applied to every type annotation
182
+ ▼
183
+ dict {"items": [...]}
184
+ │
185
+ ▼ AbstractGenerator.dump_pseudocode()
186
+ YAML string
187
+ ```
188
+
189
+ **YAML → Python**
190
+
191
+ ```
192
+ yaml_input: str
193
+ └─► CodeGenerator.generate()
194
+ └─► _generate_config()
195
+ ├─► yaml.safe_load()
196
+ ├─► GeneratorConfig.from_config() (if "generator" key present)
197
+ └─► Registry dispatch on item["type"]
198
+ └─► ConstantConfig | ClassConfig | FunctionConfig .from_config()
199
+ │
200
+ ▼ .to_code()
201
+ Python source (joined with "\n")
202
+ ```
203
+
204
+ ## Integration in the Suite
205
+
206
+ This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
207
+
208
+ ### Related Packages
209
+
210
+ The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
211
+
212
+ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
213
+
214
+ ## Dependencies
215
+
216
+ - attrs: >=23.1.0
217
+ - cattrs: >=23.1.0
218
+ - wexample-helpers: >=20.0.0
219
+
220
+ ## Versioning & Compatibility Policy
221
+
222
+ Wexample packages follow **Semantic Versioning** (SemVer):
223
+
224
+ - **MAJOR**: Breaking changes
225
+ - **MINOR**: New features, backward compatible
226
+ - **PATCH**: Bug fixes, backward compatible
227
+
228
+ We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
229
+
230
+ ## License
231
+
232
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
233
+
234
+ Free to use in both personal and commercial projects.
235
+
236
+ ## About us
237
+
238
+ [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
239
+
240
+ This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
241
+
242
+ Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
243
+
244
+ ## Known Limitations & Roadmap
245
+
246
+ Current limitations and planned features are tracked in the GitHub issues.
247
+
248
+ See the [project roadmap](https://github.com/wexample/python-pseudocode/issues) for upcoming features and improvements.
249
+
250
+ ## Status & Compatibility
251
+
252
+ **Maturity**: Production-ready
253
+
254
+ **Python Support**: >=3.10
255
+
256
+ **OS Support**: Linux, macOS, Windows
257
+
258
+ **Status**: Actively maintained
259
+
260
+ ## Useful Links
261
+
262
+ - **Homepage**: https://github.com/wexample/python-pseudocode
263
+ - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
264
+ - **Issue Tracker**: https://github.com/wexample/python-pseudocode/issues
265
+ - **Discussions**: https://github.com/wexample/python-pseudocode/discussions
266
+ - **PyPI**: [pypi.org/project/wexample-pseudocode](https://pypi.org/project/wexample-pseudocode/)
267
+
268
+ ## Migration Notes
269
+
270
+ When upgrading between major versions, refer to the migration guides in the documentation.
271
+
272
+ Breaking changes are clearly documented with upgrade paths and examples.
@@ -6,8 +6,8 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "wexample-pseudocode"
9
- version = "9.4.4"
10
- description = "Code creation and maintenance tools"
9
+ version = "9.4.6"
10
+ description = "Converts Python source to a YAML pseudocode schema of its classes, functions, and constants, and regenerates Python code from that schema"
11
11
  authors = [
12
12
  { name = "weeger", email = "contact@wexample.com" },
13
13
  ]
@@ -20,7 +20,7 @@ classifiers = [
20
20
  dependencies = [
21
21
  "attrs>=23.1.0",
22
22
  "cattrs>=23.1.0",
23
- "wexample-helpers>=19.0.0",
23
+ "wexample-helpers>=20.0.0",
24
24
  ]
25
25
 
26
26
  [project.readme]