lib/site-data
lib/site-data.js
Functions(4)
Assembles the full site-data payload from already-computed pieces --
this function does no extraction/analysis of its own, it only shapes
data callers already have.
| Parameter | Type | Optional | Description |
|---|---|---|---|
modules | object[] | - extractModule() output, one per file. | |
quality | {result: object, graph?: object, orphans?: string[], snapshots?: object[]}|null | - computeQualityEmbedData() output, or null if `--quality` wasn't used. | |
meta | {projectName: string, version: string, sourceUrl?: string} |
Returns:
object — the full payload, ready for JSON.stringify().Signature
buildSiteData(modules: any, quality: any, meta: any): any
| Parameter | Type | Optional | Description |
|---|---|---|---|
dataPath | string | - path to the canonical site-data.json. |
Returns:
string — the sibling history directory for that path.Signature
historyDirFor(dataPath: any): any
Writes `payload` to `dataPath`, NEVER silently overwriting a prior
generation (story-file-detail-redesign AC5): if `dataPath` already
exists, it is moved (not deleted) into a sibling `<name>-history/`
directory under an ISO-timestamped filename -- same timestamp
convention `code-multivitals`'s own `saveSnapshot()` already uses in
this codebase -- before the new payload is written to the canonical
path. Collision-safe: if two writes land in the same millisecond (e.g.
rapid successive test runs), a numeric suffix is appended rather than
clobbering the preserved copy.
| Parameter | Type | Optional | Description |
|---|---|---|---|
dataPath | string | ||
payload | object |
Returns:
{path: string, preserved: string|null} — the canonical path written, and the history path of the preserved prior file (or null if none existed).Signature
writeSiteData(dataPath: any, payload: any): any
Reads + validates a site-data JSON file. Throws a clear, actionable
Error (never a raw parse/ENOENT stack trace) on failure -- same contract
as `lib/quality.js`'s `CODE_MULTIVITALS_NOT_INSTALLED`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
dataPath | string |
Returns:
object — the parsed, validated payload.Signature
loadSiteData(dataPath: any): any
Variables & Constants(14)
const fs: any
constlib/site-data.js
----------------------------------------
story-file-detail-redesign / adr-phase-l-file-detail-and-site-data.md
A single JSON artifact that captures everything `buildSite()` needs to
regenerate the doc site: module data (same shape `--json`/`docs.json`
already publishes -- reused, not redefined) plus quality/import-graph/
snapshot data (the exact shape `computeQualityEmbedData()` in
bin/gen-docs.js already produces).
Two things this module is deliberately NOT:
- It does not touch `docs.json` (the existing `--json` flag's output).
That's a separate, already-published contract -- see the ADR's
Decision 4.
- It is not itself a renderer. `loadSiteData()` only reads and
validates; turning the result back into HTML is `bin/gen-docs.js`'s
job (calling the same `buildSite()` the normal path already uses).
Signature
const fs: any