Automatically generate a style guide from your stylesheets.

Related tags

CSS styledocco
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
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
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
Install the latest artifacts automatically and launch your server in a production ready mode with accessible convars.

Setup Edit the first three lines of the index.ts file to set your custom folder layout, follow the folder structure below for a example. const server_

null 2 Feb 4, 2022
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅

Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress ?? Looking for v5? The master branch is un

styled-components 38k Dec 31, 2022
Chrome extension to automatically mute/unmute Spotify tab when Advertisement starts and ends!

Ad free spotify Chrome extension to automatically mute/unmute Spotify tab when there's an Advertisement starts or ends. How to install Download Zip fi

Vivek 23 Dec 25, 2022
Automatically convert those LESS file which is not using less function to CSS.

less-2-css Automatically convert those .less file which is not using less function to .css. Why Less is a powerful CSS pre-processor, but it also very

UmiJS 14 May 24, 2022
A markdown based documentation system for style guides.

Hologram Hologram is a Ruby gem that parses comments in your CSS and helps you turn them into a beautiful style guide. There are two steps to building

Trulia, LLC. 2.2k Nov 12, 2022
Easily create and maintain style guides using CSS comments

mdcss lets you easily create and maintain style guides with CSS comments using Markdown. /*--- title: Buttons section: Base CSS --- Button styles c

Jonathan Neal 679 Oct 4, 2022
[ON HOLD] Living Style Guides Engine and Maintenance Environment for Front-end Components. Core repository.

[ON HOLD] SourceJS - Living Style Guide Platform The project been stale for a while and currently is in the [ON HOLD] state until we find new maintain

SourceJS 552 Nov 8, 2022
styled component for react & style-loader/usable

react-styled ES7 decorator for dynamic stylesheet usage w/ webpack install $ npm install bloody-react-styled --save-dev require import styled from "bl

Matthias Le Brun 37 Sep 26, 2022
🐒 Normalize browsers' default style

My open source work is supported by the community Special thanks to: Differences from normalize.css Smaller Includes only normalizations for the lates

Sindre Sorhus 4.8k Jan 3, 2023
NES-style CSS Framework | ファミコン風CSSフレームワーク

日本語 / 简体中文 / Español / Português / Русский / Français NES.css is a NES-style(8bit-like) CSS Framework. Installation Styles NES.css is available via ei

null 19.2k Jan 5, 2023
Octoprint-Detector2 is a detection plugin that runs in locally your browser and emails you if it detects some spaghetti, stringing or blobs on your print

Octoprint-Detector2 is a detection plugin that runs in locally your browser and emails you if it detects some spaghetti, stringing or blobs on your print. All you need is an email account and a PC.

Mikulash 24 Jan 2, 2023
:handbag: A beautiful CSS library to kickstart your projects

Picnic CSS Unpack your meal and get coding. An invasive CSS library to get your style started. Getting started There are many ways of using Picnic CSS

Francisco Presencia 3.6k Jan 4, 2023
Increase your landing page conversion rates.

Ouibounce Originally created by Carl Sednaoui from MailCharts. Maintained and improved by generous contributors. Ouibounce: A small library enabling y

Carl Sednaoui 2.3k Dec 9, 2022
📱 Free to use static generated website template for your mobile app

Mobile App Landing Page Template ?? Free to use static generated landing page template for your mobile app ?? Features Mobile App Landing Page Templat

Sandoche ADITTANE 467 Dec 30, 2022
A service to add web page screenshots to your Eleventy sites.

Screenshot API A runtime service to use live website screenshots on your site. Usage Image URLs have the formats: https://v1.screenshot.11ty.dev/:url/

Eleventy 91 Dec 24, 2022
Chrome extension that creates a button on Lever job application pages which shows you how their api parses your resume.

EDIT I have helped make a website that provides the same functionality. Repo: https://github.com/KnlnKS/resume-parser Site: https://resume-parser.verc

Kunalan Kevin Subagaran 17 May 19, 2022