• Stars
    star
    137
  • Rank 265,336 (Top 6 %)
  • Language
    Ruby
  • Created about 15 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Documentation generator for CSS files, similar to Javadoc or RDoc.

css_doc

css_doc is a Ruby library and command line tool to extract documentation from CSS files. The format of the documentation is very similar to JavaDoc.

css_doc was inspired by the CSSDOC project, but it is NOT a complete implementation of the proposed standard, although it should be fairly compatible. As there is no documentation extractor for the CSSDOC standard, this project should fill the gap for many people.

Features

  • Extracts file-scope documentation for each CSS source file.

  • Extracts documentation for rule sets (i.e. a set of selectors separated by commas with a declaration).

  • Files can be separated into several sections.

  • For rule set documentation, html code examples can be incorporated into the documentation.

  • Generates selector, section and file index pages.

What does it look like?

Consider the famous reset style sheet, documented with css_doc:

/**
* @file reset.css
* @author Eric Meyer, documented by Thomas Kadauke
* @css-for IE 5, IE 6, IE 7, IE 8, Safari 3, Safari 4, Firefox 2, Firefox 3
*/

/**
* @section Reset styles
* These styles reset the default style sheet that comes with the user agent.
*/

/**
* Set margins and paddings to 0, and font-properties to a default value.
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  font-weight: inherit;
  font-style: inherit;
  font-size: 100%;
  font-family: inherit;
  vertical-align: baseline;
}
/**
* Reset focus styles to nothing.
* Remember to define focus styles in after this declaration.
*/
:focus {
  outline: 0;
}
/**
* Reset text color and line height.
*/
body {
  line-height: 1;
  color: black;
  background: white;
}
/**
* Remove default list decoration.
*/
ol, ul {
  list-style: none;
}
/*
* Remove default table styling.
* Tables still need 'cellspacing="0"' in the markup.
*/
table {
  border-collapse: separate;
  border-spacing: 0;
}
/**
* Reset text alignment and typography for special tags.
*/
caption, th, td {
  text-align: left;
  font-weight: normal;
}
/**
* Remove CSS generated content around citation tags.
*/
blockquote:before, blockquote:after,
q:before, q:after {
  content: "";
}
blockquote, q {
  quotes: "" "";
}

Dependencies

Installation

The easiest way to install this gem is directly via the github gem repository:

$ sudo gem install css_doc

For css_doc to work, you need the latest version of CSSPool (2.0.0). CSSPool depends on libcroco, which can be installed on OS X via

$ sudo port install libcroco

Unfortunately, at the time of this writing, libcroco contains a bug, which is essential to css_doc: it does not parse comments, but instead it simply ignores them. The libcroco authors have already been notified of this bug, and will hopefully release a fixed version soon.

To make things work, download a copy of libcroco from

http://ftp.gnome.org/pub/gnome/sources/libcroco/0.6/

