Skip to content

scriptogre/drefs

Repository files navigation

drefs

CI PyPI Python versions License: MIT

An extremely fast Python docstring cross-reference checker, written in Rust.

uvx drefs .
src/models.py:12:5: DREF001 Unresolved docstring reference `pkg.mdoels.User`. Did you mean `pkg.models.User`?
src/views.py:30:5: DREF001 Unresolved docstring reference `Nonexistent`. No import or definition found in this file
Found 2 errors.

Shows a bar chart with benchmark results.

Validating cross-references in tinygrad (697 Python files). ~460x faster than mkdocs build --strict.

Supported syntax

drefs auto-detects the syntax you use:

  • MkDocs: [text][pkg.mod.Class], [pkg.mod.Class][]
  • Sphinx: :class:`pkg.mod.Class`, :func:`pkg.mod.func`
  • Rust-style: [Symbol], [`Symbol`], [pkg.mod.Class]

[User] resolves via the current file's imports. [pkg.models.User] resolves directly. Escape with \[not a ref\].

drefs understands __init__.py re-exports, inheritance chains, and self.x attributes.

Configuration

Optional. Add to pyproject.toml:

[tool.drefs]
src = ["src"]                  # auto-detected if omitted
style = "auto"                 # "mkdocs" | "sphinx" | "auto"
inventories = [                # validate against external symbols
    "https://docs.python.org/3/objects.inv",
]

Editor support

PyCharm / IntelliJ

  • Ctrl+Click on each segment of a dotted path
  • Syntax highlighting on cross-references
  • Red squiggles on broken references

Install from editors/jetbrains/build/distributions/drefs-pycharm-*.zip via Settings > Plugins > Install from Disk.

Contributing

See CONTRIBUTING.md.

License

MIT

About

An extremely fast Python docstring cross-reference checker, written in Rust.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors