imedo-css_doc 0.0.2 → 0.0.3

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.
data/bin/cssdoc CHANGED
@@ -8,7 +8,8 @@ class CSSDocCli
8
8
  options = {
9
9
  :input_dir => '.',
10
10
  :skip_files => [],
11
- :output_dir => 'doc'
11
+ :output_dir => 'doc',
12
+ :template_path => File.expand_path(File.dirname(__FILE__) + "/../src/templates/default")
12
13
  }
13
14
  OptionParser.new do |opts|
14
15
  opts.banner = "Usage: cssdoc [options] [input-dir/input-files]"
@@ -24,6 +25,13 @@ class CSSDocCli
24
25
  opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
25
26
  options[:verbose] = v
26
27
  end
28
+ opts.on("-t", "--template=name/path", "Specify template or template path") do |name|
29
+ if File.directory?(name)
30
+ options[:template_path] = name
31
+ else
32
+ options[:template_path] = File.expand_path(File.dirname(__FILE__) + "/../src/templates/#{name}")
33
+ end
34
+ end
27
35
  end.parse!
28
36
  options[:input_dir] = ARGV.first if ARGV.first
29
37
 
@@ -1,6 +1,7 @@
1
1
  module CSSDoc
2
2
  class DocumentTemplate < Template
3
- def initialize(document)
3
+ def initialize(document, options = {})
4
+ super(options)
4
5
  @document = document
5
6
  end
6
7
 
@@ -23,7 +23,7 @@ module CSSDoc
23
23
  FileUtils.mkdir_p("#{@options[:output_dir]}/#{File.dirname(relative_path)}")
24
24
  doc = CSSDoc::Document.parse(File.read(file_name), relative_path)
25
25
 
26
- html = CSSDoc::DocumentTemplate.new(doc).render
26
+ html = CSSDoc::DocumentTemplate.new(doc, @options).render
27
27
  File.open("#{@options[:output_dir]}/#{doc.output_file_name}", 'w') { |file| file.puts html }
28
28
 
29
29
  @collection.documents << doc
@@ -33,17 +33,17 @@ module CSSDoc
33
33
  def generate_index_documentation
34
34
  log "Generating Selector Index ..."
35
35
 
36
- html = CSSDoc::SelectorIndexTemplate.new(@collection).render
36
+ html = CSSDoc::SelectorIndexTemplate.new(@collection, @options).render
37
37
  File.open("#{@options[:output_dir]}/selector_index.html", 'w') { |file| file.puts html }
38
38
 
39
39
  log "Generating File Index ..."
40
40
 
41
- html = CSSDoc::FileIndexTemplate.new(@collection).render
41
+ html = CSSDoc::FileIndexTemplate.new(@collection, @options).render
42
42
  File.open("#{@options[:output_dir]}/file_index.html", 'w') { |file| file.puts html }
43
43
 
44
44
  log "Generating Section Index ..."
45
45
 
46
- html = CSSDoc::SectionIndexTemplate.new(@collection).render
46
+ html = CSSDoc::SectionIndexTemplate.new(@collection, @options).render
47
47
  File.open("#{@options[:output_dir]}/section_index.html", 'w') { |file| file.puts html }
48
48
 
49
49
  log "Generating Index Page ..."
@@ -62,7 +62,7 @@ module CSSDoc
62
62
  def copy_additional_files
63
63
  log "Copying Additional Files ..."
64
64
 
65
- FileUtils.cp(File.dirname(__FILE__) + '/../templates/default/css_doc.css', "#{@options[:output_dir]}/")
65
+ FileUtils.cp("#{@options[:template_path]}/css_doc.css", "#{@options[:output_dir]}/")
66
66
  end
67
67
 
68
68
  def log(string)
@@ -1,6 +1,7 @@
1
1
  module CSSDoc
2
2
  class FileIndexTemplate < Template
3
- def initialize(collection)
3
+ def initialize(collection, options = {})
4
+ super(options)
4
5
  @collection = collection
5
6
  end
6
7
 
@@ -1,6 +1,7 @@
1
1
  module CSSDoc
2
2
  class IndexTemplate < Template
3
3
  def initialize(options)
4
+ super
4
5
  @project_name = options[:project_name]
5
6
  end
6
7
 
@@ -1,6 +1,7 @@
1
1
  module CSSDoc
2
2
  class SectionIndexTemplate < Template
3
- def initialize(collection)
3
+ def initialize(collection, options = {})
4
+ super(options)
4
5
  @collection = collection
5
6
  end
6
7
 
@@ -1,6 +1,7 @@
1
1
  module CSSDoc
2
2
  class SelectorIndexTemplate < Template
3
- def initialize(collection)
3
+ def initialize(collection, options = {})
4
+ super(options)
4
5
  @collection = collection
5
6
  end
6
7
 
@@ -2,9 +2,10 @@ require 'erb'
2
2
 
3
3
  module CSSDoc
4
4
  class Template
