crohr-docapi 0.1.1 → 0.1.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/docapi.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{docapi}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Cyril Rohr"]
12
- s.date = %q{2009-09-09}
12
+ s.date = %q{2009-09-10}
13
13
  s.default_executable = %q{docapi}
14
14
  s.description = %q{RDoc template for generating API documentation.}
15
15
  s.email = %q{cyril.rohr@gmail.com}
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -11,9 +11,12 @@ h1 {
11
11
  margin:0.8em 0 0.3em;
12
12
  }
13
13
  h2 {
14
- font-size: 1.2em;
14
+ font-size: 1.4em;
15
15
  font-family: 'Bitstream Vera Sans Mono', Monaco, monospace, courier, 'courier new';
16
16
  }
17
+ h3 {
18
+ font-family: "Courier New";
19
+ }
17
20
  pre
18
21
  {
19
22
  /* margin: 0 0 10px 0;*/
@@ -75,11 +78,14 @@ p.page-title {
75
78
  font-weight: bold;
76
79
  font-size: 2em;
77
80
  }
78
-
79
- ol.methods {
80
- /* list-style-type: none;*/
81
+ .docapi-section {
82
+ margin-left: 15px;
83
+ }
84
+ .docapi-subsection {
85
+ padding: 5px;
86
+ margin-bottom: 20px;
81
87
  }
82
- ol.methods .synopsis {
88
+ .docapi-subsection .docapi-title {
83
89
  padding: 3px 10px;
84
90
  font-size: 1.4em;
85
91
  background: #336699;
@@ -88,11 +94,10 @@ ol.methods .synopsis {
88
94
  font-weight: bold;
89
95
  font-family: "Courier New";
90
96
  }
91
- ol.methods li {
92
- padding: 5px;
93
- margin-bottom: 20px;
94
- }
95
- ol.methods li h2 {
97
+ .docapi-subsection .docapi-subtitle {
98
+ font-size: 1.1em;
99
+ font-weight: bold;
100
+ font-family: 'Bitstream Vera Sans Mono', Monaco, monospace, courier, 'courier new';
96
101
  margin:20px 2px 5px 0px;
97
102
  border-left: 5px solid orange;
98
103
  padding-left: 5px;
data/lib/docapi.rb CHANGED
@@ -21,49 +21,63 @@ class Docapi
21
21
  output_dir.mkpath
22
22
  output = File.open(output_dir+"index.html", "w+")
23
23
  output << header(:title => options[:title])
24
- convert_directory(input_dir, output)
24
+ output << convert_directory(input_dir)
25
25
  output << footer
26
26
  output.close
27
27
  # copy stylesheets and javascripts files
28
28
  FileUtils.cp_r(File.join(File.dirname(__FILE__), "..", "files", "."), output_dir)
29
29
  end
30
30
 
31
- def convert_directory(dir, output, level = 1)
31
+ def convert_directory(dir, level = 1)
32
+ output = []
32
33
  dir.entries.each do |entry|
33
34
  next if entry.to_s =~ /^\./
34
35
  path = dir+entry
36
+ title = entry.to_s.gsub(/\d+-/, "")
37
+ output << "<div id='#{title}' class='docapi-section'>"
35
38
  if path.directory?
36
- output << "<h#{level}>#{entry.to_s.gsub(/\d+-/, "").capitalize}</h#{level}>"
37
- convert_directory(path, output, level+1)
39
+ output << "<h#{level}>#{title.capitalize}</h#{level}>"
40
+ output << convert_directory(path, level+1)
38
41
  else
39
- convert_file(path, output, level+1)
40
- end
42
+ output << convert_file(path)
43
+ end
44
+ output << '</div>'
41
45
  end
46
+ output.flatten
42
47
  end
43
48
 
44
- def convert_file(file, output, level = 1)
49
+ def convert_file(file)
45
50
  case file.extname
46
51
  when ".md"
47
- output << Maruku.new( File.read(file) ).to_html
52
+ Maruku.new( File.read(file) ).to_html
48
53
  when ".rb"
49
- blocks = []
50
- File.open(file, "r").each do |line|
51
- if line =~ /^=begin (.*)$/
52
- output << write_block(blocks.pop)
53
- blocks << {:content => "", :language => $1}
54
- elsif line =~ /^=end$/
55
- output << write_block(blocks.pop)
56
- else
57
- blocks << {:content => "", :language => "ruby"} if blocks.last.nil?
58
- blocks.last[:content] << line
59
- end
60
- end
61
- output << write_block(blocks.pop)
54
+ process_file_sections(file, 'ruby', [/^=begin (.*)$/, /^=end$/])
55
+ when ".py"
56
+ process_file_sections(file, 'python', [/^''' (.*)$/, /^'''$/])
62
57
  when ".html"
63
- output << File.read(file)
58
+ File.read(file)
64
59
  end
65
60
  end
66
61
 
62
+
63
+ def process_file_sections(file, language, regexps)
64
+ blocks = []
65
+ output = ["<div class='docapi-subsection'><div class='docapi-title'>#{File.basename(file).gsub(/^\d+-/, "")}</div>"]
66
+ File.open(file, "r").each do |line|
67
+ if line =~ regexps.first
68
+ output << write_block(blocks.pop)
69
+ blocks << {:content => "", :language => $1}
70
+ elsif line =~ regexps.last
71
+ output << write_block(blocks.pop)
72
+ else
73
+ blocks << {:content => "", :language => language} if blocks.last.nil?
74
+ blocks.last[:content] << line
75
+ end
76
+ end
77
+ output << write_block(blocks.pop)
78
+ output << '</div>'
79
+ end
80
+
67
81
  def write_block(block)
68
82
  if block
69
83
  case block[:language]
@@ -98,13 +112,11 @@ class Docapi
98
112
  methods = documentation.split("<h4> method: ")
99
113
  methods.shift
100
114
  methods.map!{ |m|
101
- ["<li>", m.gsub(/<blockquote><pre>.*/m, "").gsub(/<a name="(.+?)">(.*?)<br \/>\s*?<\/a>/m, "<div class=\"synopsis\"><a name=\"\\1\">\\2<a></div>").gsub(/<pre>(.*?)<\/pre>/m, "<pre><code>\\1</code></pre>"), "</li>"].join("")
115
+ ["<div class='docapi-subsection'>", m.gsub(/<blockquote><pre>.*/m, "").gsub(/<a name="(.+?)">(.*?)<br \/>\s*?<\/a>/m, "<div class='docapi-title'><a name=\"\\1\">\\2<a></div>").gsub(/<h2>(.*?)<\/h2>/m, "<div class='docapi-subtitle'>\\1</div>").gsub(/<pre>(.*?)<\/pre>/m, "<pre><code>\\1</code></pre>"), "</div>"].join("")
102
116
  }.reverse!
103
117
 
104
118
  File.open(File.join(output_dir.realpath, "documentation.html"), "w+") do |f|
105
- f << '<ol class="methods">'
106
119
  methods.each{ |method| f << method }
107
- f << "</ol>"
108
120
  end
109
121
  end
110
122
 
@@ -123,6 +135,7 @@ class Docapi
123
135
  end
124
136
  def footer
125
137
  output = []
138
+ output << "<div id='generation-date'>Generated at: <span class='date'>#{Time.now.to_s}</span></div>"
126
139
  output << "</body></html>"
127
140
  end
128
141
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crohr-docapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Rohr
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-09 00:00:00 -07:00
12
+ date: 2009-09-10 00:00:00 -07:00
13
13
  default_executable: docapi
14
14
  dependencies: []
15
15
 
@@ -55,6 +55,7 @@ files:
55
55
  - test/doc/3-tutorials/2-ruby/example-1.rb
56
56
  has_rdoc: true
57
57
  homepage: http://github.com/crohr/docapi
58
+ licenses:
58
59
  post_install_message:
59
60
  rdoc_options:
60
61
  - --charset=UTF-8
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  requirements: []
76
77
 
77
78
  rubyforge_project:
78
- rubygems_version: 1.2.0
79
+ rubygems_version: 1.3.5
79
80
  signing_key:
80
81
  specification_version: 3
81
82
  summary: RDoc template for generating API documentation.