Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,6 @@ __marimo__/
**/*.dll
**/.*.so
**/*.dot

# Folder containing relevant presentations made with Marp
.marp_presentations
1 change: 0 additions & 1 deletion docs/TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

## Documentation gaps: action points for docs

### Stub pages that need content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ review thread, to spell `Pyunit` out fully as well (`TautToPythonUnittest`).
## Implementation notes

- `src/renaissance/utils/text_utils.py`: `snake_case()` (Rule A), `camel_case()` removed.
- `src/renaissance/recipes/python_refactoring.py:39`: `PythonRefactoring.process()` resolves
- `src/renaissance/recipes/python_refactoring.py`: `PythonRefactoring.process()` resolves
`class_name` -> `renaissance.recipes.<snake_case(class_name)>`; names following the guideline
above resolve correctly by construction (`snake_case("TautToPythonUnittest")` ->
`taut_to_python_unittest`).
Expand Down
7 changes: 4 additions & 3 deletions docs/developer/architecture/position-consistency.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ the two sides can silently disagree, producing incorrect or corrupted output.
* `src/renaissance/syntax_tree/ast_rewriter.py` - derives the buffer a rewrite batch is applied to.
* `src/renaissance/common/rewriter.py` - splices replacement text into that buffer, in bytes.
* `src/renaissance/syntax_tree/ast_node.py` - `binary_file_content`, the root-owned buffer accessor.
* `src/renaissance/integrations/python/ast/rst_node.py`, `src/renaissance/integrations/python/ast/cst_node.py`
and `src/renaissance/integrations/python/ast/util.py` - the Python adapters and the line/column to
offset conversion they share.
* `src/renaissance/integrations/python/ast/rst_node.py` and `src/renaissance/integrations/python/ast/util.py` -
the RST adapter and its line/column to offset conversion.
* `src/renaissance/integrations/python/ast/cst_node.py` - the CST adapter, which converts libcst's line/column
positions to byte offsets itself.
* `src/renaissance/integrations/tree_sitter/lst.py` - the tree-sitter adapter.
* `src/renaissance/integrations/clang/clang_ast_node.py` and
`src/renaissance/integrations/clang/clang_json_ast_node.py` - the clang adapters.
Expand Down
45 changes: 43 additions & 2 deletions docs/developer/feature-test-map/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,54 @@ https://github.com/TNO/Renaissance.Py/blob/main/LICENSE
## 1. Pattern matching

- **Feature:** [Pattern matching](../../user/features/pattern-matching.md)
- **Suggested test modules:** `tests/matching/`
- **Test file(s):**
- `test/syntax_tree/test_match_finder.py`
- `test/syntax_tree/test_match_finder_multi_assignments.py`
- `test/syntax_tree/test_match_tree.py`
- `test/syntax_tree/test_match_dict.py`
- `test/syntax_tree/test_pattern_match.py`
- `test/syntax_tree/test_pattern_kind.py`
- `test/python/ast/test_python_matcher.py`
- `test/c_cpp/test_c_match_finder.py`
- **Code file(s):** `src/renaissance/syntax_tree/match_finder.py`, `src/renaissance/syntax_tree/pattern_kind.py`

## 2. Rewrite semantics

- **Feature:** [Rewrite semantics](../../user/features/rewrite-semantics.md)
- **Concepts:** [Rewrite semantics](../../user/concepts/rewrite-semantics.md)
- **Test modules:** [Rewrite semantics test module](../../developer/modules/rewrite-semantics.md)
- **BDD feature file:** `features/rewrite-semantics.feature`
- **BDD steps:** `features/steps/test-rewrite-semantics.py`
- **BDD steps:** `features/steps/test_rewrite_semantics.py`
- **Test file(s):**
- `test/common/test_rewriter.py`
- `test/syntax_tree/test_ast_rewriter.py`
- `test/syntax_tree/test_rewrite_semantics_properties.py`
- **Code files:** `src/renaissance/common/rewriter.py`, `src/renaissance/syntax_tree/ast_rewriter.py`

## 3. Type parameter modernization

- **Feature:** [Type parameter modernization](../../user/features/type-parameter-modernization.md)
- **Concepts:** [Rewrite semantics](../../user/concepts/rewrite-semantics.md)
- **Code modules:** [Refactoring recipes](../../developer/modules/recipes.md)
- **Test file(s):**
- `test/recipes/test_type_parameter_check.py`
- `test/recipes/test_type_parameter_check_convert.py`
- `test/recipes/test_type_parameter_check_localize.py`
- `test/recipes/test_type_parameter_check_orphaned.py`
- `test/recipes/test_type_parameter_check_properties.py`
- `test/recipes/test_type_parameter_check_variance.py`
- `test/recipes/test_type_parameter_declarations.py`
- `test/recipes/test_type_parameter_localization.py`
- `test/recipes/test_type_parameter_rules.py`
- `test/recipes/test_step_runner.py`
- `test/recipes/test_python_refactoring.py`
- `test/utils/test_cst_utils.py`
- `test/utils/test_import_resolution.py`
- `test/rejuvenation/test_migration_type_recipes.py`
- **Code file(s):** `src/renaissance/recipes/type_parameter_check.py`, `src/renaissance/recipes/type_parameter_rules.py`,
`src/renaissance/recipes/type_parameter_declarations.py`, `src/renaissance/recipes/type_parameter_localization.py`,
`src/renaissance/recipes/type_parameter_uses.py`,
`src/renaissance/recipes/step_runner.py`,
`src/renaissance/recipes/python_refactoring.py`,
`src/renaissance/utils/import_resolution.py`, `src/renaissance/utils/cst_utils.py`,
`src/rejuvenation/migration-type-recipes.py`
3 changes: 3 additions & 0 deletions docs/developer/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ https://github.com/TNO/Renaissance.Py/blob/main/LICENSE
1. [Transformation modules](transformation.md)
1. [Observability modules](observability.md)
1. [Strategy modules](strategy.md)
1. [Rewrite semantics module](rewrite-semantics.md)
1. [Refactoring recipes](recipes.md)
1. [Rejected recipes](rejected-recipes.md)
7 changes: 6 additions & 1 deletion docs/developer/modules/parser-and-ast.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,16 @@ preserves comments and whitespace, or reparses source. Each adapter supplies
those behaviors individually. Reference and data-flow collections
(`references`, `referenced_by`) are also parser-specific because not every
parser can provide the same analysis. Keep the original parser node available
when callers need parser-specific data.
when callers need parser-specific data. The Python CST adapter resolves them
with libcst's scope analysis, which also finds names used inside string
annotations. An annotation or type hint written above a definition in the
same scope still refers to it, since it is evaluated lazily.

The native Python `ast.AST` adapter is a lightweight structural adapter and
does not preserve source trivia in the same way as the lossless Python RST/CST
adapters. Use the lossless adapter when source-preserving rewriting is needed.
`PythonRefactoring` parses with the RST adapter by default; pass
`node_class=PythonCstNode` to use the CST adapter instead.

## Classify nodes

Expand Down
Loading
Loading