5
- @@template_path = File.dirname(__FILE__) + '/../templates/default'
5
+ @@default_template_path = File.dirname(__FILE__) + '/../templates/default'
6
6
 
7
- def initialize
7
+ def initialize(options = {})
8
+ @options = options
8
9
  end
9
10
 
10
11
  def render
@@ -16,12 +17,16 @@ module CSSDoc
16
17
 
17
18
  end
18
19
 
20
+ def template_path
21
+ @options[:template_path] || @@default_template_path
22
+ end
23
+
19
24
  def template
20
- File.read("#{@@template_path}/#{template_name}.html.erb")
25
+ File.read("#{template_path}/#{template_name}.html.erb")
21
26
  end
22
27
 
23
28
  def layout
24
- File.read("#{@@template_path}/layout.html.erb")
29
+ File.read("#{template_path}/layout.html.erb")
25
30
  end
26
31
 
27
32
  def relative_root
@@ -10,6 +10,7 @@ module Rake
10
10
  @name = name
11
11
  @input_dir = 'public/stylesheets'
12
12
  @output_dir = 'css_doc'
13
+ @template_path = File.expand_path(File.dirname(__FILE__) + '/../templates/default')
13
14
 
14
15
  yield self if block_given?
15
16
  define
@@ -1,5 +1,8 @@
1
- <html>
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
2
4
  <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
3
6
  <title><%= title %> - CSS Documentation</title>
4
7
  <link rel="stylesheet" media="all" href="<%= relative_root %>/css_doc.css" />
5
8
  <link rel="stylesheet" media="all" href="<%= relative_root %>/styles.css" />
