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 🙏

© 2024 – Pkg Stats / Ryan Hefner

css-vars-docs

v1.1.1

Published

Generates a comment block with all CSS variables from the specified file to improve readability and provide documentation. The block is added at the beginning of the file, or in the first <style> block for non-CSS files, if available.

Downloads

192

Readme

CssVarsDocs

Generates a comment block with all CSS variables from the specified file to improve readability and provide documentation. The block is added at the beginning of the file, or in the first <style> block for non-CSS files if available.

Installation (not required when using npx or pnpx)

As a Project Dependency:

npm install -D css-vars-docs

or

pnpm add -D css-vars-docs

Global Installation:

npm install -g css-vars-docs

or

pnpm add -g css-vars-docs

Usage

Without Installation (Using npx or pnpx):

npx css-vars-docs [options]

or

pnpx css-vars-docs [options]

With Local Installation (Using npm run or pnpm):

After installation as a project dependency (-D), you can run it as follows:

npx css-vars-docs [options]  # npm project
pnpm css-vars-docs [options] # pnpm project

With Global Installation:

When installed globally, use any of the following commands:

css-vars-docs [options]
cssvarsdocs [options]
cssvd [options]

Available Options for the CLI

| Option | Description | | ------------------------------------- | ------------------------------------------------------------------------------------------- | | -f, --files <files> | Files to process, separated by spaces or commas | | -n, --new-lines-before-group | Add a new line between variable groups | | -t, --title <title> | Header for the comment block | | -b, --block-identifier <identifier> | Unique identifier for generated blocks | | -i, --indent <indent> | Default indentation | | -is, --indent-style | Add extra indentation in <style> blocks | | -ex, --exclude-node-modules | Exclude node_modules by default | | -lc, --load-config | Boolean. Set to false to ignore configuration files (default: true, loads if available) | | -lp, --log-prefix <prefix> | Prefix for log messages | | -ll, --log-level <level> | Log level: 0 = errors only, 1 = changes only, 2 = verbose, 3 = debug | | -r, --remove | Remove existing comments from the files | | -p, --preview | Perform a dry run without writing to files |


Configuration

CssVarsDocs uses a default configuration to process files. This configuration can be customized using CLI options, or by creating a configuration file in the root directory of the project, allowing default configuration overrides to be retained across runs without the need to pass additional options.

Supported Configuration File Names:

css-vars-docs.config.{js,mjs,cjs}
cssvarsdocs.config.{js,mjs,cjs}
cssvd.config.{js,mjs,cjs}

Configuration hierarchy:

  1. Default settings
  2. Configuration file (if present)
  3. CLI options (highest priority)

Example of using a configuration file

Create a configuration file, for example css-vars-docs.config.mjs:

export default {
    indent: '    ',
    files: ['src/assets/*.css', 'src/assets/*.scss', 'src/*.html'],
    logLevel: 0
};

Run the command without additional arguments:

npx css-vars-docs

or

css-vars-docs

For a test run, simply pass -p or --preview

npx css-vars-docs -p

More Examples

Process a specific file, style.css:

css-vars-docs -f style.css

Process all .css files in the assets directory:

css-vars-docs -f assets/**/*.css

Process all .css files in assets with logLevel set to 3:

css-vars-docs -f assets/**/*.css -ll 3

Process all .css files in assets and all .vue files in components:

css-vars-docs -f "assets/**/*.css,components/*.vue"

Process all files with logLevel 3:

css-vars-docs -ll 3

Remove comments from all files with logLevel 3:

css-vars-docs -r -ll 3

Example of using the Postcss plugin

// postcss.config.js
const cssVarsDocs = require('css-vars-docs');

module.exports = {
    plugins: [
        cssVarsDocs({
            logLevel: 3
        })
        // other plugins
    ]
};

Example of using in your code

const CssVarsDocs = require('css-vars-docs');

const cssVarsDocs = new CssVarsDocs({
    // options
});

cssVarsDocs.processFiles();

License

This project is licensed under the MIT License.

Notes

This tool modifies files directly, so please use with caution and consider committing your code beforehand if necessary.