mizuho 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mizuho
3
3
  version: !ruby/object:Gem::Version
4
- hash: 43
4
+ hash: 41
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 8
10
- version: 0.9.8
9
+ - 9
10
+ version: 0.9.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Hongli Lai
@@ -15,11 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-02 00:00:00 +02:00
19
- default_executable:
18
+ date: 2012-04-15 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: hpricot
21
+ name: nokogiri
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
@@ -47,20 +46,27 @@ files:
47
46
  - Rakefile
48
47
  - bin/mizuho
49
48
  - bin/mizuho-asciidoc
50
- - lib/mizuho/chapter.rb
49
+ - lib/mizuho/fuzzystringmatch.rb
51
50
  - lib/mizuho/generator.rb
52
- - lib/mizuho/heading.rb
53
- - lib/mizuho/parser.rb
51
+ - lib/mizuho/id_map.rb
54
52
  - lib/mizuho/source_highlight.rb
55
- - lib/mizuho/template.rb
56
53
  - lib/mizuho.rb
57
54
  - test/generator_spec.rb
55
+ - test/id_map_spec.rb
58
56
  - test/parser_spec.rb
59
57
  - test/spec_helper.rb
60
- - templates/asciidoc.css
61
- - templates/asciidoc.html.erb
62
- - templates/manualsonrails.css
63
- - templates/manualsonrails.html.erb
58
+ - templates/arrow-up.png
59
+ - templates/balloon.png
60
+ - templates/balloon.svg
61
+ - templates/jquery-1.6.1.min.js
62
+ - templates/jquery-1.7.1.min.js
63
+ - templates/jquery.hashchange-1.0.0.js
64
+ - templates/juvia.js
65
+ - templates/mizuho.css
66
+ - templates/mizuho.js
67
+ - templates/topbar.css
68
+ - templates/topbar.html
69
+ - templates/topbar.js
64
70
  - asciidoc/a2x.py
65
71
  - asciidoc/asciidoc.conf
66
72
  - asciidoc/asciidoc.py
@@ -319,7 +325,6 @@ files:
319
325
  - source-highlight/xhtmltable.outlang
320
326
  - source-highlight/xml.lang
321
327
  - source-highlight/xorg.lang
322
- has_rdoc: true
323
328
  homepage: https://github.com/FooBarWidget/mizuho
324
329
  licenses: []
325
330
 
@@ -349,9 +354,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
349
354
  requirements: []
350
355
 
351
356
  rubyforge_project:
352
- rubygems_version: 1.5.2
357
+ rubygems_version: 1.8.15
353
358
  signing_key:
354
359
  specification_version: 3
355
360
  summary: Mizuho documentation formatting tool
356
361
  test_files: []
357
362
 
