Expand description
§code-ranker-plugin-api
The contract everything in Code Ranker builds on: a generic property-graph
model plus the LanguagePlugin trait. This crate is the foundation — it
depends on nothing else from Code Ranker and re-exports nothing. Every
other crate (graph operations, complexity, language plugins, viewer, cli)
depends on this.
§Model
Analysis produces a Graph of **Node**s connected by **Edge**s.
A node is anything we analyze: today a source file (kind == "file"),
tomorrow a folder, module, function, variable or line — with no model
change. kind is a free-form String (the plugin’s own vocabulary);
the core never interprets it, it only stores and projects.
Both nodes and edges carry free-form Attributes (string key →
scalar AttrValue). There is no fixed, file/language-specific field set:
the plugin chooses keys (path, loc, visibility, version, or
language-specific ones), the orchestrator adds computed keys (metrics,
cycle), and the core reads only the keys it understands. Each level describes
its keys with an AttributeSpec dictionary (type + label/hint), so the UI
knows what each key means and what it can do with it.
§Responsibilities
A LanguagePlugin is a pure parser: it turns a workspace into nodes +
edges at a requested level (by name; see Level). It does not
compute metrics — complexity / cycles / Henry-Kafura / stats are filled in
centrally, for all languages, by the orchestrator. The plugin also describes
its edge kinds (EdgeKindSpec) and attribute keys
(AttributeSpec), so the core scores, draws and labels unknown
kinds/keys without hardcoding their names.
Re-exports§
pub use attrs::AttrValue;pub use attrs::Attributes;pub use attrs::ValueType;pub use edge::Edge;pub use graph::Graph;pub use level::AttributeGroup;pub use level::AttributeSpec;pub use level::CycleKindSpec;pub use level::Direction;pub use level::EdgeKindSpec;pub use level::Level;pub use level::NodeKindSpec;pub use level::SpecRow;pub use level::Thresholds;pub use level::attr_dict;pub use level::group;pub use node::Node;pub use node::NodeId;pub use plugin::LanguagePlugin;pub use plugin::Options;pub use plugin::PluginInput;pub use plugin::Preset;
Modules§
- attrs
- Free-form attributes for nodes and edges — a string-keyed map of scalar values — plus the value-type tag used by the attribute dictionaries.
- edge
- A
Edge— a directed edge between two nodes (an import, a call, a containment, …). Thekindis the plugin’s own vocabulary; its semantics (flow vs structural, label, hint) come from a matchingEdgeKindSpec. - graph
Graph— what a plugin’sanalyzereturns: pure structure, nodes + edges, and nothing computed.- level
- Level descriptors + the semantics dictionaries that let the core handle
unknown kinds/keys without hardcoding their names, and let the UI render any
language/metric set purely from data: edge kinds (
EdgeKindSpec), node/edge attributes (AttributeSpec, grouped viaAttributeGroup), node kinds (NodeKindSpec) and cycle kinds (CycleKindSpec). - log
- Shared stderr progress/timing log.
- node
- The
Node— anything we analyze. Today a source file (kind == "file"), later a folder / module / function / variable / line, with no model change. - plugin
- The
LanguagePlugintrait +Options+Preset.
Functions§
- default_
cycle_ kinds - The generic cycle-kind vocabulary (
mutual/chain). - default_
node_ kinds - The generic node-kind palette every file-based plugin seeds its level with:
file(a project source unit, blue) andexternal(a third-party library, amber, flagged external). A plugin may recolor or add kinds.