Socket
Socket
Sign inDemoInstall

postcss-style-docs

Package Overview
Dependencies
4
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-style-docs

PostCSS plugin for dynamically adding documentation to styles


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
13.8 kB
Created
Weekly downloads
 

Changelog

Source

0.0.7 (2022-05-26)

Features

  • add getDocs function (4a77eec)

Readme

Source

postcss-style-docs

PostCSS plugin for dynamically adding documentation to styles.

The postcss-style-docs pluin will walk through your input CSS and create a map of styles to documentation blocks as a message output.

/**
 * @docs
 * This is a documentation block for the .foo class
 * it can be multiple lines
 */
.foo {
  /* Input example */
}
.foo {
  /* Output example */
}

Usage

Step 1: Install plugin:

npm install --save-dev postcss postcss-style-docs

Step 2: The postcss-style-docs plugin works best when manually calling postcss.process which enables users to get data out of the plugin:

import postcss from 'postcss';
import { getDocs, styleDocsPlugin } from './lib/cjs/index';

const inputCSS = `
/**
 * @docs
 * We're doing something really fancy and our users are going
 * to love it.
 */
.something-fancy {
  color: tomato;
}

/** @docs Make it pop */
.something-fancy--pop {
  background: papayawhip;
}
`;

const { css, messages } = await postcss([
  styleDocsPlugin()
]).process(inputCSS, { from: undefined });

const docs = getDocs(messages);

console.log(docs.size); // 2
console.log(docs.get('.something-fancy')); // 'We're doing something really fancy and our users are going to love it'
console.log(docs.get('.something-fancy--pop')); // 'Make it pop'

Keywords

FAQs

Last updated on 26 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc