drefs 0.1.0__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.
- drefs-0.1.0/.github/workflows/ci.yml +40 -0
- drefs-0.1.0/.github/workflows/release.yml +83 -0
- drefs-0.1.0/.gitignore +8 -0
- drefs-0.1.0/.pre-commit-config.yaml +7 -0
- drefs-0.1.0/BENCHMARKS.md +49 -0
- drefs-0.1.0/CHANGELOG.md +15 -0
- drefs-0.1.0/CONTRIBUTING.md +73 -0
- drefs-0.1.0/Cargo.lock +854 -0
- drefs-0.1.0/Cargo.toml +23 -0
- drefs-0.1.0/LICENSE +21 -0
- drefs-0.1.0/PKG-INFO +96 -0
- drefs-0.1.0/README.md +75 -0
- drefs-0.1.0/ROADMAP.md +21 -0
- drefs-0.1.0/SECURITY.md +7 -0
- drefs-0.1.0/assets/benchmark-dark-v3.svg +18 -0
- drefs-0.1.0/assets/benchmark-light-v3.svg +18 -0
- drefs-0.1.0/editors/pycharm/build.gradle.kts +50 -0
- drefs-0.1.0/editors/pycharm/gradle/wrapper/gradle-wrapper.jar +0 -0
- drefs-0.1.0/editors/pycharm/gradle/wrapper/gradle-wrapper.properties +7 -0
- drefs-0.1.0/editors/pycharm/gradle.properties +2 -0
- drefs-0.1.0/editors/pycharm/gradlew +234 -0
- drefs-0.1.0/editors/pycharm/gradlew.bat +89 -0
- drefs-0.1.0/editors/pycharm/settings.gradle.kts +1 -0
- drefs-0.1.0/editors/pycharm/src/main/kotlin/com/drefs/intellij/DrefsAnnotator.kt +144 -0
- drefs-0.1.0/editors/pycharm/src/main/kotlin/com/drefs/intellij/DrefsPatterns.kt +77 -0
- drefs-0.1.0/editors/pycharm/src/main/kotlin/com/drefs/intellij/DrefsPythonReference.kt +115 -0
- drefs-0.1.0/editors/pycharm/src/main/kotlin/com/drefs/intellij/DrefsReferenceContributor.kt +20 -0
- drefs-0.1.0/editors/pycharm/src/main/kotlin/com/drefs/intellij/DrefsReferenceProvider.kt +131 -0
- drefs-0.1.0/editors/pycharm/src/main/resources/META-INF/plugin.xml +23 -0
- drefs-0.1.0/justfile +49 -0
- drefs-0.1.0/pyproject.toml +34 -0
- drefs-0.1.0/scripts/check_pattern_sync.sh +66 -0
- drefs-0.1.0/scripts/generate_benchmark_svg.py +103 -0
- drefs-0.1.0/src/config.rs +136 -0
- drefs-0.1.0/src/diagnostic.rs +181 -0
- drefs-0.1.0/src/discover.rs +113 -0
- drefs-0.1.0/src/extract.rs +287 -0
- drefs-0.1.0/src/fast_scan.rs +209 -0
- drefs-0.1.0/src/graph.rs +532 -0
- drefs-0.1.0/src/inventory.rs +163 -0
- drefs-0.1.0/src/main.rs +172 -0
- drefs-0.1.0/src/parse.rs +496 -0
- drefs-0.1.0/src/patterns.rs +71 -0
- drefs-0.1.0/src/util.rs +56 -0
- drefs-0.1.0/tests/fixtures/decorated_classes/pyproject.toml +2 -0
- drefs-0.1.0/tests/fixtures/decorated_classes/src/pkg/__init__.py +2 -0
- drefs-0.1.0/tests/fixtures/decorated_classes/src/pkg/sub/__init__.py +4 -0
- drefs-0.1.0/tests/fixtures/decorated_classes/src/pkg/sub/base.py +33 -0
- drefs-0.1.0/tests/fixtures/decorated_classes/src/pkg/sub/child.py +24 -0
- drefs-0.1.0/tests/fixtures/decorated_classes/src/pkg/sub/config.py +16 -0
- drefs-0.1.0/tests/fixtures/edge_cases/pyproject.toml +3 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/__init__.py +7 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/mixins/__init__.py +1 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/mixins/serializable.py +13 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/models.py +51 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/reexport/__init__.py +3 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/reexport/layer_b.py +3 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/reexport/layer_c.py +14 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/sphinx_style.py +24 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/sub/__init__.py +4 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/sub/deep.py +25 -0
- drefs-0.1.0/tests/fixtures/edge_cases/src/pkg/sub/helpers.py +23 -0
- drefs-0.1.0/tests/fixtures/multiline_imports/pyproject.toml +3 -0
- drefs-0.1.0/tests/fixtures/multiline_imports/src/pkg/__init__.py +9 -0
- drefs-0.1.0/tests/fixtures/multiline_imports/src/pkg/helpers.py +6 -0
- drefs-0.1.0/tests/fixtures/multiline_imports/src/pkg/models.py +13 -0
- drefs-0.1.0/tests/fixtures/multiline_imports/src/pkg/views.py +10 -0
- drefs-0.1.0/tests/fixtures/native_syntax/pyproject.toml +3 -0
- drefs-0.1.0/tests/fixtures/native_syntax/src/pkg/__init__.py +5 -0
- drefs-0.1.0/tests/fixtures/native_syntax/src/pkg/models.py +25 -0
- drefs-0.1.0/tests/fixtures/native_syntax/src/pkg/services.py +59 -0
- drefs-0.1.0/tests/fixtures/wildcard_imports/pyproject.toml +3 -0
- drefs-0.1.0/tests/fixtures/wildcard_imports/src/pkg/__init__.py +4 -0
- drefs-0.1.0/tests/fixtures/wildcard_imports/src/pkg/helpers.py +11 -0
- drefs-0.1.0/tests/fixtures/wildcard_imports/src/pkg/models.py +23 -0
- drefs-0.1.0/tests/fixtures/wildcard_imports/src/pkg/views.py +16 -0
- drefs-0.1.0/tests/integration.rs +320 -0
- drefs-0.1.0/uv.lock +8 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: true
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
lint:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
18
|
+
with:
|
|
19
|
+
components: clippy, rustfmt
|
|
20
|
+
- uses: Swatinem/rust-cache@v2
|
|
21
|
+
- run: cargo fmt --check
|
|
22
|
+
- run: cargo clippy -- -D warnings
|
|
23
|
+
|
|
24
|
+
test:
|
|
25
|
+
needs: lint
|
|
26
|
+
strategy:
|
|
27
|
+
matrix:
|
|
28
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
29
|
+
runs-on: ${{ matrix.os }}
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
33
|
+
- uses: Swatinem/rust-cache@v2
|
|
34
|
+
- run: cargo test
|
|
35
|
+
|
|
36
|
+
pattern-sync:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- run: ./scripts/check_pattern_sync.sh
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
include:
|
|
17
|
+
- os: ubuntu-latest
|
|
18
|
+
target: x86_64-unknown-linux-gnu
|
|
19
|
+
manylinux: "2_28"
|
|
20
|
+
- os: ubuntu-latest
|
|
21
|
+
target: aarch64-unknown-linux-gnu
|
|
22
|
+
manylinux: "2_28"
|
|
23
|
+
- os: macos-latest
|
|
24
|
+
target: x86_64-apple-darwin
|
|
25
|
+
- os: macos-latest
|
|
26
|
+
target: aarch64-apple-darwin
|
|
27
|
+
- os: windows-latest
|
|
28
|
+
target: x86_64-pc-windows-msvc
|
|
29
|
+
runs-on: ${{ matrix.os }}
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- uses: actions/setup-python@v5
|
|
33
|
+
with:
|
|
34
|
+
python-version: "3.12"
|
|
35
|
+
- uses: PyO3/maturin-action@v1
|
|
36
|
+
with:
|
|
37
|
+
target: ${{ matrix.target }}
|
|
38
|
+
args: --release --out dist
|
|
39
|
+
manylinux: ${{ matrix.manylinux || 'auto' }}
|
|
40
|
+
- uses: actions/upload-artifact@v4
|
|
41
|
+
with:
|
|
42
|
+
name: wheels-${{ matrix.target }}
|
|
43
|
+
path: dist/*.whl
|
|
44
|
+
|
|
45
|
+
sdist:
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@v4
|
|
49
|
+
- uses: PyO3/maturin-action@v1
|
|
50
|
+
with:
|
|
51
|
+
command: sdist
|
|
52
|
+
args: --out dist
|
|
53
|
+
- uses: actions/upload-artifact@v4
|
|
54
|
+
with:
|
|
55
|
+
name: sdist
|
|
56
|
+
path: dist/*.tar.gz
|
|
57
|
+
|
|
58
|
+
publish:
|
|
59
|
+
needs: [build, sdist]
|
|
60
|
+
runs-on: ubuntu-latest
|
|
61
|
+
environment: release
|
|
62
|
+
steps:
|
|
63
|
+
- uses: actions/download-artifact@v4
|
|
64
|
+
with:
|
|
65
|
+
path: dist
|
|
66
|
+
merge-multiple: true
|
|
67
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
68
|
+
with:
|
|
69
|
+
packages-dir: dist/
|
|
70
|
+
|
|
71
|
+
github-release:
|
|
72
|
+
needs: [build, sdist]
|
|
73
|
+
runs-on: ubuntu-latest
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/checkout@v4
|
|
76
|
+
- uses: actions/download-artifact@v4
|
|
77
|
+
with:
|
|
78
|
+
path: dist
|
|
79
|
+
merge-multiple: true
|
|
80
|
+
- uses: softprops/action-gh-release@v2
|
|
81
|
+
with:
|
|
82
|
+
files: dist/*
|
|
83
|
+
generate_release_notes: true
|
drefs-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Benchmarks
|
|
2
|
+
|
|
3
|
+
Benchmarks comparing drefs against `mkdocs build --strict` for validating cross-references.
|
|
4
|
+
|
|
5
|
+
drefs checks cross-references only. `mkdocs build --strict` renders the entire documentation site (Markdown processing, HTML generation, search index, etc.), which includes cross-reference validation as a side effect.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
- Apple M1 Pro, 16 GB RAM
|
|
10
|
+
- macOS 15.7.1
|
|
11
|
+
- Rust 1.94.0 (release build)
|
|
12
|
+
- Measured with [hyperfine](https://github.com/sharkdp/hyperfine)
|
|
13
|
+
|
|
14
|
+
## Results
|
|
15
|
+
|
|
16
|
+
### tinygrad (697 Python files, 32k stars)
|
|
17
|
+
|
|
18
|
+
Validating cross-references in [tinygrad/tinygrad](https://github.com/tinygrad/tinygrad):
|
|
19
|
+
|
|
20
|
+
| Command | Mean | Min | Max |
|
|
21
|
+
|:---|---:|---:|---:|
|
|
22
|
+
| `drefs .` | 110 ms | 98 ms | 125 ms |
|
|
23
|
+
| `mkdocs build --strict` | 51.0 s | 48.3 s | 52.5 s |
|
|
24
|
+
|
|
25
|
+
**~460x faster.**
|
|
26
|
+
|
|
27
|
+
### httpx (60 Python files, 13k stars)
|
|
28
|
+
|
|
29
|
+
Validating cross-references in [encode/httpx](https://github.com/encode/httpx):
|
|
30
|
+
|
|
31
|
+
| Command | Mean | Min | Max |
|
|
32
|
+
|:---|---:|---:|---:|
|
|
33
|
+
| `drefs .` | 19 ms | 16 ms | 50 ms |
|
|
34
|
+
| `mkdocs build --strict` | 872 ms | 845 ms | 921 ms |
|
|
35
|
+
|
|
36
|
+
**~45x faster.**
|
|
37
|
+
|
|
38
|
+
## Methodology
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# drefs (release build)
|
|
42
|
+
cargo build --release
|
|
43
|
+
hyperfine --warmup 3 --ignore-failure './target/release/drefs .'
|
|
44
|
+
|
|
45
|
+
# mkdocs build --strict
|
|
46
|
+
hyperfine --warmup 3 '.venv/bin/mkdocs build --strict'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
drefs and `mkdocs build --strict` are not doing identical work. drefs validates cross-references against source code symbols. `mkdocs build --strict` renders an entire documentation site, which happens to catch some broken references along the way. The comparison shows how fast you can get cross-reference validation without waiting for a full docs build.
|
drefs-0.1.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
Initial release.
|
|
6
|
+
|
|
7
|
+
- MkDocs cross-reference checking (`[text][pkg.mod.Class]`, `[path][]`)
|
|
8
|
+
- Sphinx cross-reference checking (`:class:`, `:func:`, `:meth:`, etc.)
|
|
9
|
+
- drefs-native syntax (`[Symbol]`, `` [`Symbol`] ``) with short name resolution via imports
|
|
10
|
+
- Zero-config auto-detection of src layout and doc style
|
|
11
|
+
- Symbol graph with re-export resolution, inheritance chains, `self.x` attributes
|
|
12
|
+
- External symbol validation via Sphinx `objects.inv` inventories
|
|
13
|
+
- Ruff-compatible output format (`file:line:col: DREF001 message`)
|
|
14
|
+
- PyCharm plugin with Ctrl+Click navigation, syntax highlighting, and squiggles
|
|
15
|
+
- LSP server for editor integration
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Contributing to drefs
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
- [Rust toolchain](https://rustup.rs/) (stable)
|
|
6
|
+
- [uv](https://docs.astral.sh/uv/) for Python package management
|
|
7
|
+
- JDK 21+ (only for PyCharm plugin development)
|
|
8
|
+
|
|
9
|
+
## Development Setup
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
git clone https://github.com/scriptogre/drefs.git
|
|
13
|
+
cd drefs
|
|
14
|
+
cargo build
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Running Tests
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# All tests (unit + integration)
|
|
21
|
+
cargo test
|
|
22
|
+
|
|
23
|
+
# Unit tests only
|
|
24
|
+
cargo test --bin drefs
|
|
25
|
+
|
|
26
|
+
# Integration tests only
|
|
27
|
+
cargo test --test integration
|
|
28
|
+
|
|
29
|
+
# A specific test
|
|
30
|
+
cargo test native_syntax
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Linting
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
cargo fmt --check
|
|
37
|
+
cargo clippy
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Project Structure
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
src/
|
|
44
|
+
main.rs # CLI entry point (clap)
|
|
45
|
+
config.rs # pyproject.toml config loading
|
|
46
|
+
discover.rs # .py file discovery and module path mapping
|
|
47
|
+
parse.rs # tree-sitter Python AST parsing
|
|
48
|
+
extract.rs # Cross-reference pattern extraction (regex)
|
|
49
|
+
graph.rs # Symbol graph data structures and resolution
|
|
50
|
+
diagnostic.rs # Reference validation and error reporting
|
|
51
|
+
inventory.rs # Sphinx objects.inv parsing
|
|
52
|
+
lsp.rs # Language Server Protocol support
|
|
53
|
+
tests/
|
|
54
|
+
integration.rs # Integration tests
|
|
55
|
+
fixtures/ # Test project fixtures
|
|
56
|
+
editors/
|
|
57
|
+
pycharm/ # PyCharm/IntelliJ plugin (Kotlin)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## PyCharm Plugin
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
cd editors/pycharm
|
|
64
|
+
./gradlew buildPlugin
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The built plugin zip will be at `build/distributions/drefs-pycharm-*.zip`.
|
|
68
|
+
|
|
69
|
+
## Test Fixtures
|
|
70
|
+
|
|
71
|
+
Test fixtures are minimal Python projects in `tests/fixtures/`. Each has a `pyproject.toml` and a `src/pkg/` directory. Integration tests run `drefs` against these fixtures and assert on the output.
|
|
72
|
+
|
|
73
|
+
To add a new test case, create a fixture directory and add tests in `tests/integration.rs`.
|