363
+ has_rdoc:
@@ -1,54 +0,0 @@
1
- module Mizuho
2
-
3
- class Chapter
4
- # This may be nil, indicating that this chapter is the preamble.
5
- attr_accessor :heading
6
- attr_accessor :filename
7
- attr_accessor :contents
8
-
9
- def is_preamble?
10
- return heading.nil?
11
- end
12
-
13
- def title
14
- if @heading
15
- return @heading.title
16
- else
17
- return nil
18
- end
19
- end
20
-
21
- def title_without_numbers
22
- if @heading
23
- return @heading.title_without_numbers
24
- else
25
- return nil
26
- end
27
- end
28
-
29
- def plain_title
30
- if @heading
31
- return @heading.plain_title
32
- else
33
- return nil
34
- end
35
- end
36
-
37
- def basename
38
- return File.basename(filename)
39
- end
40
-
41
- def anchor
42
- if @heading
43
- return @heading.anchor
44
- else
45
- return nil
46
- end
47
- end
48
-
49
- def anchor_id
50
- return anchor.sub(/^#/, '')
51
- end
52
- end
53
-
54
- end
@@ -1,46 +0,0 @@
1
- require 'cgi'
2
-
3
- module Mizuho
4
-
5
- class Heading
6
- # The heading title, as HTML. Non-HTML special characters are already escaped.
7
- attr_accessor :title
8
- attr_accessor :level
9
- attr_accessor :basename
10
- attr_accessor :anchor
11
- attr_accessor :parent
12
- attr_accessor :children
13
-
14
- def initialize
15
- @children = []
16
- end
17
-
18
- def find_parent_with_level(level)
19
- h = self
20
- while h && h.level != level
21
- h = h.parent
22
- end
23
- return h
24
- end
25
-
26
- # The heading title without section number, as HTML. Non-HTML special characters
27
- # are already escaped.
28
- def title_without_numbers
29
- return title.sub(/^(\d+\.)+ /, '')
30
- end
31
-
32
- # The heading title without section number, as plain text. Contains no HTML
33
- # elements. Non-HTML special characters are NOT escaped.
34
- def plain_title
35
- return CGI::unescapeHTML(title_without_numbers.gsub(%r{</?[a-z]+>}i, ''))
36
- end
37
-
38
- def each_descendant(&block)
39
- children.each do |h|
40
- block.call(h)
41
- h.each_descendant(&block)
42
- end
43
- end
44
- end
45
-
46
- end
data/lib/mizuho/parser.rb DELETED
@@ -1,103 +0,0 @@
1
- require 'cgi'
2
- require 'mizuho/heading'
3
- require 'mizuho/chapter'
4
-
5
- module Mizuho
6
-
7
- # This class can parse the raw Asciidoc XHTML output, and extract the title, raw
8
- # contents (without layout) and other information from it.
9
- class Parser
10
- attr_reader :filename
11
-
12
- # The document's title.
13
- attr_reader :title
14
- # The document's table of contents, represented in a tree structure
15
- # by Heading objects.
16
- attr_reader :table_of_contents
17
- # The document's raw contents, without any layout.
18
- attr_reader :contents
19
-
20
- # Parse the given file.
21
- def initialize(filename)
22
- @filename = filename
23
-
24
- @contents = File.read(filename)
25
-
26
- # Extract the title.
27
- @contents =~ %r{<title>(.*?)</title>}
28
- @title = CGI::unescapeHTML($1)
29
-
30
- # Get rid of the Asciidoc layout and unwanted elements.
31
- if !@contents.sub!(/\A.*?(<div id="preamble">)/m, '\1')
32
- # There's no preamble, so strip everything until the
33
- # end of the TOC div.
34
- @contents.sub!(%r(\A.*?</noscript>[\r\n\s]*</div>[\r\n\s]*</div>)m, '')
35
- end
36
- @contents.sub!(/<div id="footer">.*/m, '')
37
- @contents.gsub!(%r{<div style="clear:left"></div>}, '')
38
-
39
- # Extract table of contents.
40
- parse_table_of_contents(@contents)
41
- end
42
-
43
- # Returns the individual chapters as an array of Chapter objects. The
44
- # first Chapter object represents the preamble.
45
- def chapters
46
- @chapters ||= parse_chapters(@contents)
47
- end
48
-
49
- private
50
- def parse_table_of_contents(html)
51
- @headings = []
52
- current_heading = toplevel_heading = Heading.new
53
- current_heading.title = @title
54
- current_heading.level = 1
55
- offset = 0
56
- while true
57
- offset = html.index(%r{<h(\d) id="(.*?)">(.*?)</h\d>}, offset)
58
- break if offset.nil?
59
- offset = $~.end(0)
60
- level = $1.to_i
61
- anchor = CGI::unescapeHTML($2)
62
- title = $3
63
-
64
- new_heading = Heading.new
65
- new_heading.title = title
66
- new_heading.level = level
67
- new_heading.anchor = "##{anchor}"
68
- new_heading.parent = current_heading.find_parent_with_level(level - 1)
69
- new_heading.parent.children << new_heading
70
- current_heading = new_heading
71
- @headings << new_heading
72
- end
73
- @table_of_contents = toplevel_heading.children
74
- end
75
-
76
- def parse_chapters(html)
77
- if !defined?(Hpricot)
78
- require 'rubygems'
79
- require 'hpricot'
80
- end
81
- doc = Hpricot(contents)
82
- result = []
83
-
84
- has_preamble = !(doc / '#preamble').empty?
85
-
86
- # TODO: fix cross-references
87
- (doc / 'div.sectionbody').each_with_index do |elem, i|
88
- chapter = Chapter.new
89
- if has_preamble
90
- if i > 0
91
- chapter.heading = @table_of_contents[i - 1]
92
- end
93
- else
94
- chapter.heading = @table_of_contents[i]
95
- end
96
- chapter.contents = elem.inner_html
97
- result << chapter
98
- end
99
- return result
100
- end
101
- end
102
-
103
- end
@@ -1,50 +0,0 @@
1
- require 'erb'
2
- require 'mizuho/parser'
3
-
4
- module Mizuho
5
-
6
- class Template
7
- class Error < StandardError
8
- end
9
-
10
- def initialize(template_file, options)
11
- @template_file = template_file
12
- @base_dir = File.expand_path(File.dirname(@template_file))
13
- @options = options
14
- options.each_key do |key|
15
- raise "All option keys must be symbols." if !key.is_a?(Symbol)
16
- raise "Invalid key name '#{key}'." if key.to_s !~ /\A[a-z0-9_]+\??\Z/i
17
- eval %{
18
- def #{key}
19
- @options[:#{key}]
20
- end
21
- }
22
- end
23
- apply
24
- end
25
-
26
- def save(output_file)
27
- File.open(output_file, 'w') do |f|
28
- f.write(@output_contents)
29
- end
30
- end
31
-
32
- protected
33
- include ERB::Util
34
-
35
- def include_file(basename)
36
- return File.read(File.join(@base_dir, basename))
37
- end
38
-
39
- private
40
- def get_binding
41
- return binding
42
- end
43
-
44
- def apply
45
- erb = ERB.new(File.read(@template_file), nil, '-')
46
- @output_contents = eval(erb.src, get_binding, @template_file)
47
- end
48
- end
49
-
50
- end
@@ -1,358 +0,0 @@
1
- /**** Asciidoc default CSS. ****/
2
-
3
- /* Debug borders */
4
- p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
5
- /*
6
- border: 1px solid red;
7
- */
8
- }
9
-
10
- body {
11
- margin: 1em 5% 1em 5%;
12
- }
13
-
14
- a {
15
- color: blue;
16
- text-decoration: underline;
17
- }
18
- a:visited {
19
- color: fuchsia;
20
- }
21
-
22
- em {
23
- font-style: italic;
24
- color: navy;
25
- }
26
-
27
- strong {
28
- font-weight: bold;
29
- color: #083194;
30
- }
31
-
32
- tt {
33
- color: navy;
34
- }
35
-
36
- h1, h2, h3, h4, h5, h6 {
37
- color: #527bbd;
38
- font-family: sans-serif;
39
- margin-top: 1.2em;
40
- margin-bottom: 0.5em;
41
- line-height: 1.3;
42
- }
43
-
44
- h1, h2, h3 {
45
- border-bottom: 2px solid silver;
46
- }
47
- h2 {
48
- padding-top: 0.5em;
49
- }
50
- h3 {
51
- float: left;
52
- }
53
- h3 + * {
54
- clear: left;
55
- }
56
-
57
- div.sectionbody {
58
- font-family: serif;
59
- margin-left: 0;
60
- }
61
-
62
- hr {
63
- border: 1px solid silver;
64
- }
65
-
66
- p {
67
- margin-top: 0.5em;
68
- margin-bottom: 0.5em;
69
- }
70
-
71
- ul, ol, li > p {
72
- margin-top: 0;
73
- }
74
-
75
- pre {
76
- padding: 0;
77
- margin: 0;
78
- }
79
-
80
- span#author {
81
- color: #527bbd;
82
- font-family: sans-serif;
83
- font-weight: bold;
84
- font-size: 1.1em;
85
- }
86
- span#email {
87
- }
88
- span#revision {
89
- font-family: sans-serif;
90
- }
91
-
92
- div#footer {
93
- font-family: sans-serif;
94
- font-size: small;
95
- border-top: 2px solid silver;
96
- padding-top: 0.5em;
97
- margin-top: 4.0em;
98
- }
99
- div#footer-text {
100
- float: left;
101
- padding-bottom: 0.5em;
102
- }
103
- div#footer-badges {
104
- float: right;
105
- padding-bottom: 0.5em;
106
- }
107
-
108
- div#preamble,
109
- div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
110
- div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
111
- div.admonitionblock {
112
- margin-right: 10%;
113
- margin-top: 1.5em;
114
- margin-bottom: 1.5em;
115
- }
116
- div.admonitionblock {
117
- margin-top: 2.5em;
118
- margin-bottom: 2.5em;
119
- }
120
-
121
- div.content { /* Block element content. */
122
- padding: 0;
123
- }
124
-
125
- /* Block element titles. */
126
- div.title, caption.title {
127
- color: #527bbd;
128
- font-family: sans-serif;
129
- font-weight: bold;
130
- text-align: left;
131
- margin-top: 1.0em;
132
- margin-bottom: 0.5em;
133
- }
134
- div.title + * {
135
- margin-top: 0;
136
- }
137
-
138
- td div.title:first-child {
139
- margin-top: 0.0em;
140
- }
141
- div.content div.title:first-child {
142
- margin-top: 0.0em;
143
- }
144
- div.content + div.title {
145
- margin-top: 0.0em;
146
- }
147
-
148
- div.sidebarblock > div.content {
149
- background: #ffffee;
150
- border: 1px solid silver;
151
- padding: 0.5em;
152
- }
153
-
154
- div.listingblock {
155
- margin-right: 0%;
156
- }
157
- div.listingblock > div.content {
158
- border: 1px solid silver;
159
- background: #f4f4f4;
160
- padding: 0.5em;
161
- }
162
-
163
- div.quoteblock {
164
- padding-left: 2.0em;
165
- }
166
- div.quoteblock > div.attribution {
167
- padding-top: 0.5em;
168
- text-align: right;
169
- }
170
-
171
- div.verseblock {
172
- padding-left: 2.0em;
173
- }
174
- div.verseblock > div.content {
175
- white-space: pre;
176
- }
177
- div.verseblock > div.attribution {
178
- padding-top: 0.75em;
179
- text-align: left;
180
- }
181
- /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
182
- div.verseblock + div.attribution {
183
- text-align: left;
184
- }
185
-
186
- div.admonitionblock .icon {
187
- vertical-align: top;
188
- font-size: 1.1em;
189
- font-weight: bold;
190
- text-decoration: underline;
191
- color: #527bbd;
192
- padding-right: 0.5em;
193
- }
194
- div.admonitionblock td.content {
195
- padding-left: 0.5em;
196
- border-left: 2px solid silver;
197
- }
198
-
199
- div.exampleblock > div.content {
200
- border-left: 2px solid silver;
201
- padding: 0.5em;
202
- }
203
-
204
- div.imageblock div.content { padding-left: 0; }
205
- div.imageblock img { border: 1px solid silver; }
206
- span.image img { border-style: none; }
207
-
208
- dl {
209
- margin-top: 0.8em;
210
- margin-bottom: 0.8em;
211
- }
212
- dt {
213
- margin-top: 0.5em;
214
- margin-bottom: 0;
215
- font-style: normal;
216
- }
217
- dd > *:first-child {
218
- margin-top: 0.1em;
219
- }
220
-
221
- ul, ol {
222
- list-style-position: outside;
223
- }
224
- div.olist > ol {
225
- list-style-type: decimal;
226
- }
227
- div.olist2 > ol {
228
- list-style-type: lower-alpha;
229
- }
230
-
231
- div.tableblock > table {
232
- border: 3px solid #527bbd;
233
- }
234
- thead {
235
- font-family: sans-serif;
236
- font-weight: bold;
237
- }
238
- tfoot {
239
- font-weight: bold;
240
- }
241
-
242
- div.hlist {
243
- margin-top: 0.8em;
244
- margin-bottom: 0.8em;
245
- }
246
- div.hlist td {
247
- padding-bottom: 15px;
248
- }
249
- td.hlist1 {
250
- vertical-align: top;
251
- font-style: normal;
252
- padding-right: 0.8em;
253
- }
254
- td.hlist2 {
255
- vertical-align: top;
256
- }
257
-
258
- @media print {
259
- div#footer-badges { display: none; }
260
- }
261
-
262
- div#toctitle {
263
- color: #527bbd;
264
- font-family: sans-serif;
265
- font-size: 1.1em;
266
- font-weight: bold;
267
- margin-top: 1.0em;
268
- margin-bottom: 0.1em;
269
- }
270
-
271
- div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
272
- margin-top: 0;
273
- margin-bottom: 0;
274
- }
275
- div.toclevel2 {
276
- margin-left: 2em;
277
- font-size: 0.9em;
278
- }
279
- div.toclevel3 {
280
- margin-left: 4em;
281
- font-size: 0.9em;
282
- }
283
- div.toclevel4 {
284
- margin-left: 6em;
285
- font-size: 0.9em;
286
- }
287
- div.toclevel1.return_to_table_of_contents {
288
- margin-bottom: 0.5em;
289
- }
290
- /* Workarounds for IE6's broken and incomplete CSS2. */
291
-
292
- div.sidebar-content {
293
- background: #ffffee;
294
- border: 1px solid silver;
295
- padding: 0.5em;
296
- }
297
- div.sidebar-title, div.image-title {
298
- color: #527bbd;
299
- font-family: sans-serif;
300
- font-weight: bold;
301
- margin-top: 0.0em;
302
- margin-bottom: 0.5em;
303
- }
304
-
305
- div.listingblock div.content {
306
- border: 1px solid silver;
307
- background: #f4f4f4;
308
- padding: 0.5em;
309
- overflow: auto;
310
- overflow-x: auto;
311
- }
312
-
313
- div.quoteblock-attribution {
314
- padding-top: 0.5em;
315
- text-align: right;
316
- }
317
-
318
- div.verseblock-content {
319
- white-space: pre;
320
- }
321
- div.verseblock-attribution {
322
- padding-top: 0.75em;
323
- text-align: left;
324
- }
325
-
326
- div.exampleblock-content {
327
- border-left: 2px solid silver;
328
- padding-left: 0.5em;
329
- }
330
-
331
- /* IE6 sets dynamically generated links as visited. */
332
- div#toc a:visited { color: blue; }
333
-
334
- /* Because IE6 child selector is broken. */
335
- div.olist2 ol {
336
- list-style-type: lower-alpha;
337
- }
338
- div.olist2 div.olist ol {
339
- list-style-type: decimal;
340
- }
341
-
342
- #chapter_navigation {
343
- border-top: solid 1px #9999cc;
344
- width: 100%;
345
- margin-top: 1.5em;
346
- margin-bottom: 1em;
347
- }
348
- #chapter_navigation td {
349
- padding-top: 1.5em;
350
- width: 33%;
351
- vertical-align: top;
352
- }
353
- #chapter_navigation .center {
354
- text-align: center;
355
- }
356
- #chapter_navigation .right-floaty {
357
- text-align: right;
358
- }