Automatically generate a style guide from your stylesheets.

Overview

StyleDocco

StyleDocco generates documentation and style guide documents from your stylesheets.

Stylesheet comments will be parsed through Markdown and displayed in a generated HTML document. You can write HTML code prefixed with 4 spaces or between code fences (```) in your comments, and StyleDocco show a preview with the styles applied, and displays the example HTML code.

The previews are rendered in a resizable iframes to make it easy to demonstrate responsive designs at different viewport sizes.

Suggestions, feature requests and bug reports are welcome either at GitHub or on Twitter (@jacobrask).

Installation

StyleDocco requires Node.js. After installing Node.js, run npm install -fg styledocco or clone this repository and run ./bin/styledocco.

StyleDocco is free and open source software, released under the MIT license.

Usage

styledocco [options] [STYLESHEET(S)]

Options

  • --name, -n Name of the project
  • --out, -o Output directory (default: "docs")
  • --preprocessor Custom preprocessor command. (optional) (ex: --preprocessor "~/bin/lessc")
  • --include Include specified CSS and/or JavaScript files in the previews. (optional) (ex: --include mysite.css --include app.js)
  • --verbose Show log messages when generating the documentation. (default: false)
  •                 Stylesheet (or directory of stylesheets) to process.
    

Usage examples

Generate documentation for My Project in the docs folder, from the files in the css directory.

styledocco -n "My Project" css

Generate documentation for My Project in the mydocs folder, from source files in the styles folder. Use the --compass option for SASS to make Compass imports available.

styledocco -n "My Project" -o mydocs -s mydocs --preprocessor "scss --compass" styles

Syntax

/* Provides extra visual weight and identifies the primary action in a set of buttons.

    <button class="btn primary">Primary</button> */
.btn.primary {
    background: blue;
    color: white;
}

Would display the description, a rendered button as well as the example HTML code. The CSS will be applied to the preview.

See the examples folder for more in-depth examples.

Tips and tricks

  • StyleDocco will automatically compile any SASS, SCSS, Less or Stylus files before they are applied to the page. You can also enter a custom preprocessor command if you want to pass custom parameters to the preprocessor.
  • If your project includes a README.md file, it will be used as the base for an index.html.
  • If you don't specify a custom name, StyleDocco will use the name from a package.json file if it finds one.
  • Put some whitespace before a comment block to exclude it from the documentation.
  • Level 1 headings will automatically create a new section in the documentation.
  • Add :hover, :focus, etc as class names in example code and the pseudo class styles will be applied in the preview.

Change Log

v0.6.6 - Jan 28, 2014

  • Fix failure to render iframes in new versions of Chrome (#100)
  • Make it an option to minify the code (#106)

v0.6.5 - Nov 17, 2013

  • Fix failure to install on some systems (#94)

v0.6.4 - Oct 07, 2013

  • Large preprocessor outputs hit the maxBuffer limit (#87)
  • Relative image path is no longer added to data: URLs (#88)
  • Replace path.exists with fs.exists (#92)
  • Can now use a backslash to separate directories on Windows (#95)
  • HTTP URLs in paths now behave correctly (#97)

v0.6.3 - July 09, 2013

  • Do not add relative paths to data URLs

v0.6.2 - June 30, 2013

  • Find assets recursively in Windows
  • Fail gracefully on no files error
  • Relative url() paths are now preserved

v0.6.1 - August 20, 2012

  • Mute all preprocessor errors unless using verbose option
  • Don't try to preprocess SASS partials
  • Design tweaks

v0.6.0 - August 15, 2012

  • Remove custom resources option, as client side scripts/styles are vital to the functionality
  • Editable, auto-updating code examples
  • Documentation-wide search
  • Page specific Table of Contents

v0.5.0 - July 23, 2012

  • Render previews in sandboxed iframes
  • Resizing of iframes for responsive debugging
  • All processed CSS is included in all previews
  • Allow custom JavaScript and CSS files to be included in previews
  • Updated design with topbar instead of sidebar and new colors

Acknowledgements

A lot of the heavy lifting in StyleDocco is done by the excellent Marked module by Christopher Jeffrey. The original Docco by Jeremy Ashkenas and Knyle Style Sheets have also been sources of inspiration for StyleDocco.

Comments
  • Question: Is it possible to tell styledocco not to render the CSS of a file?

    Question: Is it possible to tell styledocco not to render the CSS of a file?

    For example, I have a base.css style sheet that has reset settings and other things that causes styledocco's styling to become malformed. Is it possible to tell styledocco not to render the stylesheet of the file that is being viewed?

    opened by redonkulus 13
  • Preview iframe can't render in Chrome 33

    Preview iframe can't render in Chrome 33

    I'm using Chrome 32.0.1700.77 (Official Build 244503). Iframe is blocked cause of CORS. The error message is below.

    Uncaught SecurityError: Blocked a frame with origin "http://localhost:10080" from accessing a frame with origin "null".  The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "data". Protocols must match.
    

    Above message has occured in my local server, but styledocco's demo site has same error.

    styledocco

    I think this problem is related #100.

    opened by Layzie 11
  • Error with node 0.8.0

    Error with node 0.8.0

    Hi,

    I installed the newest version and styledocco suddenly stopped working:

    module.js:340
    throw err;
          ^
    Error: Cannot find module 'async'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/styledocco/cli.js:3:13)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    
    exec error: Error: Command failed:
    

    The version beforehand that was working like a charm. Am I doing sth. wrong?

    opened by shapeshifta78 9
  • iframe data uri scheme breaks urls without a host

    iframe data uri scheme breaks urls without a host

    it seems that since the iframes src is a data uri any document relative or even root relative urls without a hostname won't load

    <iframe scrolling="no" name="iframe4" src="data:text/html;charset=utf-8,%3C!doctype%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3C%2Fbody..."></iframe>
    

    so css with image or font urls need to include the host as well as the full path which is not really ideal

    works:

    .foo { background: url("http://localhost/img/foo.jpg") ; }
    

    wont work:

    .foo {  background: url("/img/foo.jpg") ; }
    

    perhaps during css parsing the host & port could be inserted for urls? or maybe some other solution?

    opened by pjkix 8
  • Large preprocessor outputs hit the maxBuffer limit

    Large preprocessor outputs hit the maxBuffer limit

    When using one main file that imports all my CSS with a preprocessor I was hitting the maxBuffer limit. I've changed exec to spawn so that the output gets built from the stream, without a limit.

    Also fixed a typo in the regex that checks for Sass partials.

    opened by freejosh 7
  • Generating

    Generating "submenu" from markdown headings in CSS

    Currently StyleDocco lists the different stylesheet files in the left side navigation.

    Could it be possible to generate "submenu" / childmenu after the stylesheet name, that would contain hierarchical list of markdown headings inside the stylesheet and have links to them?

    Example, I could have following CSS:

    /* 
    Typography
    ==========
    Here are global typography styles etc
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    */
    
    /* 
    Headings
    --------
      <h1>heading 1</h1>
      <h2>heading 2</h2>
    */
    h1, h2 { /* ... */ }
    
    /* 
    Links
    -----
      <a href="#example">Default link style</a>
    */
    a:link, a:visited { /* ... */ }
    a:active, a:hover { /* ... */ }
    
    /* 
    containers
    ==========
    Here are styles for the different containers.
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    */
    
    /* 
    Main
    ----
    */
    .main { /* ... */ }
    
    /* 
    Sidebar
    -------
    */
    .sidebar { /* ... */ }
    
    
    
    
    
    

    ... and it would convert to a menu that would be something like this in the styleguide left side nav:

    stylesheet.css
    ├── Typography
    │   ├── Headings
    │   └── Links
    └── Containers
        ├── Main
        └── Sidebar
    

    Then these menuitems would link to matching section in the styleguide.

    opened by aripalo 7
  • Parsing multiple css files

    Parsing multiple css files

    Hi,

    I'm running Styledocco on Windows with node.js.

    When I type the following:

    styledocco -n "MyProject" css

    *css is a folder with styles.css & styles2.css

    Styledocco only parses styles.css but I want both of my files in the StyleGuide.

    What should I do?

    Thanks

    bug 
    opened by wooooow 7
  • Preview iframes blocked in Chrome 33

    Preview iframes blocked in Chrome 33

    Using Chrome Canary (version 33.0.1703.0) on the styledocco sample page: http://jacobrask.github.io/styledocco/styledocco/examples/styledocco/docs.html

    Getting this error, and the preview iframes are not getting appended to the DOM.

    Uncaught SecurityError: Blocked a frame with origin "http://jacobrask.github.io" from accessing a frame with origin "null". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "data". Protocols must match.

    Screenshot:

    docco

    I also notice a similar issue happening with my own styleguides, using Firefox 25, but for some reason the styledocco example works in Firefox...

    bug 
    opened by geekdave 6
  • Need some pointers

    Need some pointers

    So I forked and cloned Styledocco. It really is just what I need and I want to be able to hack, adapt and possibly help improve it. But as it turns out I have no idea how to run it from the working copy. Can you give me some pointers? I feel stupid right now.

    opened by MarcDiethelm 5
  • Documenting modularized css

    Documenting modularized css

    It seems like this project is geared towards smaller projects and could use some improvements for larger code bases.

    For example, I've got close to a hundred css files that I've started documenting for StyleDocco. Here are some issues I've encountered:

    • My css is modular and some modules depend on others, but I can only include one css file globally. I guess the easiest solution would be to include all css that's processed.
    • I don't need docs for all files. A more granular method to process specific files would be appreciated.
    • Some things depend on javascript as well... I'd like to be able to include those for functionality, not necessarily to document.
    • I don't always want code examples to be rendered. In my case, I've got some php I'd like to include as an example. I know I can hide that comment entirely from StyleDocco, but I still want it to appear with the rest of the documentation.

    I think that covers all of it. Let me know if any of these are already possible; I don't know all of version 0.4's new features.

    Note: None of this are stopping me from using StyleDocco, they'd just be nice to have :)

    feature request 
    opened by chrisjaure 5
  • use package.json like docco-husky

    use package.json like docco-husky

    Hi there,

    I'd like to use docco husky and styledocco together for my projects. husky has a package.json file which contains the project name and I'd like to use that name for styledocco as well and link beetween them via the readme file. I tried to fetch it with a bash script, but styledocco does not use the name from the variable, it just inserts "true".

    Maybe my script is wrong, but when I use echo it outputs sth. like styledocco -name "name from json file" css which is correct. Here is my script:

    #!/bin/bash
    name=`cat package.json | grep name | sed -e "s/^.*\"\(.*\)\".*$/\"\1\"/"`
    echo $name
    styledocco -name $name css 
    docco-husky js
    

    Regards, Tom

    opened by shapeshifta78 5
  • throw new TypeError('Path must be a string. Received ' + inspect(path));

    throw new TypeError('Path must be a string. Received ' + inspect(path));

    Hello, just installed and tried to see how styledocco works but I keep getting this error:

    "throw new TypeError('Path must be a string. Received ' + inspect(path));"

    I'm using it with Gulp (gulp-styledocco), however, I also tried to use it directly on the command line and I keep getting that error. This is the output I get from "gulp-styledocco" styledocco --out ./build/css/ --name "Herdez" --no-minify /Users/krrrunch/Code/herdez-front/build/css/main.css

    I'm pretty sure I installed it correctly with npm install -fg styledocco

    this is my gulp function

    gulp.task('styledocco',  function () {
      gulp.src('./build/css/*.css')
        .pipe(styledocco({
          out: './build/css/',
          name: 'Herdez',
          'no-minify': true
        }));
    });
    

    I know this is not the gulp-styledocco repository but I really think is a styledocco issue.

    Any ideas?

    opened by IrvingArmenta 3
  • I am getting a second level navigation when I try to add HTML code to my comments

    I am getting a second level navigation when I try to add HTML code to my comments

    I am trying to get styledocco to work with the project I am working on. I am using the less version of Bootstrap and the Aurelia framework. I am able to Generate documentation for my project using the following command: styledocco -n "heimdall-uiapp" -o src/styleguide --preprocessor "less src/less/*" styles. I have added the following comment to one of my custom less files and I have prefixed my HTML with 4 spaces (I also also tried to "```" notation as well):

    /*  
    Base
    ===============
    
    Standard Bootstrap button
    
        <button class="btn btn-primary">Button</button>
    
    */
    

    But when I view my documentation I get the following view. How would I resolve this issue? I can provide any additional information.

    Some additional information. I have a main LESS file where I am importing all the Bootstrap LESS files, and then importing the customize LESS files.

    screen shot 2016-07-18 at 14 06 10
    opened by herrjosua 1
  • Show demo od a CSS rule applied to real HTML element possible?

    Show demo od a CSS rule applied to real HTML element possible?

    The demo I saw generated doc text.

    Is it possible to also generate an HTML element and apply the style to it as a preview of the styles?

    I wasn't able to tell if this does that or not. Some of the demo URLs are 404

    opened by jasondavis 1
  • Include images (sprites) in Styledocco's output

    Include images (sprites) in Styledocco's output

    I am working in a big, grown project with hells of CSS, trying to introduce SCSS/SASS and Styledocco there step for step.

    For the examples of the output styledocco gives me (we are using maven and grunt), I include generated sprite css files (which works fine with the include option). Is there any way to include the images the CSS is relying on as well?

    opened by paulwellnerbou 2
  • Templating support instead of polluting CSS with HTML

    Templating support instead of polluting CSS with HTML

    Hi,

    Does hologram supports, or plan to support templates include from CSS comments? Like

    /*
    My example
    
    \```html_example
        @inclute template.hbs
    \```
    */
    

    HTML placed in CSS comments is hard to maintain, and easpecially keep up to date, because of you're always forced to copy paste it from real codebase to comments. Also, you don't have any syntax highlight and writing bigger chunks of HTML examples will bloat your CSS.

    opened by therobhrt 0
Automatically generate a style guide from your stylesheets.

StyleDocco StyleDocco generates documentation and style guide documents from your stylesheets. Stylesheet comments will be parsed through Markdown and

Jacob Rask 1.1k Sep 24, 2022
Styleguide generator is a handy little tool that helps you generate good looking styleguides from stylesheets using KSS notation

SC5 style guide generator Looking for a maintainer If you would like to maintain the project, create an issue and tell a few words about yourself. Sty

SC5 1.3k Sep 26, 2022
Base62-token.js - Generate & Verify GitHub-style & npm-style Base62 Tokens

base62-token.js Generate & Verify GitHub-style & npm-style Secure Base62 Tokens Works in Vanilla JS (Browsers), Node.js, and Webpack. Online Demo See

Root 4 Jun 11, 2022
JavaScript Style Guide

Airbnb JavaScript Style Guide() { A mostly reasonable approach to JavaScript Note: this guide assumes you are using Babel, and requires that you use b

Airbnb 130.5k Jan 4, 2023
Isolated React component development environment with a living style guide

Isolated React component development environment with a living style guide React Styleguidist is a component development environment with hot reloaded

Styleguidist 10.6k Jan 5, 2023
Created from react styleguidist for Vue Components with a living style guide

Isolated Vue component development environment with a living style guide Start documenting now on codesandbox.io Sponsors A big thank you to our spons

Vue Styleguidist 2.3k Dec 28, 2022
🌟 JavaScript Style Guide, with linter & automatic code fixer

JavaScript Standard Style Sponsored by English • Español (Latinoamérica) • Français • Bahasa Indonesia • Italiano (Italian) • 日本語 (Japanese) • 한국어 (Ko

Standard JS 27.8k Dec 31, 2022
Dropbox’s (S)CSS authoring style guide

Dropbox (S)CSS Style Guide “Every line of code should appear to be written by a single person, no matter the number of contributors.” —@mdo General Do

Dropbox 890 Jan 4, 2023
🌟 JavaScript Style Guide, with linter & automatic code fixer

JavaScript Standard Style Sponsored by English • Español (Latinoamérica) • Français • Bahasa Indonesia • Italiano (Italian) • 日本語 (Japanese) • 한국어 (Ko

Standard JS 27.8k Dec 31, 2022
Vercel's engineering style guide

The Vercel Style Guide This repository is the home of Vercel's style guide, which includes configs for popular linting and styling tools. The followin

Vercel 409 Jan 6, 2023
AirBnb Javascript Style Guide'ının Türkçe diline çevrildiği repository

Airbnb JavaScript Stil Kılavuzu() { JavaScript'e büyük ölçüde mantıklı/makul bir yaklaşım Not: Bu kılavuz sizin Babel kullandığınızı varsayar ve babel

Gökhan Kandemir 71 Dec 29, 2022
Automatic GatsbyJS App Landing Page - Automatically generate iOS app landing page using GatsbyJS

Automatic GatsbyJS App Landing Page Create and deploy an iOS app landing page on GitHub Pages and Netlify in a couple of minutes ?? Fork this repo ??

Imed Adel 173 Jan 1, 2023
Generate short video game music, automatically, endlessly.

short-VGM-generator (DEMO) Generate short video game music, automatically, endlessly. It is powered by machine learning with magenta.js HOW TO PLAY Pr

ABA Games 8 Oct 28, 2022
🌸 A cli can automatically generate files from Excel files.

unxlsx A cli can automatically generate files from Excel files. Why We often need to export some information from XLSX to generate our files, such as

Frozen FIsh 24 Aug 22, 2022
Automatically generate unit price for applicable items when shopping online.

Unit Price Helper Unit Price Helper is an Google Chrome extension that allows to display the prices per unit for the products on multiple shopping sit

Yang 6 Nov 18, 2022
Guide your users through a tour of your app

Shepherd is maintained by Ship Shape. Contact us for web app consulting, development, and training for your project. Browsers support Edge Firefox Chr

Ship Shape 10.8k Dec 28, 2022
portfolio-project is a npm package to automatically update your projects section in your portfolio website. It will fetch the selected repositories directly from your GitHub account.

portfolio-project Those days of manually updating portfolio website after every new project made are gone ⚡ Yesss . . . you read that right. ?? portfo

Gaurav Gulati 15 Aug 3, 2021
Generate deterministic fake values: The same input will always generate the same fake-output.

import { copycat } from '@snaplet/copycat' copycat.email('foo') // => '[email protected]' copycat.email('bar') // => 'Thurman.Schowalter668@

Snaplet 201 Dec 30, 2022
A better way for new feature introduction and step-by-step users guide for your website and project.

Intro.js v3 Lightweight, user-friendly onboarding tour library Where to get You can obtain your local copy of Intro.js from: 1) This github repository

usablica 21.7k Jan 2, 2023