Giter Club home page Giter Club logo

kss-node's Introduction

Build Status Coverage Status Dependency Status

Note: This README is for the master branch of this project. To see the README for the latest stable release see https://www.npmjs.com/package/kss.

kss-node

Greenkeeper badge

This is a Node.js implementation of KSS, "a documentation syntax for CSS" that's intended to have syntax readable by humans and machines. Hence, the kss-node software can be used to create a "living style guide".

  1. Write human-readable documentation using "KSS syntax" comments.
  2. Have the kss tool automatically build a style guide from your stylesheets.

Here's an example KSS comment:

// Button
//
// Your standard button suitable for clicking.
//
// :hover   - Highlights when hovering.
// .shiny   - Do not press this big, shiny, red button.
//
// Markup: button.html
//
// Style guide: components.button
.button {
  ...
}
.button.shiny {
  ...
}

The methodology and ideas behind KSS are contained in the specification.

There's an example project in the demo directory of this repo.

What does KSS mean?

KSS was originally named "Knyle Style Sheets" to be a pun on CSS and the software creator’s name, Kyle Neath. We are working on a better acronym.

Installation

kss-node is installed just like any other Node.js software. Read the kss-node Quick Start Guide to learn more. It also includes an npm Quick Start Guide, if you don't know much about Node.js's npm command.

Using the command line tool

To get you up and running quickly, a style guide builder is included that can be used from the command line. It parses stylesheets and spits out a set of static HTML files.

Usage: kss [options]

File locations:
  --source       Source directory or wildcard to recursively parse for KSS
                 comments, homepage, and markup                         [string]
  --base         Base directory, used to resolve sources, homepage, etc.
                            [string] [default: "/Users/yliechti/Sites/kss-node"]
  --destination  Destination directory of style guide
                                                [string] [default: "styleguide"]
  --json         Output a JSON object instead of building a style guide[boolean]
  --mask, -m     Use a mask for detecting files containing KSS comments
                [string] [default: "*.css|*.less|*.sass|*.scss|*.styl|*.stylus"]
  --config, -c   Load the kss options from a json file

Builder:
  --clone        Clone a style guide builder to customize               [string]
  --builder, -b  Use the specified builder when building your style guide
                                        [string] [default: "builder/handlebars"]

Style guide:
  --css          URL of a CSS file to include in the style guide        [string]
  --js           URL of a JavaScript file to include in the style guide [string]
  --custom       Process a custom property name when parsing KSS comments
                                                                        [string]
  --extend       Location of modules to extend the templating system; see
                 http://bit.ly/kss-wiki                                 [string]
  --homepage     File name of the homepage’s Markdown file related to working
                 directory
                [string] [default: "/Users/yliechti/Sites/kss-node/homepage.md"]
  --markup       Render "markup" templates to HTML with the placeholder text
                                                      [boolean] [default: false]
  --placeholder  Placeholder text to use for modifier classes
                                          [string] [default: "[modifier class]"]
  --nav-depth    Limit the navigation to the depth specified        [default: 3]

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --verbose  Display verbose details while building                      [count]
  --demo     Builds a KSS demo.                       [boolean] [default: false]
  --//       Comments in JSON files will be ignored

Since each builder has its own set of options, you can see the help for those options by using --builder with --help. For example, running kss --help --builder builder/twig will show these additional options:

Style guide:
  --extend-drupal8  Extend Twig.js using kss’s Drupal 8 extensions
  --namespace       Adds a Twig namespace, given the formatted string:
                    "namespace:path"

In order to parse your stylesheets containing KSS docs, you need to either specify a single directory as the first argument or you can specify one or more source directories with one or more --source [directory] flags.

The style guide will be built in the styleguide directory unless you specify the second argument or use a --destination [directory] flag.

Even though kss parses your CSS source, your CSS won't be included in the style guide unless you use the --css option or create a custom builder with --clone.

You can build a copy of the demo style guide like so:

$ kss --demo

If you want to change the HTML of the style guide being built, you can create your own builder, i.e. skin, theme. Use the kss --clone command to initialize a copy of the default builder so you can edit it and use it when building your style guide with the --builder flag.

$ kss --clone custom-builder
$ kss path/to/sass styleguide --builder custom-builder

The default builder should look something like this:

Handlebars Builder Preview

Differences from kneath/kss

Unlike the default Ruby implementation at kneath/kss, kss-node includes a few optional features to allow for completely automated style guide building.

Language Agnostic. kss-node does not care what language your application is written in (Ruby, Node.js, PHP, whatever). It just scans your CSS source files looking for KSS docs so that it can build a living style guide. And since it only looks for properly formatted KSS comments, it also doesn't need to know what kind of CSS preprocessor you use either.

Homepage Text. The overview text needed for the style guide homepage is built from a Markdown file. The file path must be relative to config file or working directory if given by command line. Just name it homepage.md and put it in directory of config file.

Additional kss-node specifics are detailed in this version of the KSS spec.

Take a look at the demo project for some examples.

Using kss from Node.js

Check out the JavaScript API for a full explanation. Here's an example:

var kss = require('kss'),
    options = {
        markdown: false
    };