(preferably version 0.6.2), and add the following lines to src/cr-parser.c, line 630, between “do { if (token) {” and “cr_token_destroy(token)”:

if (token->type == COMMENT_TK && PRIVATE (a_this)->sac_handler && PRIVATE (a_this)->sac_handler->comment) {
    PRIVATE (a_this)->sac_handler->comment(PRIVATE (a_this)->sac_handler, token->u.str);
}

Then, in the root directory of libcroco, compile using

$ ./configure
$ make

You can use make install to install the library, but you can just as well set the environment variable LIBCROCO to

/path/to/libcroco/src/.libs/libcroco-0.6.dylib

(on OS X), or

/path/to/libcroco/src/.libs/libcroco-0.6.so

on other Unix systems.

Usage

As command line client

To get help, type

$ cssdoc --help

The command line options are

-o, --output=dir                 Specify output directory
-s, --skip=files                 Skip specified files
-p, --project-name=name          Specify Project name
-v, --[no-]verbose               Run verbosely
-t, --template=name/path         Specify template or template path

You can specifiy the input directory as an optional last parameter. The default is the current directory. For skipped files, a comma-separated list of file names relative to the input directory is expected.

The default options usually work well. Just go to your repository root, and type

$ cssdoc

In Rakefiles

To define a rake task for css_doc, add the following to your Rakefile:

require 'rake/css_doc_task'

# only if libcroco is not found automatically
ENV['LIBCROCO'] = '/path/to/libcroco'

Rake::CSSDocTask.new('doc:css') do |task|
  task.input_dir = 'public/stylesheets' # default
  task.output_dir = 'css_doc' # default

  task.project_name = 'my_project'
  task.skip_files = ['base_packaged.css', 'print_packaged.css']
  task.verbose = true
end

TODO

  • Implement more tags

  • Make default template pretty

  • Include more templates

Getting it, License and Patches

Get the complete source code through github.com/tkadauke/css_doc. For installation instructions, see above. License is MIT. That means that you can do whatever you want with the software, as long as the copyright statement stays intact. Please be a kind open source citizen, and give back your patches and extensions. Just fork the code on Github, and after you’re done, send us a pull request. Thanks for your help!

Copyright © 2008-2009 Thomas Kadauke, released under the MIT license

More Repositories

1

motion-resource

Access RESTful resources from your iOS app. Inspired by ActiveResource.
Ruby
77
star
2

TinyMon

iOS client for TinyMon using RubyMotion
Ruby
66
star
3

tiny_mon

Website Acceptance Monitoring
Ruby
22
star
4

motion-i18n

Wrapper for translations in RubyMotion
Ruby
20
star
5

i18n_tools

Very simple rake tasks for finding missing and unused translations in Rails applications using the I18n library.
Ruby
20
star
6

motion-parse

Thin wrapper around the Parse SDK for RubyMotion
Ruby
11
star
7

background_lite

Easy-to-use Rails gem for background processing
Ruby
8
star
8

tiny_ci

Continuous Integration Server for Ruby on Rails
Ruby
7
star
9

motion-devices

RubyMotion rake task that allows easy distribution to multiple devices
Ruby
6
star
10

TimePlane

Small RubyMotion app that makes time zone calculations trivial
Ruby
5
star
11

tuxml

JUnit XML compatible output for Ruby's Test::Unit framework
Ruby
5
star
12

mpk_classic

TeX
5
star
13

jsmock

Mocking framework for Javascript unit tests using the Scriptaculous unittest.js
JavaScript
4
star
14

gitchat

Chat system using git as the backend
Shell
4
star
15

raytracer

This is a raytracing library that is focused on speed and interactive rendering.
C++
3
star
16

pdf_renderer

Render PDFs using LaTeX in your Rails applications
Ruby
3
star
17

symbols

Defines UTF-8 symbols for common math concepts
Ruby
2
star
18

Logger

Tiny graphical display for logs generated with motion-support's NetworkLogger
Ruby
2
star
19

tiny_notes

Manage TODOs from release notes
Ruby
2
star
20

poop

Persistent Object Oriented Programming
Shell
2
star
21

motion-frank-screenshots

Take automated screenshots for RubyMotion apps using Frank
Ruby
2
star
22

dirty_after_save

Track changes even after saving an ActiveRecord model
Ruby
1
star
23

has_properties

Makes STI base classes with extensible attributes possible through serialization
Ruby
1
star
24

tiny_vault

Store passwords and share them with groups of people
Ruby
1
star
25

gemmer

Define rake tasks for managing gems
Ruby
1
star
26

iTunnel

RubyCocoa application that presents a configurable menu of servers to SSH tunnel into
Ruby
1
star
27

tiny_core_accounts

Simple account management based on tiny_core_users
Ruby
1
star
28

tiny_core

Common parts for building Tiny Applications
Ruby
1
star
29

tiny_core_users

Simple reusable user management with generator based on authlogic
Ruby
1
star
30

const_cache

Cache dynamic constant lookups in RubyMotion
Ruby
1
star
31

brickset-api-ruby

Ruby
1
star
32

scatter

Easily distribute rubygems on several machines
Ruby
1
star
33

starttime

Inspect start up time of Ruby applications
Ruby
1
star