wexample-pseudocode 9.4.12__tar.gz → 9.4.13__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.13/PKG-INFO +113 -0
  2. wexample_pseudocode-9.4.13/README.md +93 -0
  3. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/pyproject.toml +2 -2
  4. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/.gitkeep +0 -0
  5. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/class/basic_calculator.py.txt +0 -0
  6. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/constant/constant_using_const.py.txt +0 -0
  7. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/function/basic_function.py.txt +0 -0
  8. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/function/complex_function.py.txt +0 -0
  9. wexample_pseudocode-9.4.12/PKG-INFO +0 -292
  10. wexample_pseudocode-9.4.12/README.md +0 -272
  11. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/__init__.py +0 -0
  12. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/common/__init__.py +0 -0
  13. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/common/docstring.py +0 -0
  14. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/common/type_normalizer.py +0 -0
  15. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/__init__.py +0 -0
  16. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/class_config.py +0 -0
  17. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/class_method_config.py +0 -0
  18. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/class_property_config.py +0 -0
  19. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/constant_config.py +0 -0
  20. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/doc_comment_config.py +0 -0
  21. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/doc_comment_parameter_config.py +0 -0
  22. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/doc_comment_return_config.py +0 -0
  23. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/function_config.py +0 -0
  24. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/function_parameter_config.py +0 -0
  25. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/generator_config.py +0 -0
  26. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/config/method_parameter_config.py +0 -0
  27. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/generator/__init__.py +0 -0
  28. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/generator/abstract_generator.py +0 -0
  29. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/generator/code_generator.py +0 -0
  30. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/generator/pseudocode_generator.py +0 -0
  31. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/parser/__init__.py +0 -0
  32. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/parser/class_parser.py +0 -0
  33. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/parser/function_parser.py +0 -0
  34. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/parser/module_parser.py +0 -0
  35. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/src/wexample_pseudocode/py.typed +0 -0
  36. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/conftest.py +0 -0
  37. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/__init__.py +0 -0
  38. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/__init__.py +0 -0
  39. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/class/__init__.py +0 -0
  40. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/class/basic_calculator.yml +0 -0
  41. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/constant/__init__.py +0 -0
  42. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/constant/constant_using_const.yml +0 -0
  43. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/function/__init__.py +0 -0
  44. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/function/basic_function.yml +0 -0
  45. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/resources/item/function/complex_function.yml +0 -0
  46. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/test_class_basic_calculator.py +0 -0
  47. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/test_code_generator_class_basic_calculator.py +0 -0
  48. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/test_code_generator_constant.py +0 -0
  49. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/test_constant_using_const.py +0 -0
  50. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/test_function_items.py +0 -0
  51. {wexample_pseudocode-9.4.12 → wexample_pseudocode-9.4.13}/tests/test_php_yaml_compat.py +0 -0
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.1
2
+ Name: wexample-pseudocode
3
+ Version: 9.4.13
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: pyyaml>=6.0
15
+ Requires-Dist: wexample-helpers>=20.6.0
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest; extra == "dev"
18
+ Requires-Dist: pytest-cov; extra == "dev"
19
+ Description-Content-Type: text/markdown
20
+
21
+ # pseudocode
22
+
23
+ Version: 9.4.13
24
+
25
+ Converts Python source to a YAML pseudocode schema of its classes, functions, and constants, and regenerates Python code from that schema
26
+
27
+ ## Table of Contents
28
+
29
+ - [Install](#install)
30
+ - [Tests](#tests)
31
+ - [Roadmap](#roadmap)
32
+ - [Status Compatibility](#status-compatibility)
33
+ - [Useful Links](#useful-links)
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install wexample-pseudocode
39
+ ```
40
+
41
+ Requires Python >=3.10.
42
+
43
+ ## Tests
44
+
45
+ This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
46
+
47
+ ### Installation
48
+
49
+ First, install the required testing dependencies:
50
+ ```bash
51
+ .venv/bin/python -m pip install pytest pytest-cov
52
+ ```
53
+
54
+ ### Basic Usage
55
+
56
+ Run all tests with coverage:
57
+ ```bash
58
+ .venv/bin/python -m pytest --cov --cov-report=html
59
+ ```
60
+
61
+ ### Common Commands
62
+ ```bash
63
+ # Run tests with coverage for a specific module
64
+ .venv/bin/python -m pytest --cov=your_module
65
+
66
+ # Show which lines are not covered
67
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
68
+
69
+ # Generate an HTML coverage report
70
+ .venv/bin/python -m pytest --cov=your_module --cov-report=html
71
+
72
+ # Combine terminal and HTML reports
73
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
74
+
75
+ # Run specific test file with coverage
76
+ .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
77
+ ```
78
+
79
+ ### Viewing HTML Reports
80
+
81
+ After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
82
+
83
+ ### Coverage Threshold
84
+
85
+ To enforce a minimum coverage percentage:
86
+ ```bash
87
+ .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
88
+ ```
89
+
90
+ This will cause the test suite to fail if coverage drops below 80%.
91
+
92
+ ## Known Limitations & Roadmap
93
+
94
+ Current limitations and planned features are tracked in the GitHub issues.
95
+
96
+ See the [project roadmap](https://github.com/wexample/python-pseudocode/issues) for upcoming features and improvements.
97
+
98
+ ## Status & Compatibility
99
+
100
+ **Maturity**: Production-ready
101
+
102
+ **Python Support**: >=3.10
103
+
104
+ **OS Support**: Linux, macOS, Windows
105
+
106
+ **Status**: Actively maintained
107
+
108
+ ## Useful Links
109
+
110
+ - **Homepage**: https://github.com/wexample/python-pseudocode
111
+ - **Issue Tracker**: https://github.com/wexample/python-pseudocode/issues
112
+ - **Discussions**: https://github.com/wexample/python-pseudocode/discussions
113
+ - **PyPI**: [pypi.org/project/wexample-pseudocode](https://pypi.org/project/wexample-pseudocode/)
@@ -0,0 +1,93 @@
1
+ # pseudocode
2
+
3
+ Version: 9.4.13
4
+
5
+ Converts Python source to a YAML pseudocode schema of its classes, functions, and constants, and regenerates Python code from that schema
6
+
7
+ ## Table of Contents
8
+
9
+ - [Install](#install)
10
+ - [Tests](#tests)
11
+ - [Roadmap](#roadmap)
12
+ - [Status Compatibility](#status-compatibility)
13
+ - [Useful Links](#useful-links)
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install wexample-pseudocode
19
+ ```
20
+
21
+ Requires Python >=3.10.
22
+
23
+ ## Tests
24
+
25
+ This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
26
+
27
+ ### Installation
28
+
29
+ First, install the required testing dependencies:
30
+ ```bash
31
+ .venv/bin/python -m pip install pytest pytest-cov
32
+ ```
33
+
34
+ ### Basic Usage
35
+
36
+ Run all tests with coverage:
37
+ ```bash
38
+ .venv/bin/python -m pytest --cov --cov-report=html
39
+ ```
40
+
41
+ ### Common Commands
42
+ ```bash
43
+ # Run tests with coverage for a specific module
44
+ .venv/bin/python -m pytest --cov=your_module
45
+
46
+ # Show which lines are not covered
47
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
48
+
49
+ # Generate an HTML coverage report
50
+ .venv/bin/python -m pytest --cov=your_module --cov-report=html
51
+
52
+ # Combine terminal and HTML reports
53
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
54
+
55
+ # Run specific test file with coverage
56
+ .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
57
+ ```
58
+
59
+ ### Viewing HTML Reports
60
+
61
+ After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
62
+
63
+ ### Coverage Threshold
64
+
65
+ To enforce a minimum coverage percentage:
66
+ ```bash
67
+ .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
68
+ ```
69
+
70
+ This will cause the test suite to fail if coverage drops below 80%.
71
+
72
+ ## Known Limitations & Roadmap
73
+
74
+ Current limitations and planned features are tracked in the GitHub issues.
75
+
76
+ See the [project roadmap](https://github.com/wexample/python-pseudocode/issues) for upcoming features and improvements.
77
+
78
+ ## Status & Compatibility
79
+
80
+ **Maturity**: Production-ready
81
+
82
+ **Python Support**: >=3.10
83
+
84
+ **OS Support**: Linux, macOS, Windows
85
+
86
+ **Status**: Actively maintained
87
+
88
+ ## Useful Links
89
+
90
+ - **Homepage**: https://github.com/wexample/python-pseudocode
91
+ - **Issue Tracker**: https://github.com/wexample/python-pseudocode/issues
92
+ - **Discussions**: https://github.com/wexample/python-pseudocode/discussions
93
+ - **PyPI**: [pypi.org/project/wexample-pseudocode](https://pypi.org/project/wexample-pseudocode/)
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "wexample-pseudocode"
9
- version = "9.4.12"
9
+ version = "9.4.13"
10
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" },
@@ -21,7 +21,7 @@ dependencies = [
21
21
  "attrs>=23.1.0",
22
22
  "cattrs>=23.1.0",
23
23
  "pyyaml>=6.0",
24
- "wexample-helpers>=20.5.0",
24
+ "wexample-helpers>=20.6.0",
25
25
  ]
26
26
 
27
27
  [project.readme]
@@ -1,292 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: wexample-pseudocode
3
- Version: 9.4.12
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: pyyaml>=6.0
15
- Requires-Dist: wexample-helpers>=20.5.0
16
- Provides-Extra: dev
17
- Requires-Dist: pytest; extra == "dev"
18
- Requires-Dist: pytest-cov; extra == "dev"
19
- Description-Content-Type: text/markdown
20
-
21
- # pseudocode
22
-
23
- Version: 9.4.12
24
-
25
- `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.
26
-
27
- ## Table of Contents
28
-
29
- - [Installation](#installation)
30
- - [Quickstart](#quickstart)
31
- - [Tests](#tests)
32
- - [Architecture](#architecture)
33
- - [Integration in the Suite](#integration-in-the-suite)
34
- - [Dependencies](#dependencies)
35
- - [Versioning & Compatibility Policy](#versioning--compatibility-policy)
36
- - [License](#license)
37
- - [About us](#about-us)
38
- - [Known Limitations & Roadmap](#known-limitations--roadmap)
39
- - [Status & Compatibility](#status--compatibility)
40
- - [Useful Links](#useful-links)
41
- - [Migration Notes](#migration-notes)
42
-
43
- ## Installation
44
-
45
- ```bash
46
- pip install wexample-pseudocode
47
- ```
48
-
49
- Requires Python >=3.10.
50
-
51
- ## Quickstart
52
-
53
- ```bash
54
- pip install wexample-pseudocode
55
- ```
56
-
57
- Parse Python source into a YAML pseudocode schema:
58
-
59
- ```python
60
- from wexample_pseudocode.generator.pseudocode_generator import PseudocodeGenerator
61
-
62
- source = "MAX_RETRIES = 3 # Maximum number of retries for API calls\n"
63
-
64
- gen = PseudocodeGenerator()
65
- data = gen.generate_config_data(source)
66
- print(gen.dump_pseudocode(data))
67
- ```
68
-
69
- Output:
70
-
71
- ```yaml
72
- items:
73
- - type: constant
74
- name: MAX_RETRIES
75
- value: 3
76
- description: Maximum number of retries for API calls
77
- ```
78
-
79
- To go the other direction and regenerate Python from that YAML, use `CodeGenerator`:
80
-
81
- ```python
82
- from wexample_pseudocode.generator.code_generator import CodeGenerator
83
-
84
- yaml_input = """\
85
- items:
86
- - type: constant
87
- name: MAX_RETRIES
88
- value: 3
89
- description: Maximum number of retries for API calls
90
- """
91
-
92
- gen = CodeGenerator()
93
- print(gen.generate(yaml_input))
94
- # MAX_RETRIES = 3 # Maximum number of retries for API calls
95
- ```
96
-
97
- ## Tests
98
-
99
- This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
100
-
101
- ### Installation
102
-
103
- First, install the required testing dependencies:
104
- ```bash
105
- .venv/bin/python -m pip install pytest pytest-cov
106
- ```
107
-
108
- ### Basic Usage
109
-
110
- Run all tests with coverage:
111
- ```bash
112
- .venv/bin/python -m pytest --cov --cov-report=html
113
- ```
114
-
115
- ### Common Commands
116
- ```bash
117
- # Run tests with coverage for a specific module
118
- .venv/bin/python -m pytest --cov=your_module
119
-
120
- # Show which lines are not covered
121
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
122
-
123
- # Generate an HTML coverage report
124
- .venv/bin/python -m pytest --cov=your_module --cov-report=html
125
-
126
- # Combine terminal and HTML reports
127
- .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
128
-
129
- # Run specific test file with coverage
130
- .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
131
- ```
132
-
133
- ### Viewing HTML Reports
134
-
135
- After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
136
-
137
- ### Coverage Threshold
138
-
139
- To enforce a minimum coverage percentage:
140
- ```bash
141
- .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
142
- ```
143
-
144
- This will cause the test suite to fail if coverage drops below 80%.
145
-
146
- ## Architecture
147
-
148
- 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).
149
-
150
- ### `generator/` — the public entry points
151
-
152
- 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`.
153
-
154
- Two subclasses implement the two directions of the pipeline:
155
-
156
- - 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.
157
-
158
- - 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.
159
-
160
- ### `parser/` — AST extraction
161
-
162
- All three parsers accept a `source_code: str`, call `ast.parse()` once, and yield typed dataclass items.
163
-
164
- - 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.
165
-
166
- - 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.
167
-
168
- - 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)`.
169
-
170
- ### `common/` — shared utilities
171
-
172
- - 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.
173
-
174
- - 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.
175
-
176
- ### `config/` — schema items and code rendering
177
-
178
- 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.
179
-
180
- - src/wexample_pseudocode/config/constant_config.py — `ConstantConfig.to_code()` emits `NAME = value # description`.
181
-
182
- - src/wexample_pseudocode/config/class_config.py — `ClassConfig.to_code()` assembles the class body from `ClassPropertyConfig` and `ClassMethodConfig` fragments.
183
-
184
- - src/wexample_pseudocode/config/function_config.py — `FunctionConfig.to_code()` builds the function signature, docstring, and `pass` body from `FunctionParameterConfig` entries.
185
-
186
- - 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.
187
-
188
- 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).
189
-
190
- ### Call paths
191
-
192
- **Python → YAML**
193
-
194
- ```
195
- source_code: str
196
- └─► PseudocodeGenerator.generate_config_data()
197
- ├─► parse_module_constants() → ConstantItem[]
198
- ├─► parse_module_classes() → ClassItem[] (calls parse_docstring, _annotation_to_str)
199
- └─► parse_module_functions() → FunctionItem[] (calls parse_docstring, _annotation_to_str)
200
- │
201
- │ normalize_type() applied to every type annotation
202
- ▼
203
- dict {"items": [...]}
204
- │
205
- ▼ AbstractGenerator.dump_pseudocode()
206
- YAML string
207
- ```
208
-
209
- **YAML → Python**
210
-
211
- ```
212
- yaml_input: str
213
- └─► CodeGenerator.generate()
214
- └─► _generate_config()
215
- ├─► yaml.safe_load()
216
- ├─► GeneratorConfig.from_config() (if "generator" key present)
217
- └─► Registry dispatch on item["type"]
218
- └─► ConstantConfig | ClassConfig | FunctionConfig .from_config()
219
- │
220
- ▼ .to_code()
221
- Python source (joined with "\n")
222
- ```
223
-
224
- ## Integration in the Suite
225
-
226
- 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.
227
-
228
- ### Related Packages
229
-
230
- 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.
231
-
232
- ## Dependencies
233
-
234
- - attrs: >=23.1.0
235
- - cattrs: >=23.1.0
236
- - pyyaml: >=6.0
237
- - wexample-helpers: >=20.5.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
- Built and maintained by [Romain Weeger](https://weeger.io).
264
-
265
- ## Known Limitations & Roadmap
266
-
267
- Current limitations and planned features are tracked in the GitHub issues.
268
-
269
- See the [project roadmap](https://github.com/wexample/python-pseudocode/issues) for upcoming features and improvements.
270
-
271
- ## Status & Compatibility
272
-
273
- **Maturity**: Production-ready
274
-
275
- **Python Support**: >=3.10
276
-
277
- **OS Support**: Linux, macOS, Windows
278
-
279
- **Status**: Actively maintained
280
-
281
- ## Useful Links
282
-
283
- - **Homepage**: https://github.com/wexample/python-pseudocode
284
- - **Issue Tracker**: https://github.com/wexample/python-pseudocode/issues
285
- - **Discussions**: https://github.com/wexample/python-pseudocode/discussions
286
- - **PyPI**: [pypi.org/project/wexample-pseudocode](https://pypi.org/project/wexample-pseudocode/)
287
-
288
- ## Migration Notes
289
-
290
- When upgrading between major versions, refer to the migration guides in the documentation.
291
-
292
- Breaking changes are clearly documented with upgrade paths and examples.
@@ -1,272 +0,0 @@
1
- # pseudocode
2
-
3
- Version: 9.4.12
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
- ## Dependencies
213
-
214
- - attrs: >=23.1.0
215
- - cattrs: >=23.1.0
216
- - pyyaml: >=6.0
217
- - wexample-helpers: >=20.5.0
218
-
219
- ## Versioning & Compatibility Policy
220
-
221
- Wexample packages follow **Semantic Versioning** (SemVer):
222
-
223
- - **MAJOR**: Breaking changes
224
- - **MINOR**: New features, backward compatible
225
- - **PATCH**: Bug fixes, backward compatible
226
-
227
- We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
228
-
229
- ## License
230
-
231
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
232
-
233
- Free to use in both personal and commercial projects.
234
-
235
- ## About us
236
-
237
- [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.
238
-
239
- 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.
240
-
241
- 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.
242
-
243
- Built and maintained by [Romain Weeger](https://weeger.io).
244
-
245
- ## Known Limitations & Roadmap
246
-
247
- Current limitations and planned features are tracked in the GitHub issues.
248
-
249
- See the [project roadmap](https://github.com/wexample/python-pseudocode/issues) for upcoming features and improvements.
250
-
251
- ## Status & Compatibility
252
-
253
- **Maturity**: Production-ready
254
-
255
- **Python Support**: >=3.10
256
-
257
- **OS Support**: Linux, macOS, Windows
258
-
259
- **Status**: Actively maintained
260
-
261
- ## Useful Links
262
-
263
- - **Homepage**: https://github.com/wexample/python-pseudocode
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.