npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cssdoc/core

v0.14.2

Published

A generic CSS documentation extractor: parse doc-comments + the CSS AST into a serializable model (TSDoc, for CSS).

Readme

@cssdoc/core

TSDoc, for CSS. A small, framework-agnostic documentation extractor: parse a doc-comment grammar plus the CSS AST into a serializable model, then build whatever emitter you like on top (markdown, JSON, a component gallery) — the way typedoc-plugin-markdown builds on TypeDoc's reflections.

There's no modern, maintained "TypeDoc for plain CSS" (CSSdoc is abandoned, KSS-node is dated, SassDoc is Sass-only). This is the missing core: it reads structured comments and derives the machine facts from the actual selectors, so the docs can't drift from the shipping CSS.

Install

npm i -D @cssdoc/core

Usage

import { parseCssDocs, toJson } from "@cssdoc/core";
import { readFileSync } from "node:fs";

const model = parseCssDocs(readFileSync("dist/components.css", "utf8"));
writeFileSync("css-docs.json", toJson(model));

Generate @custom-media declarations from @structure profile references:

import { buildCustomMediaDeclarations, parseCssDocs } from "@cssdoc/core";

const model = parseCssDocs(css);
const customMedia = buildCustomMediaDeclarations(model, {
  resolveValue: (profile) => {
    if (profile === "--top-nav") return "(width >= 64rem)";
    return true;
  },
});

// @custom-media --top-nav (width >= 64rem);

Or compile directly from CSS in one step:

import { compileCustomMediaDeclarations } from "@cssdoc/core";

const declarations = compileCustomMediaDeclarations(css, {
  resolveValue: (profile) => (profile === "--top-nav" ? "(width >= 64rem)" : true),
});

parseCssDocs(css) returns one CssDocEntry per record. It is AST-first — modifiers, sub-element parts, consumed and declared custom properties, and deprecated-alias links are extracted from the selectors, so they never drift. Authored doc comments supply only prose (summaries, descriptions) and delimit one component from the next.

The doc-comment grammar

A /** … */ block above a component's rules. Records are delimited by @component/@name. The tag vocabulary adopts the Custom Elements Manifest names (@cssproperty, @csspart, @cssstate) where they exist, so it's standards-aligned:

/**
 * @component button
 * @summary An accessible action control.
 * @modifier -color-secondary — A lower-emphasis action.
 * @part .icon — A leading glyph.
 * @cssproperty --ring <color> — The focus-ring colour.
 * @deprecated Use the button utility instead.
 * @demo self:button
 */
.button {
  /* … */
}
.button .icon {
  /* … */
}
.button.-color-secondary {
  /* … */
}

| Tag | Meaning | | ------------------------------------------ | --------------------------------------------------------------------------- | | @component / @name <id> | Names the record (required; marks a boundary). | | @class <selector> | An explicit base class (otherwise inferred from the first bare-class rule). | | @summary <text> | One-line intro. | | @modifier -<x> — <desc> | Prose for a modifier (the list itself is AST-derived). | | @part / @csspart .<x> — <desc> | Prose for a sub-element part. | | @cssproperty --<x> [<syntax>] — <desc> | A declared custom property. | | @cssstate <x> — <desc> | A component state. | | @example, @deprecated, @demo, @see | As in TSDoc. |

Unknown tags are ignored, so the grammar degrades gracefully.

Model

parseCssDocs returns CssDocEntry[]:

interface CssDocEntry {
  name: string;
  className: string;
  summary?: string;
  modifiers: {
    name: string;
    prop: string;
    value?: string;
    description?: string;
    deprecated?: { canonical: string };
  }[];
  parts: { name: string; description?: string }[];
  cssPropertiesConsumed: { name: string; description?: string }[];
  cssPropertiesDeclared: { name: string; syntax?: string; description?: string }[];
  examples: string[];
  demo?: string;
  deprecated?: string;
  see: string[];
  usage?: string;
  compat: string[];
  related: { name: string; description?: string }[];
  source?: { file?: string; line?: number; column?: number };
}

Records default to splitting on @component/@name; pass parseCssDocs(css, { isRecordBoundary }) to delimit on something else (e.g. a per-component header comment).

License

MIT