@@ -0,0 +1,282 @@
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
+ /**
145
+ * Navigation is on the top, and items are inlined.
146
+ */
147
+ .navigation {
148
+ text-align: center;
149
+ margin-bottom: 1em;
150
+ }
151
+
152
+ .navigation li {
153
+ display: inline;
154
+ }
155
+
156
+ .navigation li a {
157
+ border-right: 1px solid #000;
158
+ padding: 0 1em;
159
+ }
160
+
161
+ .navigation li:last-child a {
162
+ border: none;
163
+ }
164
+
165
+ /**
166
+ * @section Lists
167
+ */
168
+
169
+ dl {
170
+ margin-bottom: 0.5em;
171
+ }
172
+
173
+ dt {
174
+ font-weight: bold;
175
+ }
176
+
177
+ /**
178
+ * Use nice indentation to make definition items more distinguishable from the
179
+ * terms.
180
+ */
181
+ dd {
182
+ padding-left: 2em;
183
+ }
184
+
185
+ /**
186
+ * @section Indexes
187
+ */
188
+
189
+ /**
190
+ * Index list items should be next to each other.
191
+ */
192
+ dl.index ul li {
193
+ display: inline;
194
+ }
195
+
196
+ /**
197
+ * Separate index list items by commas via CSS.
198
+ */
199
+ dl.index ul li:after {
200
+ content: ', ';
201
+ }
202
+
203
+ /**
204
+ * No comma for the last index list item.
205
+ */
206
+ dl.index ul li:last-child:after {
207
+ content: '';
208
+ }
209
+
210
+ /**
211
+ * Actually use bullets for the file index.
212
+ */
213
+ ul.file-index {
214
+ list-style-type: disc;
215
+ }
216
+
217
+ ul.file-index li {
218
+ margin-left: 3em;
219
+ }
220
+
221
+ /**
222
+ * @section Document page
223
+ */
224
+
225
+ ul.rule-sets, ul.sections {
226
+ margin-bottom: 0.5em;
227
+ }
228
+
229
+ /**
230
+ * Like index lists, the table of contents lists on the document page should be
231
+ * inlined.
232
+ */
233
+ ul.sections li, ul.rule-sets li {
234
+ display: inline;
235
+ }
236
+
237
+ /**
238
+ * Again, use CSS-generated commas to separate the items.
239
+ */
240
+ ul.sections li:after, ul.rule-sets li:after {
241
+ content: ', ';
242
+ }
243
+
244
+ /**
245
+ * No comma for the last one.
246
+ */
247
+ ul.sections li:last-child:after, ul.rule-sets li:last-child:after {
248
+ content: '';
249
+ }
250
+
251
+ /**
252
+ * Give section headers a visual emphasis.
253
+ */
254
+ h2.section {
255
+ border-top: 1px solid #000;
256
+ border-bottom: 1px solid #000;
257
+ margin-top: 1em;
258
+ margin-bottom: 1em;
259
+ }
260
+
261
+ /**
262
+ * Examples are surrounded by a thick border. Also there is a rather large
263
+ * padding to make it clear where the example starts. This selector is the
264
+ * namespace for generated CSS, which is used to style the example in the box.
265
+ */
266
+ div.example {
267
+ margin: 1em 0 1em 2em;
268
+ border: 2px solid #000;
269
+ padding: 1em;
270
+ }
271
+
272
+ /**
273
+ * @section Footer
274
+ */
275
+
276
+ /**
277
+ * Center footer line.
278
+ */
279
+ #footer {
280
+ margin-top: 2em;
281
+ text-align: center;
282
+ }
@@ -0,0 +1,58 @@
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
+ </dl>
29
+
30
+ <%= @document.documentation.sections.to_html %>
31
+ <% end %>
32
+
33
+ <% @document.sections.each do |section| %>
34
+ <% if section.name %>
35
+ <h2 class="section" id="section-<%= section.object_id %>"><%= section.name %></h2>
36
+ <% end %>
37
+
38
+ <%= section.documentation.sections.to_html %>
39
+
40
+ <dl>
41
+ <% section.rule_sets.each do |rule_set| %>
42
+ <dt class="rule-set" id="rule-set-<%= rule_set.object_id %>">Rule set <%= rule_set.documentation.name || "(unnamed)" %></dt>
43
+ <dd>
44
+ <p><%= rule_set.selector_css %> <%= rule_set.declaration_css %></p>
45
+
46
+ <% if rule_set.documentation.formerly %>
47
+ <p>Formerly: <%= rule_set.documentation.formerly %></p>
48
+ <% end %>
49
+
50
+ <% if rule_set.documentation.deprecated %>
51
+ <p>Deprecated: <%= rule_set.documentation.deprecated %></p>
52
+ <% end %>
53
+
54
+ <%= rule_set.documentation.sections.to_html %>
55
+ </dd>
56
+ <% end %>
57
+ </dl>
58
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <h1>File Index</h1>
2
+
3
+ <ul class="file-index">
4
+ <% @collection.documents.sort_by {|doc| doc.name}.each do |document| %>
5
+ <li><a href="<%= document.output_file_name %>"><%= document.name %></a></li>
6
+ <% end %>
7
+ </ul>
@@ -0,0 +1,3 @@
1
+ <h1><%= @project_name || 'CSS Documentation' %></h1>
2
+
3
+ <p>Use the navigation to find documentation for this project</p>
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
+ <title><%= title %> - CSS Documentation</title>
7
+ <link rel="stylesheet" media="all" href="<%= relative_root %>/css_doc.css" />
8
+ <link rel="stylesheet" media="all" href="<%= relative_root %>/styles.css" />
9
+ </head>
10
+ <body>
11
+ <div id="canvas">
12
+ <ul class="navigation">
13
+ <li><a href="<%= relative_root %>/index.html">Home</a></li>
14
+ <li><a href="<%= relative_root %>/file_index.html">File Index</a></li>
15
+ <li><a href="<%= relative_root %>/selector_index.html">Selector Index</a></li>
16
+ <li><a href="<%= relative_root %>/section_index.html">Section Index</a></li>
17
+ </ul>
18
+
19
+ <div class="content">
20
+ <%= content %>
21
+ </div>
22
+
23
+ <p id="footer">
24
+ Generated by css_doc. css_doc is Copyright (2009) Thomas Kadauke, imedo.de, das <a href="http://www.imedo.de">Gesundheitsportal</a>.
25
+ </p>
26
+ </div>
27
+ </body>
28
+ </html>
29
+
@@ -0,0 +1,14 @@
1
+ <h1>Section Index</h1>
2
+
3
+ <dl class="index">
4
+ <% @collection.section_hash.sort.each do |name, sections| %>
5
+ <dt><%= name %></dt>
6
+ <dd>
7
+ <ul>
8
+ <% sections.each do |section| %>
9
+ <li><a href="<%= section.document.output_file_name %>#section-<%= section.object_id %>"><%= section.document.name %></a></li>
10
+ <% end %>
11
+ </ul>
12
+ </dd>
13
+ <% end %>
14
+ </dt>
@@ -0,0 +1,14 @@
1
+ <h1>Selector Index</h1>
2
+
3
+ <dl class="index">
4
+ <% @collection.selector_hash.sort.each do |name, selectors| %>
5
+ <dt><%= name %></dt>
6
+ <dd>
7
+ <ul>
8
+ <% selectors.each do |selector| %>
9
+ <li><a href="<%= selector.rule_set.document.output_file_name %>#rule-set-<%= selector.rule_set.object_id %>"><%= selector.rule_set.document.name %></a></li>
10
+ <% end %>
11
+ </ul>
12
+ </dd>
13
+ <% end %>
14
+ </dt>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imedo-css_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Kadauke
@@ -49,6 +49,13 @@ files:
49
49
  - src/templates/default/layout.html.erb
50
50
  - src/templates/default/section_index.html.erb
51
51
  - src/templates/default/selector_index.html.erb
52
+ - src/templates/simple/css_doc.css
53
+ - src/templates/simple/document.html.erb
54
+ - src/templates/simple/file_index.html.erb
55
+ - src/templates/simple/index.html.erb
56
+ - src/templates/simple/layout.html.erb
57
+ - src/templates/simple/section_index.html.erb
58
+ - src/templates/simple/selector_index.html.erb
52
59
  has_rdoc: false
53
60
  homepage: http://www.imedo.de
54
61
  post_install_message: