包详细信息

grock

killercup144不推荐使用0.3.8

aint got time for that

Convert commented code to awesome side-by-side documentation.

documentation, docs, generator, cli

自述文件

grock

Grock converts your nicely commented code into a gorgeous documentation where comments and code live happily next to each other.

To see how it works, just have a look at the documentation rendered from this repository.

build status dependency version

Install

Install globally using npm install --global grock and invoke anywhere using grock --glob 'your/*.files'.

Or use it as a (dev-)dependency in your project and use the package.json script section to run it, e.g. with "scripts": {"docs": "grock"} and using npm run docs (read more about this here).

Usage

Basically:

$ grock --glob 'lib/**/*.js' --out 'docs' --verbose

For more information about available options, see bin/grock or run grock --help:

$ grock --help
Usage: grock [options]

You can also use a configuration file named .groc.json to specify these options.
The defaults below show the values of the .groc.json file when possible.

Options:
  --help                    Show this message
  --version                 Show grock version
  --glob                    Set glob to match source files                                                  [default: ["*.md","bin/*","lib/**/*.coffee","lib/**/*.js","styles/**/*.coffee","styles/**/*.md","bin/*.js"]]
  --out                     Render documentation into here                                                  [default: "docs/"]
  --style                   Set the output style/theme                                                      [default: "solarized"]
  --verbose                 Show more log output                                                            [default: false]
  --index                   File to be used as root index                                                   [default: "Readme.md"]
  --indexes                 Files to be used as indexes in sub directories                                  [default: "Readme.md"]
  --root                    The project's root directory                                                    [default: "."]
  --whitespace-after-token  Require whitespace after a comment token for a line to be considered a comment  [default: true]
  --repository-url          URL to link to source files                                                     [default: "https://github.com/killercup/grock"]
  --ext-scripts             An array of external scripts for appending to the template                      [default: []]
  --ext-styles              An array of external styles for appending to the template                       [default: []]
  --github                  Push generated docs to gh-pages branch                                          [default: false]
  --git-remote              Overwrite the remote for --github

For a list of supported languages, see the lib/languages.coffee file.

Config File

You can specify all the command line options in a .groc.json file (that is compatible to groc). This will automatically be loaded. This way you just need to save that file in your project directory and can use grock without arguments from now on.

Auto Publish Documentation to Github Pages

