@cssdoc/index
v0.16.2
Published
A queryable semantic index over the @cssdoc/core model, plus a host-agnostic Usage abstraction and source spans — the shared data layer for cssdoc's linters and language server.
Maintainers
Readme
@cssdoc/index
A queryable semantic index over the @cssdoc/core model — the shared data layer every
cssdoc linter and the language server query. It adds the two cross-cutting concerns those tools need:
- a host-agnostic
Usageabstraction (ClassUsage,PropertyUsage) so HTML, JSX, template literals, and CSS selectors all feed the same providers; and - optional source spans, built in a dedicated PostCSS pass (so
@cssdoc/corestays position-free), powering diagnostics locations, hover ranges, and go-to-definition.
Usage
import { createIndex } from "@cssdoc/index";
const index = createIndex(css, { file: "components.css" });
index.componentForClass(".button"); // → the button record
index.isModifier(".button", "-color-x"); // → boolean
index.deprecationOf(".button", "-old"); // → { canonical } | undefined
index.location("button", "modifier:-color-secondary"); // → { file, span } | undefinedcreateIndex(css) includes spans; indexFromEntries(entries) builds a lookup-only index from a model
snapshot (index.toManifest()), without spans.
License
MIT
