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

grunt-panopta-style-guide-generator

v0.0.5

Published

A style-guide generator

Downloads

1

Readme

grunt-emo (Beta)

A style-guide generator that uses Swig.js

Emo is a tool that scrapes documention from your source files which it then uses to generate a style-guide. Emo is capable of gathering documention from, essentially, any type of file, which allows you to easily document your JavaScript, HTML, or whatever other type of component that you'd like documented.

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-emo --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-emo');

The "emo" task

Overview

In your project's Gruntfile, add a section named emo to the data object passed into grunt.initConfig().

grunt.initConfig({
    emo: {
        main: {
            options: {
                path: { ... },
                copy: {
                    'assets/css/modern.css': 'web/assets/css/modern.css'
                }
            },
            files: [
                {
                    expand: true,
                    cwd: '',
                    src: [
                        'assets/scss/**/*.scss',
                        'assets/scss/**/*.less',
                        'assets/css/**/*.css'
                    ]
                }
            ]
        }
    }
});

Options

options.path

Type: Object Default value: { src: '_styleguide/', dest: 'docs/styleguide/' }

Paths used by the style-guide generator

options.path.src

Type: String Default value: _styleguide/

The location the styleguide source code is to be placed. Must include a trailing slash.

options.path.dest

Type: String Default value: docs/styleguide/

The location the styleguide will be built to. Must include a trailing slash.

options.copy

Type: Object Default value: undefined

An object containing assets that should be copied over to the style-guide destination folder.

Note the example below. The right hand assignment is the path to the asset that should be copied; the left hand assignment is the path to where the asset should be copied to within the style-guide destination folder.

grunt.initConfig({
    emo: {
        main: {
            options: {
                copy: {
                    'assets/css/modern.css': 'web/assets/css/modern.css'
                }
            }
        }
    }
});

Usage Examples

Default Options

grunt.initConfig({
    emo: {
        main: {
            options: {
                copy: {
                    'assets/css/modern.css': 'web/assets/css/modern.css'
                }
            },
            files: [
                {
                    expand: true,
                    cwd: '',
                    src: [
                        'assets/scss/**/*.scss'
                    ]
                }
            ]
        }
    }
});

Custom Options

Below, emo is configured to output the style-guide as well as its source in a custom location.

grunt.initConfig({
    emo: {
        main: {
            options: {
                path: {
                    src: 'some/path/',
                    dest: 'styleguide/'
                },
                copy: {
                    'assets/css/modern.css': 'web/assets/css/modern.css'
                }
            },
            files: [
                {
                    expand: true,
                    cwd: '',
                    src: [
                        'assets/scss/**/*.scss'
                    ]
                }
            ]
        }
    }
});

Documentation Syntax

Emo searches for name/value combinations within your source files; these name/value combinations are then used within the component.html Swig template. Note that all values are parsed as markdown. Name/value combinations are expected to take the following format.


/*

    {% Name: Btn %}

    {% Category: elements %}

    {% Description: <button>I'm a button</button> %}

*/

.btn {
    color: blue;
}

Specifically, each name/pair value is expected to be enclosed within {%%} markings and separated by a :. As components can be lengthy, it's not always ideal to inline documenation in your CSS/SCSS/LESS files. As such, emo allows you to load documentation from markdown files.


/*

    {% Name: Btn %}

    {% Category: elements %}

    {% Description: relative/path/to/markdown-file.md %}

*/

.btn {
    color: blue;
}

As previously mentioned, emo can accept any number of name/value combinations, though it demands that name, category and description are used. Each name/value combination is available within the generated Swig templates via the component global. Use name/value combinations as you wish.


/*

    {% Name: Btn %}

    {% Category: elements %}

    {% Version: 1.0.0 %}

    {% Author: Michael Jordan %}

    {% Description: relative/path/to/btn_docs.md %}

*/

.btn {
    color: blue;
}

The previous examples show name/value combinations within CSS comments. Emo is capable of scraping documention from within all comment types:


//-------------------------------------------------
// Btn
//-------------------------------------------------
//
//  {% Name: Btn %}
//
//  {% Category: elements %}
//
//  {% Version: 1.0.0 %}
//
//  {% Author: Michael Jordan %}
//
//  {% Description: relative/path/to/btn_docs.md %}
//
//-------------------------------------------------

.btn {
    color: blue;
}

<!--

    {% Name: Btn %}

    {% Category: elements %}

    {% Description: <button class="btn">Im' a button</button> %}

-->

<button class="btn">Im' a button</button>

Categories

Emo was inspired by pattern lab, which categorizes UI components as atoms, molecules, organisms, templates, and pages. Emo uses a similar set of categories: elements, molecules, and organisms. In order for a component to show up in the generated style-guide, it must be placed in one of these categories.

Elements

See atoms

Molecules

See molecules

Organisms

See organisms

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)