css_doc 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ module CSSDoc
2
+ class SectionDocumentation < Documentation
3
+ define_tag :section
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ require 'erb'
2
+
3
+ module CSSDoc
4
+ class Template
5
+ @@default_template_path = File.dirname(__FILE__) + '/../templates/default'
6
+
7
+ def initialize(options = {})
8
+ @options = options
9
+ end
10
+
11
+ class Evaluator
12
+
13
+ end
14
+
15
+ def render(name, variables = {})
16
+ variables.each do |key, value|
17
+ instance_variable_set(:"@#{key}", value)
18
+ end
19
+ content = ERB.new(template(name)).result(binding)
20
+ ERB.new(layout).result(binding)
21
+ end
22
+
23
+ def template_path
24
+ @options[:template_path] || @@default_template_path
25
+ end
26
+
27
+ def template(template_name)
28
+ File.read("#{template_path}/#{template_name}.html.erb")
29
+ end
30
+
31
+ def layout
32
+ File.read("#{template_path}/layout.html.erb")
33
+ end
34
+
35
+ def relative_root
36
+ @options[:relative_root] || "."
37
+ end
38
+
39
+ def truncate(string, length)
40
+ if string.size > length
41
+ string[0..(length - 4)] + '...'
42
+ else
43
+ string
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,9 @@
1
+ module CSSPool
2
+ module Visitors
3
+ class ToCSS
4
+ def visit_CSSDoc_RuleSet(*args)
5
+ visit_CSSPool_CSS_RuleSet(*args)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ module Rake
2
+ class CSSDocTask < TaskLib
3
+ attr_accessor :input_dir
4
+ attr_accessor :output_dir
5
+ attr_accessor :skip_files
6
+ attr_accessor :project_name
7
+ attr_accessor :verbose
8
+ attr_accessor :template_path
9
+
10
+ def initialize(name = :css_doc)
11
+ @name = name
12
+ @input_dir = 'public/stylesheets'
13
+ @output_dir = 'css_doc'
14
+ @template_path = File.expand_path(File.dirname(__FILE__) + '/../templates/default')
15
+
16
+ yield self if block_given?
17
+ define
18
+ end
19
+
20
+ def define
21
+ task @name do
22
+ require 'css_doc'
23
+
24
+ driver = CSSDoc::Driver.new
25
+ driver.run(:project_name => self.project_name, :input_dir => self.input_dir, :output_dir => self.output_dir, :skip_files => self.skip_files, :verbose => self.verbose, :template_path => self.template_path)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,286 @@
1
+ /**
2
+ * @file css_doc.css
3
+ * @author Thomas Kadauke
4
+ * @css-for Safari 4, Firefox 3
5
+ */
6
+
7
+ /**
8
+ * @section Reset styles
9
+ * These styles reset the default style sheet that comes with the user agent.
10
+ */
11
+
12
+ /**
13
+ * Set margins and paddings to 0, and font-properties to a default value.
14
+ */
15
+ html, body, div, span, applet, object, iframe,
16
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
17
+ a, abbr, acronym, address, big, cite, code,
18
+ del, dfn, em, font, img, ins, kbd, q, s, samp,
19
+ small, strike, strong, sub, sup, tt, var,
20
+ dl, dt, dd, ol, ul, li,
21
+ fieldset, form, label, legend,
22
+ table, caption, tbody, tfoot, thead, tr, th, td {
23
+ margin: 0;
24
+ padding: 0;
25
+ border: 0;
26
+ outline: 0;
27
+ font-weight: inherit;
28
+ font-style: inherit;
29
+ font-size: 100%;
30
+ font-family: inherit;
31
+ vertical-align: baseline;
32
+ }
33
+ /**
34
+ * Reset focus styles to nothing.
35
+ * Remember to define focus styles in after this declaration.
36
+ */
37
+ :focus {
38
+ outline: 0;
39
+ }
40
+ /**
41
+ * Reset text color and line height.
42
+ */
43
+ body {
44
+ line-height: 1;
45
+ color: black;
46
+ background: white;
47
+ }
48
+ /**
49
+ * Remove default list decoration.
50
+ */
51
+ ol, ul {
52
+ list-style: none;
53
+ }
54
+ /*
55
+ * Remove default table styling.
56
+ * Tables still need 'cellspacing="0"' in the markup.
57
+ */
58
+ table {
59
+ border-collapse: separate;
60
+ border-spacing: 0;
61
+ }
62
+ /**
63
+ * Reset text alignment and typography for special tags.
64
+ */
65
+ caption, th, td {
66
+ text-align: left;
67
+ font-weight: normal;
68
+ }
69
+ /**
70
+ * Remove CSS generated content around citation tags.
71
+ */
72
+ blockquote:before, blockquote:after,
73
+ q:before, q:after {
74
+ content: "";
75
+ }
76
+ blockquote, q {
77
+ quotes: "" "";
78
+ }
79
+
80
+ /**
81
+ * @section Typography
82
+ */
83
+
84
+ /**
85
+ * A font size of 100.01% on the html tag makes it possible to easily convert
86
+ * em's to pixels with default font size settings in all major browsers.
87
+ */
88
+ html {
89
+ font-size: 100.01%;
90
+ }
91
+
92
+ /**
93
+ * Reset font size so that 1 em is 10 pixels.
94
+ */
95
+ body {
96
+ font-size: 62.5%;
97
+ font-family: Arial, Verdana, Tahoma, 'Bitstream Vera Sans', sans serif;
98
+ }
99
+
100
+ /**
101
+ * Set font size and spacing.
102
+ */
103
+ #canvas {
104
+ font-size: 1.2em;
105
+ line-height: 1.3;
106
+ }
107
+
108
+ p {
109
+ margin-bottom: 0.5em;
110
+ }
111
+
112
+ /**
113
+ * Use typewriter font for code examples.
114
+ */
115
+ pre {
116
+ font-family: Courier;
117
+ width: 100%;
118
+ overflow: auto;
119
+ }
120
+
121
+ /**
122
+ * @section Headers
123
+ */
124
+
125
+ /**
126
+ * All headers use the same font, same margins, but different font sizes.
127
+ */
128
+ h1, h2, h3, h4, h5, h6 { font-family: 'Arial', sans serif; font-weight: normal; line-height: 1; margin: 0 0 .5em 0; padding: 0; }
129
+ h1 { font-size: 1.9em; }
130
+ h2 { font-size: 1.8333333em; }
131
+ h3 { font-size: 1.6em; }
132
+ h4 { font-size: 1.4em; }
133
+ h5 { font-size: 1em; }
134
+ h6 { font-size: 1em; }
135
+
136
+ /**
137
+ * @section Layout
138
+ */
139
+
140
+ body {
141
+ padding: 1em;
142
+ }
143
+
144
+ .content {
145
+ margin-left: 15em;
146
+ }
147
+
148
+ /**
149
+ * Push navigation to the left-hand side.
150
+ */
151
+ .navigation {
152
+ float: left;
153
+ width: 9em;
154
+ }
155
+
156
+ /**
157
+ * @section Lists
158
+ */
159
+
160
+ dl {
161
+ margin-bottom: 0.5em;
162
+ }
163
+
164
+ dt {
165
+ font-weight: bold;
166
+ }
167
+
168
+ /**
169
+ * Use nice indentation to make definition items more distinguishable from the
170
+ * terms.
171
+ */
172
+ dd {
173
+ padding-left: 2em;
174
+ }
175
+
176
+ /**
177
+ * @section Indexes
178
+ */
179
+
180
+ /**
181
+ * Index list items should be next to each other.
182
+ */
183
+ dl.index ul li {
184
+ display: inline;
185
+ }
186
+
187
+ /**
188
+ * Separate index list items by commas via CSS.
189
+ */
190
+ dl.index ul li:after {
191
+ content: ', ';
192
+ }
193
+
194
+ /**
195
+ * No comma for the last index list item.
196
+ */
197
+ dl.index ul li:last-child:after {
198
+ content: '';
199
+ }
200
+
201
+ /**
202
+ * Actually use bullets for the file index.
203
+ */
204
+ ul.file-index {
205
+ list-style-type: disc;
206
+ }
207
+
208
+ ul.file-index li {
209
+ margin-left: 3em;
210
+ }
211
+
212
+ /**
213
+ * @section Document page
214
+ */
215
+
216
+ ul.rule-sets, ul.sections {
217
+ margin-bottom: 0.5em;
218
+ }
219
+
220
+ /**
221
+ * Like index lists, the table of contents lists on the document page should be
222
+ * inlined.
223
+ */
224
+ ul.sections li, ul.rule-sets li {
225
+ display: inline;
226
+ }
227
+
228
+ /**
229
+ * Again, use CSS-generated commas to separate the items.
230
+ */
231
+ ul.sections li:after, ul.rule-sets li:after {
232
+ content: ', ';
233
+ }
234
+
235
+ /**
236
+ * No comma for the last one.
237
+ */
238
+ ul.sections li:last-child:after, ul.rule-sets li:last-child:after {
239
+ content: '';
240
+ }
241
+
242
+ /**
243
+ * Give section headers a visual emphasis.
244
+ */
245
+ h3.section {
246
+ border-top: 1px solid #000;
247
+ border-bottom: 1px solid #000;
248
+ margin-top: 1em;
249
+ margin-bottom: 1em;
250
+ }
251
+
252
+ /**
253
+ * Examples are surrounded by a thick border. Also there is a rather large
254
+ * padding to make it clear where the example starts. This selector is the
255
+ * namespace for generated CSS, which is used to style the example in the box.
256
+ */
257
+ div.example {
258
+ margin: 1em 0 1em 2em;
259
+ border: 2px solid #000;
260
+ padding: 1em;
261
+ }
262
+
263
+ /**
264
+ * @section Table of contents
265
+ */
266
+
267
+ ul.navigation li {
268
+ border-top: 1px solid #000;
269
+ padding: 0.25em;
270
+ }
271
+
272
+ ul.navigation li:last-child {
273
+ border-bottom: 1px solid #000;
274
+ }
275
+
276
+ /**
277
+ * @section Footer
278
+ */
279
+
280
+ /**
281
+ * Center footer line.
282
+ */
283
+ #footer {
284
+ margin-top: 2em;
285
+ text-align: center;
286
+ }
@@ -0,0 +1,93 @@
1
+ <h1>Document <%= @document.name %></h1>
2
+ <% if @document.documentation %>
3
+ <dl>
4
+ <% if @document.documentation.author %>
5
+ <dt>Author</dt>
6
+ <dd><%= @document.documentation.author %></dd>
7
+ <% end %>
8
+ <% if @document.documentation.appdef %>
9
+ <dt>Application</dt>
10
+ <dd><%= @document.documentation.appdef %></dd>
11
+ <% end %>
12
+ <% if @document.documentation.link %>
13
+ <dt>URL</dt>
14
+ <dd><%= @document.documentation.link %></dd>
15
+ <% end %>
16
+ <% if @document.documentation.copyright %>
17
+ <dt>Copyright</dt>
18
+ <dd><%= @document.documentation.copyright %></dd>
19
+ <% end %>
20
+ <% if @document.documentation.css_for %>
21
+ <dt>Compatible browsers</dt>
22
+ <dd><%= @document.documentation.css_for %></dd>
23
+ <% end %>
24
+ <% if @document.documentation.author %>
25
+ <dt>Version</dt>
26
+ <dd><%= @document.documentation.author %></dd>
27
+ <% end %>
28
+ <% if @document.documentation.date %>
29
+ <dt>Date</dt>
30
+ <dd><%= @document.documentation.date %></dd>
31
+ <% end %>
32
+ <% if @document.documentation.license %>
33
+ <dt>License</dt>
34
+ <dd><%= @document.documentation.license %></dd>
35
+ <% end %>
36
+ </dl>
37
+
38
+ <%= @document.documentation.sections.to_html %>
39
+ <% end %>
40
+
41
+ <h2>Contents</h2>
42
+
43
+ <% unless @document.named_sections.empty? %>
44
+ <h3>Sections</h3>
45
+
46
+ <ul class="sections">
47
+ <% @document.named_sections.sort_by {|section| section.name}.each do |section| %>
48
+ <li><a href="#section-<%= section.object_id %>"><%= section.name %></a></li>
49
+ <% end %>
50
+ </ul>
51
+ <% end %>
52
+
53
+ <h3>Rule sets</h3>
54
+
55
+ <ul class="rule-sets">
56
+ <% @document.rule_sets.sort_by {|set| set.selector_css}.each do |rule_set| %>
57
+ <li><a href="#rule-set-<%= rule_set.object_id %>" title="<%= rule_set.selector_css %>"><%= truncate(rule_set.selector_css, 40) %></a></li>
58
+ <% end %>
59
+ </ul>
60
+
61
+ <h2>Documentation</h2>
62
+
63
+ <% @document.sections.each do |section| %>
64
+ <% if section.name %>
65
+ <h3 class="section" id="section-<%= section.object_id %>"><%= section.name %></h3>
66
+ <% end %>
67
+
68
+ <%= section.documentation.sections.to_html %>
69
+
70
+ <% section.rule_sets.each do |rule_set| %>
71
+ <h4 class="rule-set" id="rule-set-<%= rule_set.object_id %>">Rule set <%= rule_set.documentation.name || "(unnamed)" %></h4>
72
+
73
+ <dl>
74
+ <dt>Selectors</dt>
75
+ <dd><%= rule_set.selector_css %></dd>
76
+
77
+ <dt>Properties</dt>
78
+ <dd><%= rule_set.declaration_css %></dd>
79
+
80
+ <% if rule_set.documentation.formerly %>
81
+ <dt>Formerly</dt>
82
+ <dd><%= rule_set.documentation.formerly %></dd>
83
+ <% end %>
84
+
85
+ <% if rule_set.documentation.deprecated %>
86
+ <dt>Deprecated</dt>
87
+ <dd><%= rule_set.documentation.deprecated %></dd>
88
+ <% end %>
89
+ </dl>
90
+
91
+ <%= rule_set.documentation.sections.to_html %>
92
+ <% end %>
93
+ <% end %>