Using the --github flag, grock will try to write the documentation not to an output directory, but to the gh-pages branch of your git repository. If it succeeds, it will immediately push the new changes to the origin remote (can be specified by --git-remote.

Assuming you have specified all other options in ./.groc.json, you can then run:

$ grock --github

Inspiration

What makes grock different?

In contrast to other node-based documentation generators like docco, groc, and docker, grock has the following advantages:

  • It doesn't need pygments.
  • Therefore it doesn't need python.
  • Therefore it's faster than those other tools that need pygments.
  • It renders a file tree and also a headline tree for each document.
  • The default style (based on solarized) is responsive and looks actually quite good on a phone.
  • It doesn't crash on malformed doc tags.
  • It's based on streams. I've heard all the cool kids are using streams now.

Based on

Oh, and all the heavy lifting (splitting code and comments, parsing doc tags) is actually code from groc!

Roadmap

  • [x] Be awesome with streams
  • [x] Split code and comments
  • [x] Highlight code
  • [x] Generate TOC as JSON file
  • [x] Render doc tags (like jsdoc)
  • [x] CLI docs, .groc.json config support
  • [ ] Correctly parse relative roots
  • [x] Tests. Test for almost everything.
  • [x] Add another style.
  • [ ] Find a streaming code highlighter with hooks for comment segments
  • [x] Parse files without extension

Contributing

Just fork the repo, implement some awesome feature or fix a bug and send a pull request.

Code Style and Guideline

  • Document your code.
  • Write code in CoffeeScript when possible and make sure coffeelint doesn't throw any warning or errors.
  • Make use of streams and promises. Those are good techniques.
  • Split the code into as many independent, loosely coupled modules as possible and try to reuse existing ones.
  • Write tests for those small modules.
  • On the other hand, try to minimize (NPM) dependencies. Since this is a CLI tool, the startup time gets worse with every require.
  • Run npm test before committing. (Currently, this runs coffeelint and mocha).

Contributing to Styles

When adding a new style or editing an existing one, make sure you follow the guidelines in styles/Readme.md (e.g. adding an index file exporting copy, compile and template functions).

Changelog

See list of releases on Github or read the Changelog.md file.

License

MIT (see LICENSE).

更新日志

Changelog

v0.3.8 Toothless Turtle

Sa Mar 28 2015

  • Update language definitions from groc (@jonruttan)

v0.3.7 Hanga Roa Horse

Su Jan 11 2015

  • Added options for external scripts and styles (@vitkarpov)
  • Update dependencies

v0.3.6 Stanley Sheep

Su Nov 16 2014

  • Fix Handlebars/Mustache support (@WCPetersen)

v0.3.5 Bolden Lizard

Th Sep 11 2014

  • Add rudimentary support for Facebook React JSX files (Thanks, @jdiaz5513!)

v0.3.4 Brazzaville Butterfly

Th Jun 12 2014

  • Fix Disabling whitespace-after-token (Thanks, @despairblue!)

v0.3.3 Tirana Turtle

Mon Apr 28 2014

  • Add support for parsing CSON files (Thanks, @erikmueller!)

v0.3.2 Douglas Dog

Wed Mar 18 2014

  • Add whitespace-after-token option (Thanks, @novemberborn!)

v0.3.1 Cotonou Chameleon

Wed Feb 19 2014

  • Fix RepositoryURL Fallback

v0.3.0 Papeete Polar Bear

Mon Feb 10 2014

  • Add Thin style with bright colors and sharp fonts: Screenshot
  • Correctly link to latest source files on Github and Bitbucket (git repos)
  • Add copyright and license doc tags

v0.2.6 Dave Thesis

Sat Feb 08 2014

  • Add --indexes option to generate subdirectory index files (default: Readme.md gets rendered as index.html)
  • Fix doc tags order messing up markdown
  • Automatically retrieve repository URL from package.json

v0.2.5 Oscar Hera

Mon Feb 03 2014

  • Adds nice error messages à la plumber
    • incl. file path
    • with stack traces on --verbose
  • Add better page titles
  • Fixes index.js and thus require('grock')

v0.2.4 Jefferson Hemera

Sat Feb 01 2014

  • Trim unnecessary newlines from highlighted code
  • Fix searching headlines
  • Improve tests and hopefully performance

v0.2.3 Steel-Eye Demeter

Thu Jan 30 2014

  • Render files without extension (treating them as JS)
  • Trim HTML from headlines in TOC
  • Always skip processing directories
  • Don't crash on malformed doc tags
  • Add more usage information to Readme file

v0.2.2 Happy Erebus

Thu Jan 30 2014

  • Precompile Templates
    • Enhances performance
    • Styles can use any templating library
  • Solarized uses lodash templates now (this removes jade dependency)
  • CoffeeScript 1.7 makes chained function calls more pretty (e.g. in streams and .pipes)
  • Speed things up a bit by skipping highlight.js and marked for files without code or comments (e.g. .md and .json)

v0.2.1 Louis Hermes

Sun Jan 26 2014

  • Script to publish to Github Pages branch
  • Optimize writing of table of contents file

v0.2.0 Earl Kaikias

Sat Jan 25 2014

  • CLI arguments and .groc.json compliment each other
  • Remove gulp-util dependency
  • Solarized: Better responsive modes
  • Solarized: Nicer directory index handling
  • Solarized: Fix file title from headline
  • Solarized: Readmes are fist files in directories

v0.1.2 Dizzy Demeter

Mon Jan 20 2014

  • Add missing log module

v0.1.1 Dizzy Ares

Mon Jan 20 2014

  • Add file path above document, link to currnt file in repository
  • Add checkbox lists in markdown (using [ ] and [x] syntax)
  • Fix some broken words (using CSS' word-break)

v0.1.0 Clark Hades

Mon Jan 20 2014

Initial release.

Features so far:

  • Take code files, output html files
  • Split code and comments
  • Highlight code (even in comments)
  • Generate TOC as JSON file
  • Render doc tags (like jsdoc)
  • CLI docs, .groc.json config support
  • Default output style
    • Based on Solarized
    • Searchable file and headline list
    • Responsive layout