| 34 | def rust_module_key(crate: str, src_root: Path, path: Path) -> str: |
| 35 | """Rust-style module path, e.g. ``openquant::util::volatility``. |
| 36 | |
| 37 | Keying by crate + path (not by ``path.stem``) is required now that the scan |
| 38 | recurses and covers more than one crate: several module names, such as |
| 39 | ``filters`` and ``volatility``, exist in both crates and would otherwise |
| 40 | silently overwrite each other. |
| 41 | """ |
| 42 | parts = path.relative_to(src_root).with_suffix("").parts |
| 43 | return "::".join((crate,) + parts) |
| 44 | |
| 45 | |
| 46 | def scan_rust() -> dict[str, list[str]]: |
| 47 | out: dict[str, list[str]] = {} |
| 48 | for crate in RUST_CRATES: |
| 49 | src_root = CRATES / crate / "src" |
| 50 | for path in sorted(src_root.rglob("*.rs")): |
| 51 | # Crate/module roots only re-export; they declare no API of their own. |
| 52 | if path.name in {"lib.rs", "mod.rs"}: |
| 53 | continue |
| 54 | module = rust_module_key(crate, src_root, path) |
| 55 | fns: list[str] = [] |
| 56 | for line in path.read_text(encoding="utf-8").splitlines(): |