imedo-css_doc 0.0.2
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 +35 -0
- data/src/css_doc/css_writer.rb +20 -0
- data/src/css_doc/document.rb +31 -0
- data/src/css_doc/document_collection.rb +33 -0
- data/src/css_doc/document_documentation.rb +19 -0
- data/src/css_doc/document_handler.rb +36 -0
- data/src/css_doc/document_template.rb +23 -0
- data/src/css_doc/documentation.rb +81 -0
- data/src/css_doc/driver.rb +72 -0
- data/src/css_doc/file_index_template.rb +15 -0
- data/src/css_doc/index_template.rb +15 -0
- data/src/css_doc/rule_set.rb +14 -0
- data/src/css_doc/rule_set_documentation.rb +32 -0
- data/src/css_doc/section.rb +17 -0
- data/src/css_doc/section_documentation.rb +19 -0
- data/src/css_doc/section_index_template.rb +15 -0
- data/src/css_doc/selector_index_template.rb +15 -0
- data/src/css_doc/template.rb +39 -0
- data/src/css_doc.rb +20 -0
- data/src/css_pool/visitors/to_css.rb +9 -0
- data/src/rake/css_doc_task.rb +27 -0
- data/src/templates/default/css_doc.css +286 -0
- data/src/templates/default/document.html.erb +85 -0
- data/src/templates/default/file_index.html.erb +7 -0
- data/src/templates/default/index.html.erb +3 -0
- data/src/templates/default/layout.html.erb +26 -0
- data/src/templates/default/section_index.html.erb +14 -0
- data/src/templates/default/selector_index.html.erb +14 -0
- metadata +79 -0
data/bin/cssdoc
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'css_doc'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
class CSSDocCli
|
7
|
+
def self.run(args)
|
8
|
+
options = {
|
9
|
+
:input_dir => '.',
|
10
|
+
:skip_files => [],
|
11
|
+
:output_dir => 'doc'
|
12
|
+
}
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: cssdoc [options] [input-dir/input-files]"
|
15
|
+
opts.on("-o", "--output=dir", "Specify output directory") do |dir|
|
16
|
+
options[:output_dir] = dir
|
17
|
+
end
|
18
|
+
opts.on("-s", "--skip=files", "Skip specified files") do |files|
|
19
|
+
options[:skip_files] = files.split(',').collect { |file| file.strip }
|
20
|
+
end
|
21
|
+
opts.on("-p", "--project-name=name", "Specify Project name") do |name|
|
22
|
+
options[:project_name] = name
|
23
|
+
end
|
24
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
25
|
+
options[:verbose] = v
|
26
|
+
end
|
27
|
+
end.parse!
|
28
|
+
options[:input_dir] = ARGV.first if ARGV.first
|
29
|
+
|
30
|
+
driver = CSSDoc::Driver.new
|
31
|
+
driver.run(options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
CSSDocCli.run(ARGV)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class CSSWriter
|
3
|
+
def initialize(collection)
|
4
|
+
@collection = collection
|
5
|
+
end
|
6
|
+
|
7
|
+
def write
|
8
|
+
output = ""
|
9
|
+
@collection.rule_sets.each do |rule_set|
|
10
|
+
selectors = rule_set.selectors.collect { |selector| 'div.example ' + selector.to_css }
|
11
|
+
output << selectors.join(', ')
|
12
|
+
output << '{'
|
13
|
+
output << rule_set.declaration_css
|
14
|
+
output << '}'
|
15
|
+
output << "\n"
|
16
|
+
end
|
17
|
+
output
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class Document < CSSPool::CSS::Document
|
3
|
+
attr_accessor :documentation
|
4
|
+
attr_accessor :sections
|
5
|
+
attr_accessor :name
|
6
|
+
|
7
|
+
def self.parse string, name
|
8
|
+
unless string && string.length > 0
|
9
|
+
return CSSDoc::Document.new(name)
|
10
|
+
end
|
11
|
+
handler = CSSDoc::DocumentHandler.new(name)
|
12
|
+
parser = CSSPool::SAC::Parser.new(handler)
|
13
|
+
parser.parse(string)
|
14
|
+
handler.document
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(name)
|
18
|
+
super()
|
19
|
+
@name = name
|
20
|
+
@sections = [Section.new(self, '')]
|
21
|
+
end
|
22
|
+
|
23
|
+
def output_file_name
|
24
|
+
name.gsub('.css', '_css.html')
|
25
|
+
end
|
26
|
+
|
27
|
+
def named_sections
|
28
|
+
sections.reject {|section| section.name.nil?}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class DocumentCollection < CSSPool::CSS::Document
|
3
|
+
attr_accessor :documents
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@documents = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def rule_sets
|
10
|
+
documents.collect { |document| document.rule_sets }.flatten
|
11
|
+
end
|
12
|
+
|
13
|
+
def selectors
|
14
|
+
rule_sets.collect { |rule_set| rule_set.selectors }.flatten
|
15
|
+
end
|
16
|
+
|
17
|
+
def sections
|
18
|
+
documents.collect { |document| document.sections }.flatten
|
19
|
+
end
|
20
|
+
|
21
|
+
def named_sections
|
22
|
+
sections.reject { |section| section.name.nil? }
|
23
|
+
end
|
24
|
+
|
25
|
+
def selector_hash
|
26
|
+
selectors.inject({}) { |hash, selector| (hash[selector.to_css] ||= []) << selector; hash }
|
27
|
+
end
|
28
|
+
|
29
|
+
def section_hash
|
30
|
+
named_sections.inject({}) { |hash, section| (hash[section.name] ||= []) << section; hash }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class DocumentDocumentation < Documentation
|
3
|
+
attr_accessor :file, :note, :appdef, :link, :copyright, :author, :css_for, :version
|
4
|
+
|
5
|
+
def parse(lines)
|
6
|
+
section_text = []
|
7
|
+
lines.each do |line|
|
8
|
+
unless parse_one_liners(line)
|
9
|
+
section_text << line
|
10
|
+
end
|
11
|
+
end
|
12
|
+
sections << TextSection.new(section_text)
|
13
|
+
end
|
14
|
+
|
15
|
+
def one_liners
|
16
|
+
['file', 'note', 'appdef', 'link', 'copyright', 'author', 'css-for', 'version']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class DocumentHandler < CSSPool::CSS::DocumentHandler
|
3
|
+
def initialize(name)
|
4
|
+
super()
|
5
|
+
@name = name
|
6
|
+
end
|
7
|
+
|
8
|
+
def start_document
|
9
|
+
@document = CSSDoc::Document.new(@name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def comment(comment)
|
13
|
+
if comment =~ /@file/
|
14
|
+
@document.documentation = DocumentDocumentation.new(comment)
|
15
|
+
elsif comment =~ /@section/
|
16
|
+
@document.sections << Section.new(@document, comment)
|
17
|
+
else
|
18
|
+
@last_comment = comment
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def start_selector(selector_list)
|
23
|
+
rule_set = CSSDoc::RuleSet.new(
|
24
|
+
selector_list,
|
25
|
+
[],
|
26
|
+
@media_stack.last || []
|
27
|
+
)
|
28
|
+
rule_set.document = @document
|
29
|
+
rule_set.documentation = RuleSetDocumentation.new(@last_comment =~ /^\*/ ? @last_comment : "")
|
30
|
+
@last_comment = nil
|
31
|
+
|
32
|
+
@document.rule_sets << rule_set
|
33
|
+
@document.sections.last.rule_sets << rule_set
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class DocumentTemplate < Template
|
3
|
+
def initialize(document)
|
4
|
+
@document = document
|
5
|
+
end
|
6
|
+
|
7
|
+
def template_name
|
8
|
+
'document'
|
9
|
+
end
|
10
|
+
|
11
|
+
def title
|
12
|
+
@document.name
|
13
|
+
end
|
14
|
+
|
15
|
+
def relative_root
|
16
|
+
if @document.name =~ /\//
|
17
|
+
(['..'] * File.dirname(@document.name).split('/').size).join('/')
|
18
|
+
else
|
19
|
+
'.'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class Documentation
|
3
|
+
class Section
|
4
|
+
attr_accessor :lines
|
5
|
+
def initialize(lines)
|
6
|
+
self.lines = lines
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
lines.join("\n")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class TextSection < Section
|
15
|
+
def to_html
|
16
|
+
result = "<p>"
|
17
|
+
result << lines.collect {|l|l.strip}.join("\n").gsub(/\n\n+/, '</p><p>').gsub(/\n/, ' ').strip
|
18
|
+
result << "</p>"
|
19
|
+
result.gsub('<p></p>', '')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class CodeSection < Section
|
24
|
+
def to_html
|
25
|
+
result = "<pre>" + lines.join("\n").gsub("<", "<").gsub(">", ">").gsub('"', '"') + "</pre>"
|
26
|
+
result << %{<div class="example">#{lines.join("\n")}</div>}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Sections < Array
|
31
|
+
def to_html
|
32
|
+
collect {|section| section.to_html}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
attr_accessor :comment
|
37
|
+
attr_accessor :sections
|
38
|
+
|
39
|
+
def initialize(comment)
|
40
|
+
@comment = comment
|
41
|
+
@sections = Sections.new
|
42
|
+
parse_documentation
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
@comment
|
47
|
+
end
|
48
|
+
|
49
|
+
def parse_one_liners(line)
|
50
|
+
one_liners.each do |one_liner|
|
51
|
+
rx = /@#{one_liner}/
|
52
|
+
if line =~ rx
|
53
|
+
instance_variable_set(:"@#{one_liner.gsub('-', '_')}", line.gsub(rx, "").strip)
|
54
|
+
return true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
return false
|
58
|
+
end
|
59
|
+
|
60
|
+
def one_liners
|
61
|
+
[]
|
62
|
+
end
|
63
|
+
|
64
|
+
def parse_comment
|
65
|
+
@parsed_comment ||= comment.gsub(/\*\/$/, '').split("\n").collect { |line| line.gsub(/^\s*\*/, '') }
|
66
|
+
end
|
67
|
+
|
68
|
+
def parse_documentation
|
69
|
+
lines = parse_comment
|
70
|
+
parse(lines)
|
71
|
+
end
|
72
|
+
|
73
|
+
def empty?
|
74
|
+
parse_comment.join("\n").strip.empty?
|
75
|
+
end
|
76
|
+
|
77
|
+
def parse(lines)
|
78
|
+
raise NotImplementedError
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class Driver
|
3
|
+
def run(options = {})
|
4
|
+
@options = options
|
5
|
+
|
6
|
+
@collection = CSSDoc::DocumentCollection.new
|
7
|
+
|
8
|
+
generate_file_documentation
|
9
|
+
generate_index_documentation
|
10
|
+
generate_css
|
11
|
+
copy_additional_files
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_file_documentation
|
15
|
+
skip_files = @options[:skip_files] || []
|
16
|
+
|
17
|
+
Dir.glob("#{@options[:input_dir]}/**/*.css").each do |file_name|
|
18
|
+
relative_path = file_name.gsub("#{@options[:input_dir]}/", '')
|
19
|
+
next if skip_files.include?(relative_path)
|
20
|
+
|
21
|
+
log "Generating documentation for file #{relative_path} ..."
|
22
|
+
|
23
|
+
FileUtils.mkdir_p("#{@options[:output_dir]}/#{File.dirname(relative_path)}")
|
24
|
+
doc = CSSDoc::Document.parse(File.read(file_name), relative_path)
|
25
|
+
|
26
|
+
html = CSSDoc::DocumentTemplate.new(doc).render
|
27
|
+
File.open("#{@options[:output_dir]}/#{doc.output_file_name}", 'w') { |file| file.puts html }
|
28
|
+
|
29
|
+
@collection.documents << doc
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def generate_index_documentation
|
34
|
+
log "Generating Selector Index ..."
|
35
|
+
|
36
|
+
html = CSSDoc::SelectorIndexTemplate.new(@collection).render
|
37
|
+
File.open("#{@options[:output_dir]}/selector_index.html", 'w') { |file| file.puts html }
|
38
|
+
|
39
|
+
log "Generating File Index ..."
|
40
|
+
|
41
|
+
html = CSSDoc::FileIndexTemplate.new(@collection).render
|
42
|
+
File.open("#{@options[:output_dir]}/file_index.html", 'w') { |file| file.puts html }
|
43
|
+
|
44
|
+
log "Generating Section Index ..."
|
45
|
+
|
46
|
+
html = CSSDoc::SectionIndexTemplate.new(@collection).render
|
47
|
+
File.open("#{@options[:output_dir]}/section_index.html", 'w') { |file| file.puts html }
|
48
|
+
|
49
|
+
log "Generating Index Page ..."
|
50
|
+
|
51
|
+
html = CSSDoc::IndexTemplate.new(@options).render
|
52
|
+
File.open("#{@options[:output_dir]}/index.html", 'w') { |file| file.puts html }
|
53
|
+
end
|
54
|
+
|
55
|
+
def generate_css
|
56
|
+
log "Generating Example CSS ..."
|
57
|
+
|
58
|
+
writer = CSSDoc::CSSWriter.new(@collection)
|
59
|
+
File.open("#{@options[:output_dir]}/styles.css", 'w') { |file| file.puts writer.write }
|
60
|
+
end
|
61
|
+
|
62
|
+
def copy_additional_files
|
63
|
+
log "Copying Additional Files ..."
|
64
|
+
|
65
|
+
FileUtils.cp(File.dirname(__FILE__) + '/../templates/default/css_doc.css', "#{@options[:output_dir]}/")
|
66
|
+
end
|
67
|
+
|
68
|
+
def log(string)
|
69
|
+
puts string if @options[:verbose]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class RuleSet < CSSPool::CSS::RuleSet
|
3
|
+
attr_accessor :document
|
4
|
+
attr_accessor :documentation
|
5
|
+
|
6
|
+
def selector_css
|
7
|
+
@selector_css ||= selectors.collect { |selector| selector.to_css }.join(", ")
|
8
|
+
end
|
9
|
+
|
10
|
+
def declaration_css
|
11
|
+
@declaration_css ||= declarations.collect { |declaration| declaration.to_css }.join(' ')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class RuleSetDocumentation < Documentation
|
3
|
+
attr_accessor :name, :formerly, :deprecated
|
4
|
+
|
5
|
+
def parse(lines)
|
6
|
+
section_type = TextSection
|
7
|
+
section_text = []
|
8
|
+
lines.each do |line|
|
9
|
+
unless parse_one_liners(line)
|
10
|
+
if line =~ /@code/
|
11
|
+
sections << section_type.new(section_text)
|
12
|
+
section_text = []
|
13
|
+
section_type = CodeSection
|
14
|
+
elsif line =~ /@endcode/
|
15
|
+
sections << section_type.new(section_text)
|
16
|
+
section_text = []
|
17
|
+
section_type = TextSection
|
18
|
+
elsif line =~ /@description/
|
19
|
+
section_text << line.gsub(/@description/, '')
|
20
|
+
else
|
21
|
+
section_text << line
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
sections << section_type.new(section_text)
|
26
|
+
end
|
27
|
+
|
28
|
+
def one_liners
|
29
|
+
['name', 'formerly', 'deprecated']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class Section
|
3
|
+
attr_accessor :document
|
4
|
+
attr_accessor :rule_sets
|
5
|
+
attr_accessor :documentation
|
6
|
+
|
7
|
+
def initialize(document, comment)
|
8
|
+
@document = document
|
9
|
+
@rule_sets = []
|
10
|
+
@documentation = SectionDocumentation.new(comment)
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
documentation.section
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module CSSDoc
|
2
|
+
class SectionDocumentation < Documentation
|
3
|
+
attr_accessor :section
|
4
|
+
|
5
|
+
def parse(lines)
|
6
|
+
section_text = []
|
7
|
+
lines.each do |line|
|
8
|
+
unless parse_one_liners(line)
|
9
|
+
section_text << line
|
10
|
+
end
|
11
|
+
end
|
12
|
+
sections << TextSection.new(section_text)
|
13
|
+
end
|
14
|
+
|
15
|
+
def one_liners
|
16
|
+
['section']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module CSSDoc
|
4
|
+
class Template
|
5
|
+
@@template_path = File.dirname(__FILE__) + '/../templates/default'
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
end
|
9
|
+
|
10
|
+
def render
|
11
|
+
content = ERB.new(template).result(binding)
|
12
|
+
ERB.new(layout).result(binding)
|
13
|
+
end
|
14
|
+
|
15
|
+
def title
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def template
|
20
|
+
File.read("#{@@template_path}/#{template_name}.html.erb")
|
21
|
+
end
|
22
|
+
|
23
|
+
def layout
|
24
|
+
File.read("#{@@template_path}/layout.html.erb")
|
25
|
+
end
|
26
|
+
|
27
|
+
def relative_root
|
28
|
+
"."
|
29
|
+
end
|
30
|
+
|
31
|
+
def truncate(string, length)
|
32
|
+
if string.size > length
|
33
|
+
string[0..(length - 4)] + '...'
|
34
|
+
else
|
35
|
+
string
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/src/css_doc.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'csspool'
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/css_doc/document'
|
4
|
+
require File.dirname(__FILE__) + '/css_doc/document_handler'
|
5
|
+
require File.dirname(__FILE__) + '/css_doc/document_collection'
|
6
|
+
require File.dirname(__FILE__) + '/css_doc/section'
|
7
|
+
require File.dirname(__FILE__) + '/css_doc/rule_set'
|
8
|
+
require File.dirname(__FILE__) + '/css_doc/template'
|
9
|
+
require File.dirname(__FILE__) + '/css_doc/document_template'
|
10
|
+
require File.dirname(__FILE__) + '/css_doc/selector_index_template'
|
11
|
+
require File.dirname(__FILE__) + '/css_doc/file_index_template'
|
12
|
+
require File.dirname(__FILE__) + '/css_doc/section_index_template'
|
13
|
+
require File.dirname(__FILE__) + '/css_doc/index_template'
|
14
|
+
require File.dirname(__FILE__) + '/css_doc/documentation'
|
15
|
+
require File.dirname(__FILE__) + '/css_doc/document_documentation'
|
16
|
+
require File.dirname(__FILE__) + '/css_doc/rule_set_documentation'
|
17
|
+
require File.dirname(__FILE__) + '/css_doc/section_documentation'
|
18
|
+
require File.dirname(__FILE__) + '/css_doc/css_writer'
|
19
|
+
require File.dirname(__FILE__) + '/css_doc/driver'
|
20
|
+
require File.dirname(__FILE__) + '/css_pool/visitors/to_css'
|
@@ -0,0 +1,27 @@
|
|
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
|
+
|
9
|
+
def initialize(name = :css_doc)
|
10
|
+
@name = name
|
11
|
+
@input_dir = 'public/stylesheets'
|
12
|
+
@output_dir = 'css_doc'
|
13
|
+
|
14
|
+
yield self if block_given?
|
15
|
+
define
|
16
|
+
end
|
17
|
+
|
18
|
+
def define
|
19
|
+
task @name do
|
20
|
+
require 'css_doc'
|
21
|
+
|
22
|
+
driver = CSSDoc::Driver.new
|
23
|
+
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)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
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,85 @@
|
|
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
|
+
<h2>Contents</h2>
|
34
|
+
|
35
|
+
<% unless @document.named_sections.empty? %>
|
36
|
+
<h3>Sections</h3>
|
37
|
+
|
38
|
+
<ul class="sections">
|
39
|
+
<% @document.named_sections.sort_by {|section| section.name}.each do |section| %>
|
40
|
+
<li><a href="#section-<%= section.object_id %>"><%= section.name %></a></li>
|
41
|
+
<% end %>
|
42
|
+
</ul>
|
43
|
+
<% end %>
|
44
|
+
|
45
|
+
<h3>Rule sets</h3>
|
46
|
+
|
47
|
+
<ul class="rule-sets">
|
48
|
+
<% @document.rule_sets.sort_by {|set| set.selector_css}.each do |rule_set| %>
|
49
|
+
<li><a href="#rule-set-<%= rule_set.object_id %>" title="<%= rule_set.selector_css %>"><%= truncate(rule_set.selector_css, 40) %></a></li>
|
50
|
+
<% end %>
|
51
|
+
</ul>
|
52
|
+
|
53
|
+
<h2>Documentation</h2>
|
54
|
+
|
55
|
+
<% @document.sections.each do |section| %>
|
56
|
+
<% if section.name %>
|
57
|
+
<h3 class="section" id="section-<%= section.object_id %>"><%= section.name %></h3>
|
58
|
+
<% end %>
|
59
|
+
|
60
|
+
<%= section.documentation.sections.to_html %>
|
61
|
+
|
62
|
+
<% section.rule_sets.each do |rule_set| %>
|
63
|
+
<h4 class="rule-set" id="rule-set-<%= rule_set.object_id %>">Rule set <%= rule_set.documentation.name || "(unnamed)" %></h4>
|
64
|
+
|
65
|
+
<dl>
|
66
|
+
<dt>Selectors</dt>
|
67
|
+
<dd><%= rule_set.selector_css %></dd>
|
68
|
+
|
69
|
+
<dt>Properties</dt>
|
70
|
+
<dd><%= rule_set.declaration_css %></dd>
|
71
|
+
|
72
|
+
<% if rule_set.documentation.formerly %>
|
73
|
+
<dt>Formerly</dt>
|
74
|
+
<dd><%= rule_set.documentation.formerly %></dd>
|
75
|
+
<% end %>
|
76
|
+
|
77
|
+
<% if rule_set.documentation.deprecated %>
|
78
|
+
<dt>Deprecated</dt>
|
79
|
+
<dd><%= rule_set.documentation.deprecated %></dd>
|
80
|
+
<% end %>
|
81
|
+
</dl>
|
82
|
+
|
83
|
+
<%= rule_set.documentation.sections.to_html %>
|
84
|
+
<% end %>
|
85
|
+
<% end %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title><%= title %> - CSS Documentation</title>
|
4
|
+
<link rel="stylesheet" media="all" href="<%= relative_root %>/css_doc.css" />
|
5
|
+
<link rel="stylesheet" media="all" href="<%= relative_root %>/styles.css" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="canvas">
|
9
|
+
<ul class="navigation">
|
10
|
+
<li><a href="<%= relative_root %>/index.html">Home</a></li>
|
11
|
+
<li><a href="<%= relative_root %>/file_index.html">File Index</a></li>
|
12
|
+
<li><a href="<%= relative_root %>/selector_index.html">Selector Index</a></li>
|
13
|
+
<li><a href="<%= relative_root %>/section_index.html">Section Index</a></li>
|
14
|
+
</ul>
|
15
|
+
|
16
|
+
<div class="content">
|
17
|
+
<%= content %>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<p id="footer">
|
21
|
+
Generated by css_doc. css_doc is Copyright (2009) Thomas Kadauke, imedo.de, das <a href="http://www.imedo.de">Gesundheitsportal</a>.
|
22
|
+
</p>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
26
|
+
|
@@ -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
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: imedo-css_doc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Kadauke
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-19 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Library and Executable that extracts documentation from CSS files.
|
17
|
+
email: thomas.kadauke@imedo.de
|
18
|
+
executables:
|
19
|
+
- cssdoc
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- src/css_doc/css_writer.rb
|
26
|
+
- src/css_doc/document.rb
|
27
|
+
- src/css_doc/document_collection.rb
|
28
|
+
- src/css_doc/document_documentation.rb
|
29
|
+
- src/css_doc/document_handler.rb
|
30
|
+
- src/css_doc/document_template.rb
|
31
|
+
- src/css_doc/documentation.rb
|
32
|
+
- src/css_doc/driver.rb
|
33
|
+
- src/css_doc/file_index_template.rb
|
34
|
+
- src/css_doc/index_template.rb
|
35
|
+
- src/css_doc/rule_set.rb
|
36
|
+
- src/css_doc/rule_set_documentation.rb
|
37
|
+
- src/css_doc/section.rb
|
38
|
+
- src/css_doc/section_documentation.rb
|
39
|
+
- src/css_doc/section_index_template.rb
|
40
|
+
- src/css_doc/selector_index_template.rb
|
41
|
+
- src/css_doc/template.rb
|
42
|
+
- src/css_doc.rb
|
43
|
+
- src/css_pool/visitors/to_css.rb
|
44
|
+
- src/rake/css_doc_task.rb
|
45
|
+
- src/templates/default/css_doc.css
|
46
|
+
- src/templates/default/document.html.erb
|
47
|
+
- src/templates/default/file_index.html.erb
|
48
|
+
- src/templates/default/index.html.erb
|
49
|
+
- src/templates/default/layout.html.erb
|
50
|
+
- src/templates/default/section_index.html.erb
|
51
|
+
- src/templates/default/selector_index.html.erb
|
52
|
+
has_rdoc: false
|
53
|
+
homepage: http://www.imedo.de
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
|
57
|
+
require_paths:
|
58
|
+
- src
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.2.0
|
75
|
+
signing_key:
|
76
|
+
specification_version: 2
|
77
|
+
summary: Documentation generator for CSS files, similar to Javadoc or RDoc.
|
78
|
+
test_files: []
|
79
|
+
|