kss.traverse('public/stylesheets/', options).then(function(styleGuide) {
    styleGuide.sections('2.1.1');                                   // <KssSection>
    styleGuide.sections('2.1.1').modifiers(0);                      // <KssModifier>
    styleGuide.sections('2.1.1').modifiers(':hover').description(); // 'Subtle hover highlight'
    styleGuide.sections('2.1.1').modifiers(0).className();          // 'pseudo-class-hover'
    styleGuide.sections('2.x.x');                                   // [<KssSection>, ...]
    styleGuide.sections('2.1.1').modifiers();                       // [<KssModifier>, ...]
});

Development

Forking, hacking, and tearing apart of this software is welcome! It still needs some cleaning up.

After you've cloned this repository, run npm install and then you'll be able to run the module's mocha and eslint tests with npm test.

To build a new version of the demo style guide and JavaScript documentation, use make docs and commit your changes to master. To publish the documentation to http://kss-node.github.io/kss-node/ , run npm run docs-deploy.

Contributors

Lots! And more are welcome. https://github.com/kss-node/kss-node/graphs/contributors

kss-node's People

Contributors

0x6a68 avatar aeharding avatar auspicus avatar benogle avatar catiaraminhos avatar chafnan avatar danielruf avatar davidtheclark avatar emcpadden avatar fokusferit avatar greenkeeper[bot] avatar greenkeeperio-bot avatar hughsk avatar iampuma avatar jhollingworth avatar jnowland avatar johnalbin avatar kennethormandy avatar kevinastone avatar ksokhan avatar oldstarchy avatar queenvictoria avatar rcaracaus avatar robloach avatar ryuran avatar scottaohara avatar torbs avatar vagelis-prokopiou avatar warin avatar xumepadismal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kss-node's Issues

Hidden .svn files prevent styleguide generation

Hi,

kss-node fails when run on a folder whose contents are managed in Subversion.

Subversion creates a hidden folder (.svn) which contains various copies of the directory contents, appended with .svn-base and .tmp.

I think what is happening is that the script is grabbing these files from the SVN subdirectory, then something is breaking when it attempts to parse them.

Can the current regex be tweaked to only capture files which end in .css/.less, rather than filenames which contain these strings?

Thanks,
Dan

Remove all stylesheet compilation

