code2graph-rs 0.0.0b3__cp39-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
code2graph/__init__.py
ADDED
|
Binary file
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: code2graph-rs
|
|
3
|
+
Version: 0.0.0b3
|
|
4
|
+
Classifier: Programming Language :: Python :: 3
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Summary: Source code to structural graph facts — Python bindings
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
10
|
+
|
|
11
|
+
# code2graph — Python bindings
|
|
12
|
+
|
|
13
|
+
Python bindings to the [code2graph](https://github.com/nodedb-lab/code2graph) Rust library, which turns
|
|
14
|
+
source files into structural facts: symbols (definitions), references (use sites), and cross-file edges.
|
|
15
|
+
|
|
16
|
+
## Build
|
|
17
|
+
|
|
18
|
+
Inside a virtualenv, from the `bindings/python` directory:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pip install maturin
|
|
22
|
+
maturin develop
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This compiles the Rust extension and installs it into the active virtualenv. The published distribution is named `code2graph-rs` (`pip install code2graph-rs`); the import name is `code2graph`.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import code2graph
|
|
31
|
+
facts = code2graph.extract("src/lib.rs", "pub fn hello() {}")
|
|
32
|
+
print(facts["symbols"])
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`extract(file, source)` returns a dict mirroring the `FileFacts` schema (keys: `symbols`, `references`,
|
|
36
|
+
`scopes`, `bindings`, `ffi_exports`). `SymbolId` values appear as their stable SCIP strings.
|
|
37
|
+
|
|
38
|
+
Resolve facts from multiple files into a cross-file graph with `build_graph`:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import code2graph
|
|
42
|
+
a = code2graph.extract("src/util.rs", "pub fn helper() {}")
|
|
43
|
+
b = code2graph.extract("src/main.rs", "pub fn run() { helper() }")
|
|
44
|
+
graph = code2graph.build_graph([a, b], tier="name")
|
|
45
|
+
print(graph["edges"]) # each edge: from, to, role, confidence, provenance, occ
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`build_graph(files, tier="name")` returns a dict mirroring `CodeGraph` (`symbols` + `edges`). The `tier`
|
|
49
|
+
argument selects the resolver: `"name"` (default, Tier A — fast, recall-first, `NameOnly` confidence) or
|
|
50
|
+
`"scope"` (Tier B — scope-graph path resolution, `Scoped`/`Exact` confidence). The helper
|
|
51
|
+
`language_of(path)` returns the canonical language tag for a path (e.g. `"rust"`), or `None` if the
|
|
52
|
+
extension is unrecognized.
|
|
53
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
code2graph/__init__.py,sha256=6po_kClHPdsahgCis7MVhEdQuJ5jtuCRbVKAs9wtlao,123
|
|
2
|
+
code2graph/code2graph.pyd,sha256=K1lhJOliUbEmG4cUouDQy12vIiqmMt_xMG9nPTB1Cv0,39327232
|
|
3
|
+
code2graph_rs-0.0.0b3.dist-info/METADATA,sha256=Cks-QlYIMspQ9Hn5IEcK9UrQkuL0ZNj0zWeeRyfveng,2085
|
|
4
|
+
code2graph_rs-0.0.0b3.dist-info/WHEEL,sha256=ZiBmjEMKX1iTyJmqXZl_jTcrFdOtPkEbr7SVi1lbRvI,95
|
|
5
|
+
code2graph_rs-0.0.0b3.dist-info/sboms/code2graph-py.cyclonedx.json,sha256=fY0LnPKGu37XM-wmqAOlzyNknLAeMx4fHDPQGaLJMdQ,70668
|
|
6
|
+
code2graph_rs-0.0.0b3.dist-info/RECORD,,
|