Skip to content

Commit 9d4d156

Browse files
authored
docs(api): sync Python API reference to python-sdk 1.4.0 (#6)
Co-authored-by: rahlk <1433964+rahlk@users.noreply.github.com>
1 parent d84bb0e commit 9d4d156

4 files changed

Lines changed: 170 additions & 22 deletions

File tree

src/content/docs/reference/python-api/core.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ The full generated reference follows.
140140

141141
<!-- AUTO-GENERATED by scripts/gen_api_docs.py, do not edit by hand. -->
142142

143-
[![Source on GitHub](https://img.shields.io/badge/source-codellm--devkit%2Fpython--sdk-181717?logo=github&logoColor=white)](https://github.com/codellm-devkit/python-sdk) [![cldk 1.2.0](https://img.shields.io/badge/cldk-1.2.0-3776AB?logo=pypi&logoColor=white)](https://pypi.org/project/cldk/1.2.0/)
143+
[![Source on GitHub](https://img.shields.io/badge/source-codellm--devkit%2Fpython--sdk-181717?logo=github&logoColor=white)](https://github.com/codellm-devkit/python-sdk) [![cldk 1.4.0](https://img.shields.io/badge/cldk-1.4.0-3776AB?logo=pypi&logoColor=white)](https://pypi.org/project/cldk/1.4.0/)
144144

145-
_API reference generated from cldk 1.2.0._
145+
_API reference generated from cldk 1.4.0._
146146

147147
Core CLDK module.
148148

@@ -155,8 +155,8 @@ parsers, and sanitization utilities.
155155
> **The CLDK supports the following languages**
156156
> - **Java**: Full static analysis via CodeAnalyzer backend, including symbol
157157
> tables, call graphs, and code metrics.
158-
> - **Python**: Static analysis via codeanalyzer-python backend with optional
159-
> CodeQL-augmented call graph resolution.
158+
> - **Python**: Static analysis via codeanalyzer-python backend (Jedi plus
159+
> PyCG call-graph construction).
160160
> - **C**: Basic analysis via libclang for parsing and extracting code structure.
161161
162162
Typical usage involves instantiating `CLDK` with a target language, then
@@ -221,7 +221,7 @@ Create a Java analysis facade.
221221

222222
| Name | Type | Description |
223223
| ---- | ---- | ----------- |
224-
| `project_path` | `str \| Path \| None` | Path to the Java project directory. |
224+
| `project_path` | `str \| Path \| None` | Path to the Java project directory. Optional only when ``backend`` is a `Neo4jConnectionConfig` (the graph is read out of band over Bolt). When provided, the path is validated, it must exist and be a directory, regardless of backend. |
225225
| `source_code` | `str \| None` | Single Java source string (deprecated; pass ``project_path`` instead). |
226226
| `analysis_level` | `str` | Analysis depth (see `AnalysisLevel`). |
227227
| `target_files` | `List[str] \| None` | Restrict analysis to these files. |
@@ -244,7 +244,7 @@ Create a Python analysis facade.
244244

245245
| Name | Type | Description |
246246
| ---- | ---- | ----------- |
247-
| `project_path` | `str \| Path \| None` | Path to the Python project directory. Optional only when ``backend`` is a `Neo4jConnectionConfig` (the graph is populated out of band). |
247+
| `project_path` | `str \| Path \| None` | Path to the Python project directory. Optional only when ``backend`` is a `Neo4jConnectionConfig` (the graph is populated out of band over Bolt). When provided, the path is validated, it must exist and be a directory, regardless of backend. |
248248
| `analysis_level` | `str` | Analysis depth (see `AnalysisLevel`). |
249249
| `target_files` | `List[str] \| None` | Restrict analysis to these files. |
250250
| `eager` | `bool` | Force regeneration of cached analysis. |
@@ -262,11 +262,11 @@ Create a TypeScript analysis facade.
262262

263263
| Name | Type | Description |
264264
| ---- | ---- | ----------- |
265-
| `project_path` | `str \| Path \| None` | Path to the TypeScript project directory. Optional only when ``backend`` is a `Neo4jConnectionConfig` (the graph is populated out of band). |
265+
| `project_path` | `str \| Path \| None` | Path to the TypeScript project directory. Optional only when ``backend`` is a `Neo4jConnectionConfig` (the graph is populated out of band over Bolt). When provided, the path is validated, it must exist and be a directory, regardless of backend. |
266266
| `analysis_level` | `str` | Analysis depth (see `AnalysisLevel`). |
267267
| `target_files` | `List[str] \| None` | Restrict analysis to these files. |
268268
| `eager` | `bool` | Force regeneration of cached analysis. |
269-
| `backend` | `TSBackend \| None` | Backend configuration. Defaults to `CodeAnalyzerConfig`; pass a `Neo4jConnectionConfig` to use the read-only Neo4j backend. |
269+
| `backend` | `TSBackend \| None` | Backend configuration. Defaults to `CodeAnalyzerConfig`; pass a `TSCodeAnalyzerConfig` to set TypeScript-only knobs such as ``tsc_only`` (passes ``--tsc-only``), or a `Neo4jConnectionConfig` to use the read-only Neo4j backend. |
270270

271271
#### `CLDK.c`
272272

@@ -279,7 +279,7 @@ Create a C analysis facade for the given project directory.
279279
#### `CLDK.analysis`
280280

281281
```python
282-
analysis(project_path: str | Path | None = None, source_code: str | None = None, eager: bool = False, analysis_level: str = AnalysisLevel.symbol_table, target_files: List[str] | None = None, analysis_backend_path: str | None = None, analysis_json_path: str | Path | None = None, cache_dir: str | Path | None = None, use_codeql: bool = True, use_ray: bool = False, neo4j_config: Neo4jConnectionConfig | None = None) -> JavaAnalysis | PythonAnalysis | CAnalysis | TypeScriptAnalysis
282+
analysis(project_path: str | Path | None = None, source_code: str | None = None, eager: bool = False, analysis_level: str = AnalysisLevel.symbol_table, target_files: List[str] | None = None, analysis_backend_path: str | None = None, analysis_json_path: str | Path | None = None, cache_dir: str | Path | None = None, use_ray: bool = False, neo4j_config: Neo4jConnectionConfig | None = None) -> JavaAnalysis | PythonAnalysis | CAnalysis | TypeScriptAnalysis
283283
```
284284

285285
Deprecated entry point. Use the per-language factory methods instead.

src/content/docs/reference/python-api/java.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ follows.
106106

107107
<!-- AUTO-GENERATED by scripts/gen_api_docs.py, do not edit by hand. -->
108108

109-
[![Source on GitHub](https://img.shields.io/badge/source-codellm--devkit%2Fpython--sdk-181717?logo=github&logoColor=white)](https://github.com/codellm-devkit/python-sdk) [![cldk 1.2.0](https://img.shields.io/badge/cldk-1.2.0-3776AB?logo=pypi&logoColor=white)](https://pypi.org/project/cldk/1.2.0/)
109+
[![Source on GitHub](https://img.shields.io/badge/source-codellm--devkit%2Fpython--sdk-181717?logo=github&logoColor=white)](https://github.com/codellm-devkit/python-sdk) [![cldk 1.4.0](https://img.shields.io/badge/cldk-1.4.0-3776AB?logo=pypi&logoColor=white)](https://pypi.org/project/cldk/1.4.0/)
110110

111-
_API reference generated from cldk 1.2.0._
111+
_API reference generated from cldk 1.4.0._
112112

113113
## Analysis
114114

src/content/docs/reference/python-api/python.md

Lines changed: 122 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ follows.
123123

124124
<!-- AUTO-GENERATED by scripts/gen_api_docs.py, do not edit by hand. -->
125125

126-
[![Source on GitHub](https://img.shields.io/badge/source-codellm--devkit%2Fpython--sdk-181717?logo=github&logoColor=white)](https://github.com/codellm-devkit/python-sdk) [![cldk 1.2.0](https://img.shields.io/badge/cldk-1.2.0-3776AB?logo=pypi&logoColor=white)](https://pypi.org/project/cldk/1.2.0/)
126+
[![Source on GitHub](https://img.shields.io/badge/source-codellm--devkit%2Fpython--sdk-181717?logo=github&logoColor=white)](https://github.com/codellm-devkit/python-sdk) [![cldk 1.4.0](https://img.shields.io/badge/cldk-1.4.0-3776AB?logo=pypi&logoColor=white)](https://pypi.org/project/cldk/1.4.0/)
127127

128-
_API reference generated from cldk 1.2.0._
128+
_API reference generated from cldk 1.4.0._
129129

130130
## Analysis
131131

@@ -140,8 +140,7 @@ The analysis is powered by the ``codeanalyzer-python`` backend, which uses a
140140
combination of:
141141
- **Jedi**: For semantic code understanding, symbol resolution, and basic
142142
call graph construction.
143-
- **CodeQL** (optional): For enhanced call graph resolution and more
144-
accurate inter-procedural analysis.
143+
- **PyCG**: For call-graph construction.
145144
- **Tree-sitter**: For fast syntactic parsing and AST operations.
146145

147146
> **Key capabilities include**
@@ -416,16 +415,15 @@ from one callable to another.
416415

417416
> **The call graph is built using**
418417
> - Jedi for semantic call resolution
419-
> - CodeQL (if enabled) for enhanced inter-procedural analysis
418+
> - PyCG for inter-procedural call-graph construction
420419
421420
**Returns:**
422421

423422
- `nx.DiGraph`: A ``networkx.DiGraph`` where: - Nodes represent callables (functions/methods) with attributes containing callable metadata - Edges represent call relationships, directed from caller to callee - Edge attributes may include call site information
424423

425424
> **Note**
426-
> The completeness of the call graph depends on the analysis
427-
> configuration. With ``use_codeql=True``, more call relationships
428-
> are typically discovered at the cost of longer analysis time.
425+
> The completeness of the call graph depends on the analysis backend
426+
> (Jedi plus PyCG in codeanalyzer-python 0.3.0).
429427
430428
> **See Also**
431429
> `get_callers`: For finding callers of a specific method.
@@ -559,6 +557,94 @@ dictionary structure by class name and then method name.
559557
> `get_methods_in_class`: For methods of a specific class.
560558
> `get_method`: For a single method by name.
561559
560+
##### `PythonAnalysis.get_callables_overview`
561+
562+
```python
563+
get_callables_overview() -> List[PyCallableOverview]
564+
```
565+
566+
Return a lightweight overview of every callable in the project, in one bulk read.
567+
568+
A field-projected alternative to `get_methods` for enumeration: each
569+
`PyCallableOverview` carries the callable's signature, owning
570+
class (if any), kind, location, and decorators, but not the full reconstruction (call
571+
sites, inner callables, locals). On the Neo4j backend this is a single Cypher query instead
572+
of the per-entity fan-out `get_methods` pays. Body-inspect the few you need afterwards
573+
via `get_method` or `get_method_bodies`.
574+
575+
**Returns:**
576+
577+
- `List[PyCallableOverview]`: A flat list of `PyCallableOverview`, one per callable
578+
- `List[PyCallableOverview]`: (methods, module-level functions, and nested functions).
579+
580+
> **See Also**
581+
> `get_decorated_callables`: The same projection filtered by decorator.
582+
> `get_method_bodies`: Bulk source-body fetch for chosen signatures.
583+
584+
##### `PythonAnalysis.get_method_bodies`
585+
586+
```python
587+
get_method_bodies(signatures: List[str]) -> Dict[str, str]
588+
```
589+
590+
Return source bodies for the given callable signatures, in one bulk read.
591+
592+
**Parameters:**
593+
594+
| Name | Type | Description |
595+
| ---- | ---- | ----------- |
596+
| `signatures` | `List[str]` | Callable signatures to fetch bodies for (e.g. from `get_callables_overview`). |
597+
598+
**Returns:**
599+
600+
- `Dict[str, str]`: A dict mapping each signature to its source body. Signatures with no matching callable
601+
- `Dict[str, str]`: are omitted.
602+
603+
##### `PythonAnalysis.get_decorated_callables`
604+
605+
```python
606+
get_decorated_callables(markers: List[str]) -> List[PyCallableOverview]
607+
```
608+
609+
Return overviews of callables decorated with any of the given markers, in one bulk read.
610+
611+
**Parameters:**
612+
613+
| Name | Type | Description |
614+
| ---- | ---- | ----------- |
615+
| `markers` | `List[str]` | Decorator names to match (e.g. ``["staticmethod", "app.route"]``). |
616+
617+
**Returns:**
618+
619+
- `List[PyCallableOverview]`: A list of `PyCallableOverview` for every callable carrying at
620+
- `List[PyCallableOverview]`: least one of ``markers`` as a decorator.
621+
622+
> **See Also**
623+
> `get_callables_overview`: The unfiltered projection.
624+
625+
##### `PythonAnalysis.get_callsites_for`
626+
627+
```python
628+
get_callsites_for(signatures: List[str]) -> Dict[str, List[PyCallsite]]
629+
```
630+
631+
Return the call sites of the given callables, keyed by signature, in one bulk read.
632+
633+
Avoids the per-callable reconstruction fan-out when you need call sites for a specific
634+
frontier (e.g. dispatch-edge synthesis or external-reader detection).
635+
636+
**Parameters:**
637+
638+
| Name | Type | Description |
639+
| ---- | ---- | ----------- |
640+
| `signatures` | `List[str]` | Callable signatures to fetch call sites for. |
641+
642+
**Returns:**
643+
644+
- `Dict[str, List[PyCallsite]]`: A dict mapping each existing signature to its list of
645+
- `Dict[str, List[PyCallsite]]`: class:`~cldk.models.python.PyCallsite` (empty if the callable has no call sites).
646+
- `Dict[str, List[PyCallsite]]`: Signatures with no matching callable are omitted.
647+
562648
##### `PythonAnalysis.get_methods_in_class`
563649

564650
```python
@@ -1233,6 +1319,7 @@ Represents a Python application.
12331319
| ---- | ---- | ----------- |
12341320
| `symbol_table` | `Dict[str, PyModule]` | |
12351321
| `call_graph` | `List[PyCallEdge]` | |
1322+
| `external_symbols` | `Dict[str, PyExternalSymbol]` | |
12361323

12371324
### `PyCallEdge`
12381325

@@ -1256,7 +1343,7 @@ Rich per-call metadata (receiver, arguments, location, ...) lives on
12561343
| `target` | `str` | |
12571344
| `type` | `Literal['CALL_DEP']` | |
12581345
| `weight` | `int` | |
1259-
| `provenance` | `List[Literal['jedi', 'codeql', 'joern']]` | |
1346+
| `provenance` | `List[Literal['jedi', 'pycg', 'joern']]` | |
12601347

12611348
### `PyCallable`
12621349

@@ -1288,6 +1375,32 @@ Represents a Python callable (function/method).
12881375
| `local_variables` | `List[PyVariableDeclaration]` | |
12891376
| `cyclomatic_complexity` | `int` | |
12901377

1378+
### `PyCallableOverview`
1379+
1380+
```python
1381+
class PyCallableOverview(BaseModel)
1382+
```
1383+
1384+
A lightweight projection of one callable, enough to enumerate and filter without the full
1385+
`PyCallable` reconstruction (call-sites, inner callables, locals).
1386+
1387+
Returned set-at-a-time by `get_callables_overview` /
1388+
`get_decorated_callables`. Body-inspect only the few you need afterwards
1389+
via `get_method`/`get_method_bodies`.
1390+
1391+
#### Attributes
1392+
1393+
| Name | Type | Description |
1394+
| ---- | ---- | ----------- |
1395+
| `signature` | `str` | |
1396+
| `name` | `str` | |
1397+
| `class_signature` | `Optional[str]` | |
1398+
| `kind` | `str` | |
1399+
| `path` | `str` | |
1400+
| `start_line` | `int` | |
1401+
| `end_line` | `int` | |
1402+
| `decorators` | `List[str]` | |
1403+
12911404
### `PyCallableParameter`
12921405

12931406
```python

src/content/docs/reference/python-api/typescript.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ graph = analysis.get_call_graph() # -> networkx.DiGraph
5353

5454
<!-- AUTO-GENERATED by scripts/gen_api_docs.py, do not edit by hand. -->
5555

56-
[![Source on GitHub](https://img.shields.io/badge/source-codellm--devkit%2Fpython--sdk-181717?logo=github&logoColor=white)](https://github.com/codellm-devkit/python-sdk) [![cldk 1.2.0](https://img.shields.io/badge/cldk-1.2.0-3776AB?logo=pypi&logoColor=white)](https://pypi.org/project/cldk/1.2.0/)
56+
[![Source on GitHub](https://img.shields.io/badge/source-codellm--devkit%2Fpython--sdk-181717?logo=github&logoColor=white)](https://github.com/codellm-devkit/python-sdk) [![cldk 1.4.0](https://img.shields.io/badge/cldk-1.4.0-3776AB?logo=pypi&logoColor=white)](https://pypi.org/project/cldk/1.4.0/)
5757

58-
_API reference generated from cldk 1.2.0._
58+
_API reference generated from cldk 1.4.0._
5959

6060
## Analysis
6161

@@ -134,6 +134,16 @@ The phantom (external) call targets, imported/required library members the call
134134
points at (e.g. ``node:fs.readFileSync``, ``js-yaml.load``). Useful for source→sink
135135
reachability.
136136

137+
##### `TypeScriptAnalysis.get_synthesized_callables`
138+
139+
```python
140+
get_synthesized_callables() -> Dict[str, TSSynthesizedCallable]
141+
```
142+
143+
The synthesized anonymous-callback endpoints the call graph points at, Jelly-resolved
144+
callbacks the symbol table never names (keyed by their ``<host>:<line:col>`` signature).
145+
Empty under the ``tsc``-only resolver. Materialized so anonymous call edges don't dangle.
146+
137147
##### `TypeScriptAnalysis.get_call_graph_json`
138148

139149
```python
@@ -436,6 +446,7 @@ The root analysis object emitted as analysis.json.
436446
| `symbol_table` | `Dict[str, TSModule]` | |
437447
| `call_graph` | `List[TSCallEdge]` | |
438448
| `external_symbols` | `Dict[str, TSExternalSymbol]` | |
449+
| `synthesized_callables` | `Dict[str, TSSynthesizedCallable]` | |
439450

440451
### `TSCallEdge`
441452

@@ -895,6 +906,30 @@ A symbol referenced or declared in code.
895906
| `lineno` | `int` | |
896907
| `col_offset` | `int` | |
897908

909+
### `TSSynthesizedCallable`
910+
911+
```python
912+
class TSSynthesizedCallable(_Base)
913+
```
914+
915+
A first-party anonymous callback that Jelly resolves as a call-graph endpoint but the symbol
916+
table never names (the canonicalizer returns ``null`` for anonymous functions). Materialized so
917+
that ``call_graph`` edges to anonymous callbacks don't dangle.
918+
919+
Slim, like `TSExternalSymbol`: the map key in ``TSApplication.synthesized_callables`` IS
920+
the synthesized signature ``<nearest-named-enclosing-signature>:<line:col>``, so an edge's
921+
``source``/``target`` byte-matches it just like a real ``TSCallable.signature``. The ``tsc``
922+
resolver emits an empty map; Jelly (the union default) populates it.
923+
924+
#### Attributes
925+
926+
| Name | Type | Description |
927+
| ---- | ---- | ----------- |
928+
| `name` | `str` | |
929+
| `path` | `str` | |
930+
| `start_line` | `int` | |
931+
| `start_column` | `int` | |
932+
898933
### `TSTypeAlias`
899934

900935
```python

0 commit comments

Comments
 (0)