kss-node currently requires that it compile a kss.less file in the template directory (see #34) and optionally will compile styles, sass or less files that are specified on the command line:

  -s, --style         Compile and include a stylesheet - the precompiler is chosen based on file extension  [string]
  -l, --less          Compile and include a LESS stylesheet                                                 [string]
  -y, --stylus        Compile and include a Stylus stylesheet                                               [string]
  -S, --sass          Compile and include a SASS stylesheet                                                 [string]

Given how many different workflows for compilation there are (there are 350 node.js modules returned for npm search sass!), its unreasonable for kss-node to be expected to support them all.

A better approach would be for developers to compile the stylesheets themselves and then hand off the compiled CSS to kss-node to include. (or optionally, make a custom template and include what you want by editing the index.html)

kss-node will continue to parse css, stylus, less and sass source files; it just won't be in the business of trying to compile them.

Optional @import ignoring and paths option

In my project I use some external dependency (think of Bootstrap), which I include in the code but do not want to process it to the guide.

Could some directive be introduced to optionally disable guide processing for the next import?

Syntax propose:

// Do not process
@import "vendor/foobar";

On a related matter, kss should have the paths option for less.js (see http://lesscss.org/ Usage > Configuration section).

Fix order of generated styleguide sections

It appears as if the order of the sections isn't always correct, instead decided by the order in which they're parsed. Will look into this and fix as soon as I can...

HTML entities are not shown correctly

When I use a HTML entity in Markup: section, that will be shown as a result character in the code block.

I think HTML entities should be displayed as is.

Source code:

// Markup: <a href="#">&lt;</a>

But code block in the document:

<a href="#"><</a>

Style.css Not Generated When Using SASS

This won't generate the style.css:
kss-node sass docs/styleguide --sass sass/styles.scss

But this does:
kss-node sass docs/styleguide --css css/styles.css

My sass folder looks something like:

  • sass/
    • styles.scss
    • partials/
      • components.scss

Can't generate styleguide in working directory

While using the kss-node script, I can't specify the current directory for the build directory with ..

For example, if I go into this repository's gh-pages directory and run ../bin/kss-node ../demo . -l ../demo/styles.less (which means read the source in ../demo and then put the auto-generated files in the current working directory, .), I receive the following error:

Generating your KSS Styleguide!

 * Source: /Users/jwilkins/Sites/contrib/kss-node/demo
 * Destination: /Users/jwilkins/Sites/contrib/kss-node/gh-pages
 * Template: /Users/jwilkins/Sites/contrib/kss-node/lib/template

../node_modules/wrench/lib/wrench.js:180
        if (e.code !== 'EEXIST') throw e;
                                       ^
Error: EACCES, permission denied '/public'
    at Object.fs.mkdirSync (fs.js:647:18)
    at Object.exports.copyDirSyncRecursive (../node_modules/wrench/lib/wrench.js:177:12)
    at Object.<anonymous> (../bin/kss-node:116:8)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

HTML in description breaks

Tags in the description section are being parsed (presumably because of markdown). For example, this example breaks:

// Test
// 
// Should not actually turn <li> into a list item, but it does

Looks like they should be allowed:

The description should be plain sentences of what the CSS rule or hierarchy does and looks like. A good description gives guidance toward the application of elements the CSS rules style.

CSS rules that depend on specific HTML structures should describe those structures using <element#id.class:pseudo> notation. For example:

// A feed of activity items. Within each <section.feed>, there should be many
// <article>s which are the  feed items.

"Cannot call method 'render' of undefined" when generating demo styleguide

Using: ss-node demo styleguide --less demo/styles.less

...compiling LESS
...parsing your styleguide
...generating section 1 [ Modules ]
...generating section 2 [ Forms ]
...generating styleguide overview
...compiling additional stylesheets
 - demo/styles.less (less)
Cannot call method 'render' of undefined
TypeError: Cannot call method 'render' of undefined
    at C:\Users\Enzy\AppData\Roaming\npm\node_modules\kss\bin\kss-node:224:20
    at _asyncMap (C:\Users\Enzy\AppData\Roaming\npm\node_modules\kss\node_modules\async\lib\async.js:185:13)
    at async.forEach (C:\Users\Enzy\AppData\Roaming\npm\node_modules\kss\node_modules\async\lib\async.js:86:13)
    at Array.forEach (native)
    at _forEach (C:\Users\Enzy\AppData\Roaming\npm\node_modules\kss\node_modules\async\lib\async.js:26:24)
    at async.forEach (C:\Users\Enzy\AppData\Roaming\npm\node_modules\kss\node_modules\async\lib\async.js:85:9)
    at _asyncMap (C:\Users\Enzy\AppData\Roaming\npm\node_modules\kss\node_modules\async\lib\async.js:184:9)
    at Object.doParallel [as map] (C:\Users\Enzy\AppData\Roaming\npm\node_modules\kss\node_modules\async\lib\async.js:168:23)
    at generateStylesheet (C:\Users\Enzy\AppData\Roaming\npm\node_modules\kss\bin\kss-node:208:9)
    at async.reduce (C:\Users\Enzy\AppData\Roaming\npm\node_modules\kss\node_modules\async\lib\async.js:201:13)

style.css not generated

Hi,

First up, thanks a lot for writing this, this is only my first day using the system so apologies if I've overlooked something simple.

When I run the following in Terminal, section-0.html is generated, but style.css isn't:

kss-node dan/input dan/output --css dan/input/test1.css

Generating your KSS Styleguide!

 * Source: /Users/Dan/github/kss-node/dan/input
 * Destination: /Users/Dan/github/kss-node/dan/output
 * Template: /usr/local/lib/node_modules/kss/lib/template

...compiling LESS
...parsing your styleguide
...generating section 0 [ Unnamed ]
...generating styleguide overview
...compiling additional stylesheets
Key is not defined

Additionally, when I view the page on my local dev server, I get a JavaScript error - possibly due to the missing stylesheet?

Security error: 
_ref2 = stylesheet.cssRules || [];
  • kss.js / line 14

My stylesheet uses regular CSS (I do use SASS but I wanted to start simple to check that everything is working ok).

I've also tried the demo out and that worked without fault - but it uses LESS, so I am not sure if that makes a difference or not.

test1.css:

/*
KSS test #1 - a faux button

:hover             - Hover state (color change)
.disabled          - Dims the button to indicate it cannot be used.

Markup: 
<p>
<a href="#" class="button {$modifiers}">Link</a>
</p>

Styleguide 0.0.2.
*/
.button {
    color: red;
    padding: 10px;
    border: 1px solid;
}
.button:hover {
    color: green;
}
.button.disabled {
    color: grey;
    cursor: text;
}

Thanks,
Dan

BEM methodology

has somebody experience on implementing this into kss?

e.g.

// Buttons
// 
// some nice description
//
// Markup:
// <a href="#" class="button{$modifiers}">Button (a.button)</a>
//
// --primary

.button {
 padding: 25em;
 background-color: acolor;
}

.button--primary {
  @extend .button;
  background-color: another;
}

So what will be generated here?

the {#modifierMarkup} for default will be:

<a href="#" class="button{$modifiers}">Button (a.button)</a>

button--primary looks nice and i am happy! but for the default a class will be generated button{$modifiers}, that has no styles of course. does anybody know how to handle with this?

Update default styleguide template to use web-starter-kit styles

The styles in our default styleguide template are boring. https://kss-node.github.io/kss-node

screen shot of current style guide template

In addition, with the navigation bar on the left, any components with media queries will display incorrectly since its unlikely the component's container on the live site will match the style guide's container.

If we move the navigation to the top and remove the sidebar, we make it easier for an implementor to display their responsive components correctly within the styleguide.

I think we should use the open sourced Web Starter Kit styleguide design. http://google.github.io/web-starter-kit/app/styleguide/

screen shot of web starter kit styleguide

Readme improvement or CLI bug?

Before trying to do a pull request, just wanted your opinion about a thing.

KSS is intended for SASS files, instead of Less. It absolutely makes sense that node-kss is intended for Less files, but that's not clarified into the readme file.

I wasn't able to compile my sass files into the styleguide. Perhaps it's a bug on the CLI, which doesn't have the same options as the module itself.

What do you think?

Thanks!

Pseudo-elements are not applied

It looks like the generated docs, although they apply special classes for pseudo-elements, don't include any styles for them, is this normal ? Do I have to myself specify classes for pseudo-class-active etc ?

$modifiers doesn't stay in the right state

I try to do a test for button elements. The modifiers doesn't generate the right class for me. The class should be "btn:hover" but it gives me "btn pseudo-class-hover".

/*
Buttons

Buttons are actionable items.

Markup:
<button class="btn {$modifiers}">Action Button</button>

:hover    - hover state

Styleguide 4
*/

.btn{
    display: inline-block;
    .ie7-inline-block();
    padding: 4px 12px;
    margin-bottom: 0;
    font-size: @baseFontSize;
    line-height: @baseLineHeight;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    .buttonBackground(@btnBackground, @btnBackgroundHighlight, @grayDark, 0 1px 1px rgba(255,255,255,.75));
    border: 1px solid @btnBorder;
    border-bottom-color: darken(@btnBorder, 10%);
    .border-radius(@baseBorderRadius);

    &:hover{
        color: @grayDark;
        text-decoration: none;
        background-position: 0 -15px;
        .transition(background-position .1s linear);
    }
}

CLI custom template flag crashes out

Just a heads up: Running CLI generator with a template reference -t /path/to/template.html bails out with:

Generating your KSS Styleguide!

 * Source: /path/to/src
 * Destination: /path/to/dest
 * Template: /path/to/template.html


fs.js:413
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);

Error: ENOTDIR, not a directory 'path/to/template.html/index.html'

Incorrectly appends index.html to the path.

Bails out with similar error if you simply point it to /path/to/templateDirectory/ rather than the template file itself (even if template is index.html).

Error: ENOENT, no such file or directory 'path/to/templateDirectory/public'

Incorrectly appends /public to the path.

Multi-line Modifier Descriptions

If we define some modifiers such as

// :hover - Something on hover
// .dangerous - Something dangerous

kss-node detects it fine, but if there is one that spans multiple lines, it breaks out of the modifier system and back into normal paragraphs.

// :hover - Something on hover
// .dangerous - Something dangerous.
//                  Be careful to not have a .safe icon inside.

Github ruined the padding [edit: fixed now!], but I would expect it to work like the // Markup:, where it goes until the next empty //

This may be against actual KSS's behavior but I figured I'd bring it up since kss-node has altered the Markup syntax a bit anyway. :)

.svn folders copied to public folder

Hi,

When I run kss-node, the public directory is copied from my custom template folder, to my generated folder (along with the KSS sections).

Because my template folder is managed in Subversion, there is an .svn folder that is being copied across as well. This throws my Subversion client, as there are now two copies of that .svn folder in two separate locations and it doesn't like it.

I had a peek at how kss-node works, and see that the files are being copied over with wrench.copyDirSyncRecursive.

The wrench-js docs show that there is an option to prevent .foo files being copied over:

wrench.copyDirSyncRecursive('directory_to_copy', 'location_where_copy_should_end_up', {
    excludeHiddenUnix: bool, // Whether to copy hidden Unix files or not (preceding .)
}

I edited my copy of kss-node, to add excludeHiddenUnix: true to both instances of wrench.copyDirSyncRecursive, but the .svn folders are still being copied across.

I'm unsure whether this functionality was added to wrench-js after 1.3.x (the version you're using). I had a look through the 'Blame' listing on the wrench-js but couldn't see any mention of that specific change.
There are also some unit tests over on that repo but I'm not sure how to run them.

Alternatively, there are some custom solutions floating around, such as this one.

I'm aware that these might be shortcomings with wrench-js and nothing to do with kss-node but it looks like wrench-js is not being updated anymore (at least by the original author) so perhaps an alternative fix is necessary.

For now I can workaround this by adding a 'clean' step to my Grunt workflow, to remove the copied .svn folder.

Thanks,
Dan

SCSS stylesheets aren't included

I've set up a project as follows

src/
  buttons.scss - docs and styles about buttons
  links.scss - docs and styles about links
  kss.scss - @import all the other .scss files in this folder in order

and then run kss-node as

./node_modules/kss/bin/kss-node src dist --sass src/kss.scss

That generates a dist/ directory with the docs. They mostly look right, but none of my styles are applied to the examples.

I found this in the README:

Your CSS won't be included by default, hence you should use the --less, --css, etc. flags to point to a stylesheet to compile and include.

I assumed that's what I was doing with --sass src/kss.scss. I've tried naming the file various other things, such as src.meta.scss or styleguide.scss. In each case, the command generates a completely empty dist/public/style.css.

kss-node version 0.3.7

Roadmap for 1.0.0, 2.0.0 and beyond

hello together! since i am a big fan of kss and node, i have asked @hughsk to help him out as a contributor. as you have noticed i closed several issues and moved most of them into this list:

  • Example Update, SASS projects
  • HTML Entities #30
  • Multiline Description for Modifiers #25
  • Compass Sprite #24
  • Support for functions and mixins #22

if you have any features, which are not listed above, just leave a note here and we can discuss them. thanks and bye!

Generating Duplicate Sections/Subsections

I'm experiencing an issue where the documentation sections are added twice in the documentation. Looking at the sections object in the kss-node module, it seems like the the same object gets added twice. So the issue is not at the template level:

[{
    data: {
        raw: ' \nIconography\n\nall about icons goes here\n\nStyleguide 1.0',
        header: 'Iconography',
        description: '<p>all about icons goes here</p>\n',
        modifiers: [],
        markup: false,
        reference: '1',
        refDepth: 1,
        deprecated: false,
        experimental: false
    },
    styleguide: null
}, {
    data: {
        raw: ' \nCustom Icons\n\nCustom icons for our site\n\nMarkup:\n<i class="{$modifiers}"></i>\n\n.icon-chevron-right   - chevron right\n.icon-reorder         - reorder\n.icon-plus            - plus\n.icon-question-sign   - question sign\n.icon-lock            - lock\n.icon-ok              - ok\n.icon-caret-up        - caret up\n\nStyleguide 1.1.1',
        header: 'Custom Icons',
        description: '<p>Custom icons for our site</p>\n',
        modifiers: [Object],
        markup: '<i class="{$modifiers}"></i>',
        reference: '1.1.1',
        refDepth: 3,
        deprecated: false,
        experimental: false
    },
    styleguide: null
}, {
    data: {
        raw: ' \nIconography\n\nall about icons goes here\n\nStyleguide 1.0',
        header: 'Iconography',
        description: '<p>all about icons goes here</p>\n',
        modifiers: [],
        markup: false,
        reference: '1',
        refDepth: 1,
        deprecated: false,
        experimental: false
    },
    styleguide: null
}, {
    data: {
        raw: ' \nCustom Icons\n\nCustom icons for our site\n\nMarkup:\n<i class="{$modifiers}"></i>\n\n.icon-chevron-right   - chevron right\n.icon-reorder         - reorder\n.icon-plus            - plus\n.icon-question-sign   - question sign\n.icon-lock            - lock\n.icon-ok              - ok\n.icon-caret-up        - caret up\n\nStyleguide 1.1.1',
        header: 'Custom Icons',
        description: '<p>Custom icons for our site</p>\n',
        modifiers: [Object],
        markup: '<i class="{$modifiers}"></i>',
        reference: '1.1.1',
        refDepth: 3,
        deprecated: false,
        experimental: false
    },
    styleguide: null
}]

I'm using the following command to generate docs:

kss-node StyleSheets/_Shared Docs --css StyleSheets/_Shared/_Layout.css --template KSS/mytemplate

with a folder structure that looks something like this:

  • root
    • Docs
    • KSS
      • mytemplate
    • StyleSheets
      • _Shared

It generates the documentation with the right styling but for some reason the each section and subsection gets added twice in the docs:

screen shot 2013-10-16 at 3 57 39 pm

Pseudo class examples not working correctly

Thanks for porting this to node. I've found it very useful.

I just cloned the repo and in the button section, the :hover, :disabled and :active examples all look identical. The pseudo-class-hover class is getting applied, but not the styles. This is happening on my own style guide as well.

Note that it's fine on what's deployed on Github pages (http://hughsk.github.com/kss-node/section-1.html), so probably a recent regression?

Compiling stylus file that uses file globbing

I guess this is the same as issue #61.

When I try to compile a stylus file that uses the @import rule with file globbing (@import modules/*), I get this compile error:

> kss-node modules styleguide --stylus ./styles.styl

Generating your KSS Styleguide!

 * Source: /Users/lambertsteven/fs/stylus-styleguide/modules
 * Destination: /Users/lambertsteven/fs/stylus-styleguide/styleguide
 * Template: /Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/lib/template

...compiling KSS styles
...parsing your styleguide
 - modules/_buttons.styl
...generating section 1 [ Unnamed ]
...generating styleguide overview
...no styleguide overview generated: ENOENT, no such file or directory 'modules/styleguide.md'
...compiling additional stylesheets
 - ./styles.styl (stylus)
./styles.styl:7
   3| // Reusable elements that can be used across the site.
   4| // So far this just includes buttons.
   5| //
   6| // Styleguide 1.
 > 7| @import './modules/*'

failed to locate @import file ./modules/*.styl

Error: ./styles.styl:7
   3| // Reusable elements that can be used across the site.
   4| // So far this just includes buttons.
   5| //
   6| // Styleguide 1.
 > 7| @import './modules/*'

failed to locate @import file ./modules/*.styl

    at Evaluator.visitImport (/Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/node_modules/stylus/lib/visitor/evaluator.js:675:21)
    at Evaluator.Visitor.visit (/Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/node_modules/stylus/lib/visitor/evaluator.js:75:18)
    at Evaluator.visitBlock (/Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/node_modules/stylus/lib/visitor/evaluator.js:545:39)
    at Evaluator.Visitor.visit (/Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/node_modules/stylus/lib/visitor/evaluator.js:75:18)
    at Evaluator.visitImport (/Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/node_modules/stylus/lib/visitor/evaluator.js:706:18)
    at Evaluator.Visitor.visit (/Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/node_modules/stylus/lib/visitor/evaluator.js:75:18)
    at Evaluator.visitRoot (/Users/lambertsteven/.nvm/v0.10.24/lib/node_modules/kss/node_modules/stylus/lib/visitor/evaluator.js:532:27)

I put this up in a repo so you can see my structure. I can compile the file just fine using the stylus node_module so it's not that. However, if I change the import rule to just the file (@import modules/_buttons), it works fine.

Styleguide reference doesn't support words?

I think (according to KSS) it should support words as styleguide references e.g.:

// Styleguide Forms.Checkboxes.
// - or -
// Styleguide Forms - Special Checkboxes.

But this doesn't seem to work. Any idea if it should or if this is something we could add. It would certainly be very useful as sequential numbers 1.1, 1.2, .1.3 etc are hard to maintain if you remove the code relating to 1.2 :(

Thanks!

Issue with compiling a template - Refuses to stop using LESS

I'm using the following command in terminal to generate a styleguide:

kss-node core core/docs --sass core/sass/screen.sass -t core/docs/template/

But I can't get KSS to not use the kss.less file in the templates directory. It compiles my SASS file after the LESS file, but the contents of the kss.css file is always whatever is in the LESS file. I've also tried deleting the LESS file, but when I'm compiling it gives the error:

...compiling KSS styles
{ type: 'File',
message: ''core/docs/public/kss.less' wasn't found',
filename: 'input',
index: 0,
line: 1,
callLine: undefined,
callExtract: undefined,
column: 0,
extract: [ undefined, '@import "core/docs/public/kss.less";', undefined ] }
'core/docs/public/kss.less' wasn't found
undefined

Is there a way to stop using the less file?

Support for preprocessor functions and mixins

It seems like mixins and functions, at least in SASS/SCSS, aren't parsed correctly.
Take the following simple block :

// @arrow-bottom($size, $color)
//
// Generates an arrow on the bottom of the block
//
// $size  - The size of the arrow
// $color - Its color
//
// Styleguide 1.2.2.

As kss-node is interpreting the arguments as modifiers, it doesn't display them without a provided markup.
Mixins and functions shouldn't have any markup – ever – and thus the parser should skip straight to the modifiers and display them as arguments.

SASS/CSS differentation

If I run kss-node with this command:
kss-node css css/compiled/ --sass css/layout.css -sass css/common.css

I get this output

...compiling KSS styles
...parsing your styleguide
 - css/_normalize.scss
 - css/common.scss
.... [ snipped ]
...generating section 1 [ _wpt.scss ]
...generating section 2 [ "Rigid" Theme ]
... [ snipped ]
...generating styleguide overview
...compiling additional stylesheets
 - css/common.css (css)
 - css/layout.css (sass)

Note the last two lines:

 - css/common.css (css)
 - css/layout.css (sass)

The argument hinted both are sass, but the first one is always reported as css. If I switch the arguments so layout comes first and then common, the same behavior happens:

kss-node css css/compiled/ --sass css/common.css -sass css/layout.css

...compiling additional stylesheets
 - css/layout.css (css)
 - css/common.css (sass)

This is more than just an output glitch, as one direction breaks my style.css, while the other does not, because the output style.css in the compiled folder seems to contain only stuff from the last given -sass file.

Problems with generation guides of SCSS-mixins

Hi! Help me, please.
I have this code:

// Yellow gradient
//
// Compatible in IE6+, Firefox 2+, Safari 4+.
@mixin gr-yellow() {
    background:-webkit-linear-gradient(#FEE789, #FCCD10);
    background:     -o-linear-gradient(#FEE789, #FCCD10);
    background:linear-gradient(#FEE789, #FCCD10);
}

And this block don't exist in generated documentation. What I'm doing wrong?

Inline Markup?

I've already included being able to define markup in descriptions like so:

// Header
//
// Description paragraph.
//
// Markup: <a class="{$modifiers}">Link</a>
//
// :hover    - Change the color when moused-over
// .disabled - Alter styles to reflect that the link is disabled
//
// Styleguide 1.4.

But then what would be a good way to include inline markup on a per-modifier basis,
if at all? Was thinking perhaps:

// Markup: <a class="{$modifiers}">{$content}</a>
//
// :hover   - Change the color when moused over {Link}

Or something similar, but can see it getting clunky.

Attribute selectors as modifiers

What if my modifiers are not always class names?
E.g. I often use ARIA role attributes as modifiers:

.btn[aria-disabled="true"] { ... }

I did not find any practicable solution to document those.

Creating two-level navigation is not obvious

We would like to create a two-level menu in the left sidebar in a custom template and we're having issues with accessing the parent "reference" variable in the innerLoop:

<ul>
    {{#eachRoot}}
        <li><a href="section-{{reference}}.html">{{reference}}: {{header}}</a>
        {{#eachSection rootNumber}}
            <h1>{{header}}</h1>
            {{html description}}
        {{/eachSection}}
    </li>
    {{/eachRoot}}
</ul>

I'd like to turn:

<h1>{{header}}</h1>

into

<h1><a href="section{{../reference}}#{{reference}">{{header}}</a></h1>

Unfortunately, the parent scope Handlebars.js accessor (..) does not work.

Doesn't generate sections - public folder but no html

Windows 7, Node v0.8.8

kss-node css/all.css docs

Generating your KSS Styleguide!

 * Source: C:\Framework\css\all.css
 * Destination: C:\Framework\docs
 * Template: C:\Documents and Settings\user\Application Data\npm\node_modules\kss\lib\template

...compiling LESS
...parsing your styleguide

Generation completed successfully!
kss-node css docs --template "C:\Framework\docs\template"

Generating your KSS Styleguide!

 * Source: C:\Framework\css
 * Destination: C:\Framework\docs
 * Template: C:\Framework\docs\template

...compiling LESS
...parsing your styleguide
...generating section 1 [ Base ]
Property '0' of object #<Object> is not a function

Example CSS

/* 
Base

Base includes resets, normalization, and bare-bones default styles.

Styleguide 1
*/
/*
Reset

Minimalized resets that provide a foundation for base normalizations & defaults

Styleguide 1.1
*/
html, body, h1, h2, h3, h4, h5, h6, p, blockquote, ol, ul, dl, li, dd, pre,
fieldset, form, legend, input, select, textarea, button,
article, aside, figcaption, figure, section {
  margin: 0;
  padding: 0;
}

C:\Framework\docs is created and the public folder is copied with:

  • kss.css
  • kss.js
  • kss.less
  • less.js
  • markdown.less
  • prettify.js

But no HTML appears in "docs".

When styleguide.md is placed in the CSS folder, it generates an index.html file based on the contents. But no other HTML is generated, no section-x.html files.

Get one of the two above results whether I try it on my own CSS, on the demo, using the default template, using a custom template, etc. Got 2 other people to try it also, they have the same issues. Sometimes they get the Property 0 error and sometimes not. But in either no documentation is generated.

Issue with traverse in multiple modules.

I am running into an issue using kss.traverse() in multiple modules. Based on the following setup:

/app.js

var styles = require('./routes/styles');
var scripts = require('./routes/scripts');

styles.getStyles();
scripts.getScripts();

/routes/scripts.js

var kss = require('kss')
options = {
  markdown: false,
  masks: '*.css'
};

exports.getScripts = function() {
  kss.traverse('public/javascripts', options, function(err, guide) {
    if(err) throw err;
    console.log('scripts:',err,guide.data.files);
  });
};

/routes/styles.js

var kss = require('kss')
options = {
  markdown: false,
  masks: '*.css'
};

exports.getStyles = function() {
  kss.traverse('public/stylesheets', options, function(err, guide) {
    if(err) throw err;
    console.log('styles:',err,guide.data.files);
  });
};

Assume also that the following files exist:
/public/javascripts/scripts.css
/public/stylesheets/styles.css

This produces the following response in the log:

scripts: false [ 'public/javascripts/scripts.css' ]

What I should be seeing is a response of both 'scripts: ...' and 'styles: ...', but I only see one. The behavior is that the last method to be called in app.js is the one that gets a response. One traverse call seems to be interfering with the other.

Is this a bug or am I missing something?

Examples in top-level sections do not display

When you don't need subsections, it would be nice to be able to include examples right in your top-level section.

For example:

/*
Bins

Generic enclosed containers

Markup:
<div class="bin {$modifiers}">content</div>

Styleguide 6
*/

.bin {
     background-color: #ccc;
     border: 1px solid #333;
     margin-bottom: 10px;
     padding: 10px;
}

Not working on Windows?

Just noticed this bug in kss.traverse - something to do with additional items being picked up when reading through the directory contents, so the parsing method never gets called. Will get a fix out pretty soon.

Issue with SASS -

Trying to use your node module and keep getting this error:
kss-node sass styleguide --sass sass/global.scss

Generating your KSS Styleguide!

  • Source: /Users/jrutter/atg/svn/Development_39/grapevine-web.war/sass
  • Destination: /Users/jrutter/atg/svn/Development_39/grapevine-web.war/styleguide
  • Template: /usr/local/lib/node_modules/kss/lib/template

...compiling LESS
...parsing your styleguide
Cannot read property 'data' of undefined
TypeError: Cannot read property 'data' of undefined
at /usr/local/lib/node_modules/kss/bin/kss-node:146:18
at /usr/local/lib/node_modules/kss/lib/kss.js:67:18
at [object Object]. (fs.js:98:14)
at [object Object].emit (events.js:64:17)
at [object Object]. (fs.js:92:18)
at [object Object].emit (events.js:67:17)
at Object.oncomplete (fs.js:1072:12)

I cant figure out whats going wrong? It doesnt look like its working with the SASS files as it says compiling LESS. Any thoughts?

Volunteers to Maintain?

As is most likely already clear, I'm not able to make the time to maintain kss-node for those who use it, and haven't been able to for quite a while. But it seems that people still find it useful for creating their styleguides.

I'd like to hand the pushing/publishing rights to the repo over to a small group of people who are using this project on a regular basis. That way, the project can either be cleaned up or totally replaced if that's what people are after. @johannestroeger is already a maintainer, but the more the merrier :)

If anyone's interested, please let me know. If nobody wants to jump on board I'll be deprecating the project in a couple of weeks.

@indieisaconcept noticed your work on grunt-styleguide, would you be interested? @dotherightthing, I hade a look at the list of forks and looks like you've made a lot of changes too. Would you like to help out?

Include stylesheet source code into styleguide

May be i just did not figure out this thing, but is it possible to output source code (CSS, SASS, LESS). There are only html outputs in examples, but i would like to show my source code too. I know that syledocco can do this. Is it possible with kss-node?
If not, it could be a good feature.

Is this the output that I should be expecting? uncompiled handlebars .html file?

I'm using (/trying to use) kss-node to generate my styleguide. I'm not sure if the expected behavior is for handlebars markup within an .html file...

If that's whats supposed to happen:
am I supposed to do something in particular to compile it myself?
If I am supposed to compile it myself:
what data should I pass to the compiler?

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
  <meta charset="utf-8">

  <title>KSS: Living Styleguide</title>
  <meta name="description" content="">
  <meta name="generator" content="kss-node" />

  <meta name="viewport" content="width=device-width">

  <link href='http://fonts.googleapis.com/css?family=Droid+Serif' rel='stylesheet' type='text/css'>

  <link rel="stylesheet" href="public/kss.css">
  <link rel="stylesheet" href="public/style.css">

</head>
<body><div id="kss-wrapper">
  <div id="kss-nav">
    <header id="kss-header">
      <hgroup><h1>kss-node Styleguide</h1></hgroup>
    </header>
    <aside>
      <nav><ul>
        <li><a href="index.html">0.0: Overview</a></li>
        {{#eachRoot}}
          <li><a href="section-{{reference}}.html">{{reference}}.0: {{header}}</a></li>
        {{/eachRoot}}
      </ul></nav>
    </aside>
  </div>
  <div role="main" id="kss-main">
    <article id="kss-content">
      {{#if overview}}
        {{html overview}}
      {{else}}

        {{!
          Find each section, in order.
          If there's no markup or modifiers supplied, use a Markdown-only
          layout instead.

          The "root" element comes first in this loop, and can be detected using
          the "#whenDepth 1" block as seen below.
        }}
        {{#eachSection rootNumber}}
          {{#whenDepth 1}}
            <h1 class="kss-title"><span class="kss-ref">{{ reference }}.0</span> - {{ header }}</h1>
          {{else}}
           <section class="kss-depth-{{ refDepth }}">
            <h1 class="kss-title"><span class="kss-ref">{{ reference }}</span> - {{ header }}</h1>
          {{/whenDepth}}
            {{#ifAny markup modifiers}}
                <div class="kss-box">{{html description}}</div>
                <table class="kss-mod-list">
                  <tr class="kss-mod-desc-group">
                    <td class="kss-mod-desc"><p>Default styling</p></td>
                    <td class="kss-mod-name"></td>
                  </tr>
                  <tr class="kss-mod-example">
                    <td colspan="2">{{modifierMarkup}}</td>
                  </tr>
                {{#eachModifier}}
                  <tr class="kss-mod-desc-group">
                    <td class="kss-mod-desc">{{html description}}</td>
                    <td class="kss-mod-name"><p>{{name}}</p></td>
                  </tr>
                  <tr class="kss-mod-example">
                    <td colspan="2">{{modifierMarkup}}</td>
                  </tr>
                {{/eachModifier}}
                </table>
                <div class="kss-markup">
                  <pre class="prettyprint lang-html">{{markup}}</pre>
                </div>
            {{else}}
                {{#if description}}
                  {{html description}}
                {{/if}}
            {{/ifAny}}
          {{#whenDepth 1}} {{else}}
            </section>
          {{/whenDepth}}
        {{/eachSection}}
      {{/if}}
    </article>
  </div>
  <footer>
    {{#if argv.xdemo}}<a href="http://github.com/hughsk/kss-node"><img id="kss-github" style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/30f550e0d38ceb6ef5b81500c64d970b7fb0f028/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub"></a>{{/if}}
  </footer>
  <!-- SCRIPTS -->
  <script src="public/kss.js"></script>
  <script src="public/prettify.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  <script>
    $(document).ready(function(){
      var sidebarAdjust = function() {
        // Match footer/body height
        var height = Math.max($(window).height(), $('#kss-main').height());

        if ($(window).width() <= 768) {
          $('#kss-main, #kss-nav').height('auto');
        } else {
          $('#kss-main, #kss-nav').height(height);
        }
      };

      $(window).resize(sidebarAdjust);
      $(window).scroll(sidebarAdjust);
      sidebarAdjust();

      // Ensure code blocks are highlighted properly...
      $('pre>code').addClass('prettyprint');
      prettyPrint();

    });
  </script>

  {{! This won't be included in the demo page }}
  {{#if argv.xdemo}}
    <script type="text/javascript">
    var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-12249588-4']); _gaq.push(['_trackPageview']);
    (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();
    </script>
  {{/if}}
</div></body>
</html>

Does kss-node support UI component with CSS animation?

I tried to create a section for a loading animation (created by pure css), somehow it doesn't really work. I double check in the HTML manually created, it runs smoothly. I'm wonder kss-node doesn't support displaying css animation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.