Cssdoc
Cssdoc
CSSDOC Project
The CSSDOC project is done together with Timo Derstappen and Dirk Jesse. I'd like to thank them
for the ongoing support and for taking care. For example Dirk Jesse did a great job with CSSDOC
inside his mature YAML CSS Framework1 and this specification benefits a lot from his input.
http://www.cssdoc.net/
Feedback
The CSSDOC Project is planing to re-work the website infrastructure to better support the
specification process and to provide community support. As long as we still use the first and
password protected website due to our limited resources, please contact us by email.
1 http://www.yaml.de/en/home.html
1.1. DocBlock
These are comments spanning multiple lines written in a specific convention. They start with a /**
character-sequence and are followed by one or more nicely intended lines beginning with a *. The
DocBlock is closed on the last line with the */ character-sequence which has to be intended as
well.
NOTE: Javadoc 1.4 does partially lower the strictness on how to write the
DocBlock. CSSDOC parser authors might want to take this into account.
Please check the Javadoc specification for this.
Inside this “Block marker” there is space for a title (normally the first line) and a human readable
description, which can be followed separated by an empty line in the DocBlock. The Larger
DocBlock example shows this.
/**
* Homepage Style
*
* Standard Layout (all parts) for Big Little Homepage
*
* This style has been designed by Mina Margin. It reflects
* the composition of colors through the years of the
* customers project as well as the boldness it implies.
*
* @project Big Little Homepage
* @version 0.2.8
* @package xhtml-css
* @author Mina Margin
* @copyright 2008 by the author
* @cssdoc version 1.0-pre
* @license GPL v3
*
* @colordef #fff; white
* @colordef #808080; standard grey
*/
4 See http://www.w3.org/International/questions/qa-css-charset
A parser must identify it as the file comment but a non-docblock-styled comment proceeding it
should be treated as a standard CSS comment by the parser. Even if the file comment should not be
proceeded by any other comment. This should be considered as bad practise. A parser might throw a
warning then.
A parser must find at least the file comment. If it does not exists, the file must be classified as CSS
file without CSSDOC.
To open a new section, the @section tag must be placed into the section comment. Infact the
@section tag turns a docblock into a section comment. Any docblock not being the first one without
the @section tag is just a standard CSSDOC comment.
The following example shows a simple section comment for a CSS-reset block.
1.3. Tags
Tags are one-word-identifiers that start with the @-symbol.
1.4. Syntax
At the lexical level, CSSDOC must match with the standard sequence of tokens for CSS. In CSS21
the definition uses lex-style regular expressions. Octal codes refer to ISO 106467.
Therefore anything - and that means main description, tag naming and values as well - must match
the comment description8 without ending it:
Token Definition
COMMENT \/\*[^*]*\*+([^/*][^*]*\*+)*\/
This might look quite complicated and the CSS specification misses to reference lex-style regular
expression9 or even define it at all. So it is advisable to get a closer look inside the CSS
specifications:
“Comments begin with the characters '/*' and end with the characters '*/'. They may
occur anywhere between tokens, and their contents have no influence on the rendering.
Comments may not be nested.” - 4.1.9 Comments in CSS 2.1 Specification10
“Textual comments in CSS style sheets are similar to those in the C programming
language [7]:
EM { color: red } /* red, really red!! */
Comments cannot be nested. For a CSS1 parser, a comment is equivalent to
whitespace.” - 1.7 Comments in Cascading Style Sheets, level 111
That specified, CSSDOC can create its own syntax within this domain. It is great to see, that the
7 No real data, only a ISO-Number specified: "Information Technology - Universal Multiple- Octet Coded Character
Set (UCS) - Part 1: Architecture and Basic Multilingual Plane", ISO/IEC 10646-1:2003. Useful roadmap of the BMP
and plane 1 documents show which scripts sit at which numeric ranges.”; compare
http://www.w3.org/TR/CSS21/refs.html#ref-ISO10646
8 http://www.w3.org/TR/CSS21/syndata.html#tokenization
9 Lex - A Lexical Analyzer Generator by M. E. Lesk and E. Schmidt; http://dinosaur.compilertools.net/lex/index.html
10 http://www.w3.org/TR/CSS21/syndata.html#comments
11 http://www.w3.org/TR/CSS1#comments
\s\*\s{tagname}
Tag with a value
\s\*\s{tagname}\s*{tagvalue}
Tag with a value spanning multiple lines:
\s\*\s{tagname}\s*{tagvalue}({nl}
\s\*\s+{tagvalue})+
As where nl is {\n|\r\n|\r|\f}.
[@][_a-z-][_a-z0-9-]+
([a-z0-9A-Z]|[$_\.\+!*'\(\),:\[\]-]|[\s\t])+
For a simple value of smaller size which fits into the current line , it is simply anything from the
first non-space character ([^\s]) to the end of the line minus spaces at the end.
An empty line in the next line within the comment is not part of the last value. Empty lines empty
values.
1.5. Parser
A Parser is a program reading the machine-readable parts from a CSSDOC CSS file. CSS parsers
already do exist, CSSDOC enabled CSS parsers not yet.
A CSSDOC enabled parser must parse as intended. That means, it handles the CSS file properly and
is taking care of the comments as well. That is called normal parsemode. The CSSDOC command
parsing off must throw the parser into skipping parsemode which enables the parser to exclude a
range of the file from syntactical correct CSS parsing. This is a feature a CSSDOC parser must
have.
NOTE: skipping parsemode has been defined to work around useragent CSS-
parsing-bugs that would stop a strict-standards-working CSS parser.
This solves problems many CSS tools are facing. Non-standard CSS code can not be properly
optimized nor excluded. Such tools can now refer to CSSDOC to include such a functionality.
More Information can be found in 2.3.6. Parser and Control Tags and in the Tag Reference for Tag
@cssdoc .
13 See http://www.rfc-editor.org/rfc/rfc1738.txt
14 See http://www.w3.org/TR/html401/types.html#h-6.2
15 See http://en.wikipedia.org/wiki/UTC
● Grouped by usage:
○ Tags related to CSS-Hacks are tags used to describe CSS hacks and workarounds.
○ Versioning and Packaging Tags are tags that can be used for versioning and to add a
CSS file to packages (of an Application etc.).
○ Application defined Tagsare tags used for (web-) application metadata
○ Parser and Control Tags deliver information for a CSSDOC parser (CSSDOC
commands)
It is a complex topic in CSS and the usage of CSSDOC will reflect it with some tags designed for
this problematic topic in mind. Mostly these tags are informative.
CSS-Hacks can be classified and explained with CSSDOC. They can be marked as valid or invalid
CSS (@valid), affected browsers can be listed and browsers for which the hack were written for
(@affected, @css-for) can be written down.
CSSDOC offers two classifications for CSS-Hacks: Bugfix (@bugfix) and Workaround
(@workaround):
Bugfix Workaround
Should remove CSS-Rendering Problems Some browsers need a reduced rendering because
without having bothersome adverse effects. they are full of errors. A Workaround works
around those Issues.
2.3.3.1. Bugfix
A Bugfix should “fix” CSS-Rendering Problems (Bugs) and lead to an error-free display so that it
can be compared to other Browsers output.
A good Example is the fix for the “Disappearing List-Background Bug”17. Lists in IE 6 do partial
loose their Background-colors.
/**
* Disappearing List-Background Bug
*
* @bugfix
* @affected IE 5.x/Win, IE6
* @valid yes
*/
16 http://css-discuss.incutio.com/?page=CssHack
17 http://www.positioniseverything.net/explorer/ie-listbug.html
2.3.3.2. Workaround
A workaround are rules that lead to a more error-free display but it implies that visual design goals
or the CSS intention can not be matched up with. The quite famous Guillotine Bug18 for Example. It
is not possible to gain a correct display in internet explorer 6 or 7. Instead a workaround is chosen
to prevent an errorneous display. This is done with the cost of a “correct” display, so it is classified
as workaround.
/**
* IE/Win Guillotine Bug
*
* @workaround
* @affected IE 5.x/Win, IE6
* @css-for IE 5.x/Win, IE6
* @valid yes
*/
* html body a,
* html body a:hover { background-color: transparent; }
NOTE: Using invalid CSS can break the concept of CSSDOC. Please see
Parser and Control Tags for signalling a parser that some part of a
file is not to be parsed because it is not valid CSS.
18 http://www.positioniseverything.net/explorer/guillotine.html
19 Please compare to the YAML documentation and sourcecode for a broad range of bugfix and workaround cases.
http://www.yaml.de/
/**
* @css-for ie5
* @workaround Faux Box Modell
* @valid false; This is a IE parser bug for comments
* @cssdoc parsing off
*/
.box {width:280px; padding:20px;} /* * /.box {width:240px;
padding:20px;} */
/**
* @section plain, erroneous texts
* @cssdoc parsing on
* @cssdoc parsing off
*/
This is not valid CSS at all but it will never be a problem for
a browser to handle this file nor for a strict CSSDOC parser.
/* @cssdoc parsing on */
@affected
○ Location: File Comment, Section Comment
○ Usage: Name a browser version for a bugfix or workaround.
○ Value: Browser and version, or a group of useragents.
○ Note: Should be used together with @bugfix or @workaround only.
○ See: @bugfix, @workaround, Appendix D: List of Browsers
○ Example:
Ex.1 /**
* My CSS Workaround
*
* @workaround wrong border display
* @affected opera3-6.1 win
*/
Ex.2 /**
* Avoid unneeded page breaks of #col3
* content in print layout.
*
* @bugfix
* @affected ie7
* @css-for ie5.x win, ie6, ie7
* @valid yes
*/
#col3 { height: 1% }
@bugfix
○ Location: File Comment, Section Comment, Standard CSS Comment
○ Usage: Documentation of CSS bugfixes
○ Value: None
○ Note: A Bugfix is CSS to fix (not circumvent) display- or rendering-bugs of a
browser.
○ See: @affected, @css-for, @workaround
○ Example:
Ex.1 /**
* Doubled Float-Margin Bug
*
* @see http://...
*
* @bugfix
* @affected ie5 win, ie6
* @css-for all browsers
* @valid yes
*/
Ex.2 /**
* Avoid unneeded page breaks of #col3
* content in print layout.
*
* @bugfix
* @affected ie7
* @css-for ie5.x win, ie6, ie7
* @valid yes
*/
Ex.2 /**
[...]
* @colordef rgb(45,71,108); Camou d'accord (activeBackground)
* @colordef rgb(142,155,161); Rhyme Dump Down (activeBlend)
* @colordef rgb(251,251,231); Sellout Gay Gray (activeForeground)
* @colordef rgb(142,155,161); Less Red* (activeTitleBtnBg)
* @colordef rgb(242,242,223); Snowflash (alternateBackground)
* @colordef rgb(240,240,214); Pay for Grey (background)
* @colordef rgb(230,230,205); Silver Snow Boots (buttonBackground)
* @colordef rgb(0,0,0); Black (buttonForeground)
* @colordef rgb(0,0,0); Black (foreground)
* @colordef rgb(157,168,169); Tripple Sec Dry Grey (frame)
* @colordef rgb(157,168,169); Tripple Sec Dry Grey (handle)
* @colordef rgb(95,114,135); Minor Mist (inactiveBackground)
* @note glad-beige-colors
* @see http://www.kde-look.org/content/show.php?content=75982
*/
@copyright
○ Location: File Comment
○ Usage: Copyright Information of file.
○ Value: Copyright string
○ Example:
Ex.1 /**
* [...]
* @copyright Copyright(c) 1992, 2006-2007
* by My Little Big Corp Inc.
* [...]
*/
@css-for
○ Location: File Comment, Section Comment
○ Usage: Naming the browser rules have been written for.
○ Note: Related to @bugfix and @workaround.
○ Value: Name of fixed browsers
○ See: @bugfix, @workaround, Appendix D: List of Browsers
○ Example:
Ex.1 /**
* [...]
* @css-for IE 6 Win32.
* [...]
*/
@cssdoc
○ Location: File Comment, Section Comment
○ Usage: Controlling and signalling a CSSDOC parser
○ Value: A CSSDOC command (Tag Value)
○ See: 2.3.6. Parser and Control Tags
○ Example:
Ex.1 /**
* [...]
* @cssdoc version 1.0-pre
* [...]
*/
[...]
/* @cssdoc parsing on */
@fontdef
○ Location: File Comment
○ Usage: Definition of a font
○ Value: Fontdef (Tag Value)
[@edit: Specifiy and discuss with font-knowing CSSers]
○ See: @colordef
○ Example:
Ex.1 /**
* [...]
* @fontdef freesans, arial, sans-serif, sans;
* serifenlose classique (headlines)
* [...]
*/
@group
○ Location: File Comment, Section Comment, Standard CSS Comment
○ Status: Reserved; Third Party Tag, used by CSSEdit
○ Note: Usage of this tag was not being specified so far. Feedback from vendor
pending.
○ See: Appendix C: Tags used by Third Parties
@lastmodified
○ Location: File Comment
○ Usage: Document last date of modification..
○ Value: Timestamp of the last Modification.
○ See: @date
○ Example:
Ex.1 /**
* [...]
* @lastmodified 2007-07-24 12:34
* [...]
*/
@link
○ Location: File Comment
○ Usage: File referencing hyperlink. Example: If it is part of a Theme, this could be the
Homepage of the theme.
○ Value: Hyperlink
○ See: @author
○ Example:
Ex.1 /**
* [...]
* @link http://www.example.com/
* [...]
*/
@media
○ Location: File Comment
○ Usage: Media descriptor for a file.
○ Value: CSS media descriptor
○ Note: Same wording is a CSS Selector
○ See: Appendix B: CSS that looks like Tags
○ Example:
Ex.1 /**
* [...]
* @media print
* [...]
*/
@package
○ Location: File Comment
○ Usage: Associate one or multiple files to a package
○ Value: Package name
○ See: @version, @subpackage
○ Example:
Ex.1 /**
* [...]
* @package xhtml-css
.* @subpackage css
* [...]
*/
@revision
○ Location: File Comment
○ Status: Unstable, might become obsolete because the @version is capable already and
there is no use with standard versioning systems.
○ Usage: Documentation of the file revision. Useful for systems like svn20 or similar.
○ Value: Revision number
○ See: @version
○ Example:
Ex.1 /**
* [...]
* @version 0.2.8
* @revision 193
* [...]
*/
@see
○ Location: File Comment, Section Comment
○ Usage: Reference more Info for a section or the file.
○ Value: Text, URL
○ See: @section, @link
○ Example:
Ex.1 /**
* Reset
*
* Reset to own Defaults
*
* @section reset
* @see YUI Reset CSS,
* http://developer.yahoo.com/yui/reset/
*/
@since-revision
○ Location: File Comment, Section Comment
○ Usage: Reference since which revision a section or file exists.
○ Value: Revision number
○ See: @since, @revision
○ Example:
Ex.1 /**
* [...]
* @since 0.2.8
* @since-revision 193
*/
@site
○ Location: File Comment
○ Usage: Name a site this style has been made for
○ Value: Text.
○ See: @project, @link, @package
○ Note: @pacakge might be an option as well
○ Example:
Ex.1 /**
* couleurs de l'été
*
* MyWebsite Style for Summer 2008
*
* @site mywebsite
* [...]
*/
@subpackage
○ Location: File Comment
○ Usage: Packaging
○ Value: Subpackage Name
○ See: @package
○ Example:
Ex.1 /**
* [...]
* @package xhtml-css
* @subpackage css
* [...]
*/
@subsection
○ Location: Section Comment
○ Usage: Adding structure to a CSS-File
○ Value: Subsection Name
○ See: @section, @subsubsection
○ Example:
Ex.1 /**
* [...]
* @section reset
*/
[...]
/**
* [...]
* @subsection forms
*/
@tested
○ Location: File Comment, Section Comment
○ Usage: Note which browsers a section has been tested with.
○ Value: List of tested browsers
○ Note: For ordering reasons multiple @tested tags can be used, one for each user
agent. Instead of this a comma-seperated list can be used as well. Or both.
○ Example:
Ex.1 /**
* My CSS Workaround Testsuite
*
* @workaround wrong border display
* @affected opera3-6.1 win
* @tested ie4, ie5, ie6, i7
* @tested opera3-6.1 win
* @tested moz7
*/
@valid
○ Location: File Comment, Section Comment
○ Usage: Flag validity of CSS.
○ Value: Bool (see 2.2.3. Yes/No (Tag Value) )
○ Note: If a section or a Bugfix is known not to be valid CSS, this can be flagged with
this @valid tag. Keep in mind that this is no replacement for switching the
parser off and on again for proper parsing.
○ See: @bugfix, @cssdoc
○ Example:
Ex.1 /**
* [...]
* @valid false
* [...]
*/
@version
○ Location: File Comment
○ Usage: Specify the fileversion.
○ Value: Version Number
○ See: @revision
○ Example:
Ex.1 /**
* [...]
* @version 1.2
* [...]
*/
@app-
○ Location: File Comment
○ Status: Obsolete (was: “Unstable, might become obsolete because of Vendor Specific
Tags (1.4.2.1. Vendor-specific Tagnames).”)
○ Usage: Tag of a previously defined tag-namespace. Used to create an own defitnition
of tags.
○ Value: Defined by Application
○ See: @appdef
○ Example:
Ex.1 /**
* My CSS File
*
* @appdef myapp My Application
* @app-myapp-theme Kubrik 3D
* @app-myapp-used True
*/
[...]
/**
* debugging of the background
*
* @section debug-background
* @app-yaml-default disabled
*/
@debug
○ Location: File Comment, Section Comment
○ Status: Obsolete, was once bugfix related
○ See: Tags related to CSS Hacks
@ref
○ Location: File Comment, Section Comment
○ Status: Obsolete (was: “Unstable; might become obsolete or future, see @see”)
○ Usage: Reference something: A File, a Website, another section
○ Value: Reference
○ See: @see
○ Note: For a strict reference to something existing (is it really?) so that an editor can
aquire it (e.g. open that file). Concept for reference is missing, see Reference
(Tag Value). @see is doing this in javadoc. @see should do it in cssdoc as well.
○ Example:
Ex.1 /**
* [...]
* @ref file:///home/mot/.defaults
* @ref file://./print.css
* [...]
*/
21 See http://www.w3.org/TR/REC-CSS2/syndata.html#at-rules
22 Disabling at-rules can be easily done by renaming it to an undefined at-rule. See
http://www.w3.org/TR/CSS21/syndata.html#parsing-errors for more infos.
CSSDOC DRAFT 0.2.22 // Appendix B: CSS that looks like Tags // Page 32 of 39
Appendix C: Tags used by Third Parties
@group
The @group Tag is used by a CSS editing software CSSEdit23. It uses the @group Tag to create a
kind of section that is reflected in an outline afterwards.
An Idea might be to integrate the @group tag into CSSDOC as well.
[@edit: CSS-Edit Authors have been contacted for a Statement of how @group works, answer is
pending.]
Icab
Konqueror
Netscape
Safari
NOTE: Keep in mind that there is no rule in CSSDOC that forces a CSS author
to write down browser names in a specific way.
24 See http://en.wikipedia.org/wiki/List_of_web_browsers
25 See FAQ in Mozilla Firefox 1.5 Release Notes Question 8. http://www.mozilla.com/en-US/firefox/releases/1.5.html
Publications
Even though CSSDOC is quite new, some printed publications about it are already available.
● German
○ "Praxislösungen mit YAML 3.0 YAML" by Dirk Jesse, Galileo Press 2007 (Second
Edition), ISBN 978-3-8362-1135-2, Page ff
○ "Anmerkungen zum Stil - Stylesheets mit CSSDOC kommentieren" by Michael
Jendryschik, iX Magazin für professionelle Informationstechnik (3 2008), Heise
Zeitschriften Verlag Verlag GmbH & Co. KG, ISSN 0935-9680, Page 132-134
[@edit: get infos about the page from dirks book.]
[@edit: eike zuleeg website as example]
[@edit: Technical reviewers should add their Examples as well]
26 http://phpugffm.de/index.php/phpugffm-goes-cssdoc,2007-05,198.html , http://phpugffm.de/wp-
content/uploads/2007/05/style-before.css and http://phpugffm.de/wp-content/uploads/2007/05/style-after.css
27 http://www.yaml.de/en/home.html and http://www.yaml.de/fileadmin/download/yaml_304_071127.zip
28 http://www.widerstand-portrait.de/ and http://www.widerstand-portrait.de/site/style.css
29 http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/javadoc.html#documentation
30 http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/javadoc.html#documentationcomments
31 http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_phpDocumentor.quickstart.pkg.ht
ml
32 http://www.w3.org/TR/1999/REC-CSS1-19990111
33 http://www.w3.org/TR/2007/CR-CSS21-20070719
34 http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt
35 http://www.w3.org/TR/2007/WD-xhtml11-20070216/
Index of Examples
Example 1: Small DocBlock example..................................................................................................4
Example 2: Larger DocBlock example................................................................................................5
Example 3: File Comment DocBlock example....................................................................................5
Example 4: Section Comment DocBlock (Reset section)....................................................................7
Example 5: Non-file and non-section CSSDOC comment..................................................................7
Example 6: Very short CSSDOC comment..........................................................................................7
Example 7: File comment with three tags............................................................................................8
Example 8: Bugfix Example..............................................................................................................14
Example 9: Bugfix Example..............................................................................................................14
Example 10: Small Parser Control Example......................................................................................15
Example 11: Detailed Parser Control Example..................................................................................15
Index of Illustrations
Illustration 1: Usagescheme of file and section comment....................................................................6
Illustration 2: Parsermode-Scheme.....................................................................................................10