Skip to main content

Module documentation

Module documentation 

Source
Expand description

#847: the documentation-model query — a file’s declarations aggregated into a rendered reference page (“live rustdoc for Bynk”), for the VS Code “Show Documentation” webview.

A pure, read-only IDE query. It does two things and reuses everything else:

  • Traversal. It walks the parsed unit’s items with an exhaustive match on CommonsItem — the same shape bynk-lsp’s document_symbols walk uses — so a new declaration kind is a compile error here, in push_item, not a silently-missed row on the page. (Risk: “a new doc-bearing node kind is added and silently missed by the aggregator.”)

  • Per-declaration rendering. Each entry’s Markdown (its fenced signature plus its doc-comment prose) is produced by hover’s own describe_* assembly in crate::symbols — not a parallel renderer. Sharing that code path is what keeps the doc page from drifting from hover. (Risk: “divergence from hover — two code paths formatting the same doc differently.”)

What this module adds on top is the page structure: the declaration’s heading name, its nesting depth (top-level item → its ops/handlers), a documented flag driving the “no documentation” coverage placeholder, and the name span each heading links back to (click-to-code). The Markdown is rendered — HTML-disabled — by the webview; nothing here emits HTML.

Tier 1 (Decision A) was file-scoped: documentation_model builds the model from one file’s text, exactly like document_symbols. #1885 adds documentation_model_merged, which merges every file of a multi-file unit into one page. That is unambiguous now that a unit carries at most one module doc (bynk.project.duplicate_module_doc): the page’s lede is that doc, from whichever file has it, and its entries are every file’s declarations, each tagged with the file it came from.

Structs§

DocEntry
One declaration on the page: a heading, its rendered signature+doc Markdown, and where it lives in the source.
DocModel
A file’s declarations rendered as an ordered, hierarchical reference page.

Functions§

documentation_model
Build the documentation model for a single file’s text. Returns None when the file has no recognisable unit header, or is a test suite (suite units are not a documentation unit in Tier 1 — their case/stub members have no describe_* renderer, and a doc page for tests is out of scope).
documentation_model_merged
#1885: the documentation model for the unit that primary declares, merged across every file in files that declares the same unit.