voloko-sdoc 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/rdoc/History.txt +254 -0
  2. data/rdoc/Manifest.txt +126 -0
  3. data/rdoc/README.txt +47 -0
  4. data/rdoc/RI.txt +58 -0
  5. data/rdoc/Rakefile +70 -0
  6. data/rdoc/bin/rdoc +35 -0
  7. data/rdoc/bin/ri +5 -0
  8. data/rdoc/lib/rdoc/alias.rb +54 -0
  9. data/rdoc/lib/rdoc/anon_class.rb +10 -0
  10. data/rdoc/lib/rdoc/any_method.rb +190 -0
  11. data/rdoc/lib/rdoc/attr.rb +79 -0
  12. data/rdoc/lib/rdoc/cache.rb +41 -0
  13. data/rdoc/lib/rdoc/class_module.rb +87 -0
  14. data/rdoc/lib/rdoc/code_object.rb +152 -0
  15. data/rdoc/lib/rdoc/code_objects.rb +23 -0
  16. data/rdoc/lib/rdoc/constant.rb +36 -0
  17. data/rdoc/lib/rdoc/context.rb +712 -0
  18. data/rdoc/lib/rdoc/diagram.rb +340 -0
  19. data/rdoc/lib/rdoc/dot.rb +249 -0
  20. data/rdoc/lib/rdoc/generator/darkfish.rb +455 -0
  21. data/rdoc/lib/rdoc/generator/markup.rb +194 -0
  22. data/rdoc/lib/rdoc/generator/ri.rb +230 -0
  23. data/rdoc/lib/rdoc/generator/template/darkfish/classpage.rhtml +281 -0
  24. data/rdoc/lib/rdoc/generator/template/darkfish/filepage.rhtml +112 -0
  25. data/rdoc/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  26. data/rdoc/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  27. data/rdoc/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  28. data/rdoc/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  29. data/rdoc/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  30. data/rdoc/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  31. data/rdoc/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  32. data/rdoc/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  33. data/rdoc/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  34. data/rdoc/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  35. data/rdoc/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  36. data/rdoc/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  37. data/rdoc/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  38. data/rdoc/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  39. data/rdoc/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  40. data/rdoc/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  41. data/rdoc/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  42. data/rdoc/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  43. data/rdoc/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  44. data/rdoc/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  45. data/rdoc/lib/rdoc/generator/template/darkfish/index.rhtml +64 -0
  46. data/rdoc/lib/rdoc/generator/template/darkfish/js/darkfish.js +116 -0
  47. data/rdoc/lib/rdoc/generator/template/darkfish/js/jquery.js +32 -0
  48. data/rdoc/lib/rdoc/generator/template/darkfish/js/quicksearch.js +114 -0
  49. data/rdoc/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +10 -0
  50. data/rdoc/lib/rdoc/generator/template/darkfish/rdoc.css +696 -0
  51. data/rdoc/lib/rdoc/generator.rb +8 -0
  52. data/rdoc/lib/rdoc/ghost_method.rb +8 -0
  53. data/rdoc/lib/rdoc/include.rb +39 -0
  54. data/rdoc/lib/rdoc/known_classes.rb +68 -0
  55. data/rdoc/lib/rdoc/markup/attribute_manager.rb +311 -0
  56. data/rdoc/lib/rdoc/markup/formatter.rb +25 -0
  57. data/rdoc/lib/rdoc/markup/fragments.rb +377 -0
  58. data/rdoc/lib/rdoc/markup/inline.rb +126 -0
  59. data/rdoc/lib/rdoc/markup/lines.rb +156 -0
  60. data/rdoc/lib/rdoc/markup/preprocess.rb +80 -0
  61. data/rdoc/lib/rdoc/markup/to_flow.rb +211 -0
  62. data/rdoc/lib/rdoc/markup/to_html.rb +406 -0
  63. data/rdoc/lib/rdoc/markup/to_html_crossref.rb +140 -0
  64. data/rdoc/lib/rdoc/markup/to_latex.rb +328 -0
  65. data/rdoc/lib/rdoc/markup/to_test.rb +53 -0
  66. data/rdoc/lib/rdoc/markup/to_texinfo.rb +73 -0
  67. data/rdoc/lib/rdoc/markup.rb +378 -0
  68. data/rdoc/lib/rdoc/meta_method.rb +8 -0
  69. data/rdoc/lib/rdoc/normal_class.rb +18 -0
  70. data/rdoc/lib/rdoc/normal_module.rb +34 -0
  71. data/rdoc/lib/rdoc/options.rb +542 -0
  72. data/rdoc/lib/rdoc/parser/c.rb +678 -0
  73. data/rdoc/lib/rdoc/parser/perl.rb +165 -0
  74. data/rdoc/lib/rdoc/parser/ruby.rb +2904 -0
  75. data/rdoc/lib/rdoc/parser/simple.rb +39 -0
  76. data/rdoc/lib/rdoc/parser.rb +138 -0
  77. data/rdoc/lib/rdoc/rdoc.rb +375 -0
  78. data/rdoc/lib/rdoc/require.rb +32 -0
  79. data/rdoc/lib/rdoc/ri/cache.rb +187 -0
  80. data/rdoc/lib/rdoc/ri/descriptions.rb +156 -0
  81. data/rdoc/lib/rdoc/ri/display.rb +340 -0
  82. data/rdoc/lib/rdoc/ri/driver.rb +828 -0
  83. data/rdoc/lib/rdoc/ri/formatter.rb +654 -0
  84. data/rdoc/lib/rdoc/ri/paths.rb +93 -0
  85. data/rdoc/lib/rdoc/ri/reader.rb +106 -0
  86. data/rdoc/lib/rdoc/ri/util.rb +79 -0
  87. data/rdoc/lib/rdoc/ri/writer.rb +68 -0
  88. data/rdoc/lib/rdoc/ri.rb +8 -0
  89. data/rdoc/lib/rdoc/single_class.rb +8 -0
  90. data/rdoc/lib/rdoc/stats.rb +178 -0
  91. data/rdoc/lib/rdoc/task.rb +276 -0
  92. data/rdoc/lib/rdoc/tokenstream.rb +33 -0
  93. data/rdoc/lib/rdoc/top_level.rb +242 -0
  94. data/rdoc/lib/rdoc.rb +398 -0
  95. metadata +1 -1
@@ -0,0 +1,378 @@
1
+ require 'rdoc'
2
+
3
+ ##
4
+ # RDoc::Markup parses plain text documents and attempts to decompose them into
5
+ # their constituent parts. Some of these parts are high-level: paragraphs,
6
+ # chunks of verbatim text, list entries and the like. Other parts happen at
7
+ # the character level: a piece of bold text, a word in code font. This markup
8
+ # is similar in spirit to that used on WikiWiki webs, where folks create web
9
+ # pages using a simple set of formatting rules.
10
+ #
11
+ # RDoc::Markup itself does no output formatting: this is left to a different
12
+ # set of classes.
13
+ #
14
+ # RDoc::Markup is extendable at runtime: you can add \new markup elements to
15
+ # be recognised in the documents that RDoc::Markup parses.
16
+ #
17
+ # RDoc::Markup is intended to be the basis for a family of tools which share
18
+ # the common requirement that simple, plain-text should be rendered in a
19
+ # variety of different output formats and media. It is envisaged that
20
+ # RDoc::Markup could be the basis for formatting RDoc style comment blocks,
21
+ # Wiki entries, and online FAQs.
22
+ #
23
+ # == Synopsis
24
+ #
25
+ # This code converts +input_string+ to HTML. The conversion takes place in
26
+ # the +convert+ method, so you can use the same RDoc::Markup converter to
27
+ # convert multiple input strings.
28
+ #
29
+ # require 'rdoc/markup/to_html'
30
+ #
31
+ # h = RDoc::Markup::ToHtml.new
32
+ #
33
+ # puts h.convert(input_string)
34
+ #
35
+ # You can extend the RDoc::Markup parser to recognise new markup
36
+ # sequences, and to add special processing for text that matches a
37
+ # regular expression. Here we make WikiWords significant to the parser,
38
+ # and also make the sequences {word} and \<no>text...</no> signify
39
+ # strike-through text. When then subclass the HTML output class to deal
40
+ # with these:
41
+ #
42
+ # require 'rdoc/markup'
43
+ # require 'rdoc/markup/to_html'
44
+ #
45
+ # class WikiHtml < RDoc::Markup::ToHtml
46
+ # def handle_special_WIKIWORD(special)
47
+ # "<font color=red>" + special.text + "</font>"
48
+ # end
49
+ # end
50
+ #
51
+ # m = RDoc::Markup.new
52
+ # m.add_word_pair("{", "}", :STRIKE)
53
+ # m.add_html("no", :STRIKE)
54
+ #
55
+ # m.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
56
+ #
57
+ # wh = WikiHtml.new
58
+ # wh.add_tag(:STRIKE, "<strike>", "</strike>")
59
+ #
60
+ # puts "<body>#{wh.convert ARGF.read}</body>"
61
+ #
62
+ #--
63
+ # Author:: Dave Thomas, dave@pragmaticprogrammer.com
64
+ # License:: Ruby license
65
+
66
+ class RDoc::Markup
67
+
68
+ SPACE = ?\s
69
+
70
+ # List entries look like:
71
+ # * text
72
+ # 1. text
73
+ # [label] text
74
+ # label:: text
75
+ #
76
+ # Flag it as a list entry, and work out the indent for subsequent lines
77
+
78
+ SIMPLE_LIST_RE = /^(
79
+ ( \* (?# bullet)
80
+ |- (?# bullet)
81
+ |\d+\. (?# numbered )
82
+ |[A-Za-z]\. (?# alphabetically numbered )
83
+ )
84
+ \s+
85
+ )\S/x
86
+
87
+ LABEL_LIST_RE = /^(
88
+ ( \[.*?\] (?# labeled )
89
+ |\S.*:: (?# note )
90
+ )(?:\s+|$)
91
+ )/x
92
+
93
+ ##
94
+ # Take a block of text and use various heuristics to determine it's
95
+ # structure (paragraphs, lists, and so on). Invoke an event handler as we
96
+ # identify significant chunks.
97
+
98
+ def initialize
99
+ @am = RDoc::Markup::AttributeManager.new
100
+ @output = nil
101
+ end
102
+
103
+ ##
104
+ # Add to the sequences used to add formatting to an individual word (such
105
+ # as *bold*). Matching entries will generate attributes that the output
106
+ # formatters can recognize by their +name+.
107
+
108
+ def add_word_pair(start, stop, name)
109
+ @am.add_word_pair(start, stop, name)
110
+ end
111
+
112
+ ##
113
+ # Add to the sequences recognized as general markup.
114
+
115
+ def add_html(tag, name)
116
+ @am.add_html(tag, name)
117
+ end
118
+
119
+ ##
120
+ # Add to other inline sequences. For example, we could add WikiWords using
121
+ # something like:
122
+ #
123
+ # parser.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
124
+ #
125
+ # Each wiki word will be presented to the output formatter via the
126
+ # accept_special method.
127
+
128
+ def add_special(pattern, name)
129
+ @am.add_special(pattern, name)
130
+ end
131
+
132
+ ##
133
+ # We take a string, split it into lines, work out the type of each line,
134
+ # and from there deduce groups of lines (for example all lines in a
135
+ # paragraph). We then invoke the output formatter using a Visitor to
136
+ # display the result.
137
+
138
+ def convert(str, op)
139
+ lines = str.split(/\r?\n/).map { |line| Line.new line }
140
+ @lines = Lines.new lines
141
+
142
+ return "" if @lines.empty?
143
+ @lines.normalize
144
+ assign_types_to_lines
145
+ group = group_lines
146
+ # call the output formatter to handle the result
147
+ #group.each { |line| p line }
148
+ group.accept @am, op
149
+ end
150
+
151
+ private
152
+
153
+ ##
154
+ # Look through the text at line indentation. We flag each line as being
155
+ # Blank, a paragraph, a list element, or verbatim text.
156
+
157
+ def assign_types_to_lines(margin = 0, level = 0)
158
+ while line = @lines.next
159
+ if line.blank? then
160
+ line.stamp :BLANK, level
161
+ next
162
+ end
163
+
164
+ # if a line contains non-blanks before the margin, then it must belong
165
+ # to an outer level
166
+
167
+ text = line.text
168
+
169
+ for i in 0...margin
170
+ if text[i] != SPACE
171
+ @lines.unget
172
+ return
173
+ end
174
+ end
175
+
176
+ active_line = text[margin..-1]
177
+
178
+ # Rules (horizontal lines) look like
179
+ #
180
+ # --- (three or more hyphens)
181
+ #
182
+ # The more hyphens, the thicker the rule
183
+ #
184
+
185
+ if /^(---+)\s*$/ =~ active_line
186
+ line.stamp :RULE, level, $1.length-2
187
+ next
188
+ end
189
+
190
+ # Then look for list entries. First the ones that have to have
191
+ # text following them (* xxx, - xxx, and dd. xxx)
192
+
193
+ if SIMPLE_LIST_RE =~ active_line
194
+ offset = margin + $1.length
195
+ prefix = $2
196
+ prefix_length = prefix.length
197
+
198
+ flag = case prefix
199
+ when "*","-" then :BULLET
200
+ when /^\d/ then :NUMBER
201
+ when /^[A-Z]/ then :UPPERALPHA
202
+ when /^[a-z]/ then :LOWERALPHA
203
+ else raise "Invalid List Type: #{self.inspect}"
204
+ end
205
+
206
+ line.stamp :LIST, level+1, prefix, flag
207
+ text[margin, prefix_length] = " " * prefix_length
208
+ assign_types_to_lines(offset, level + 1)
209
+ next
210
+ end
211
+
212
+ if LABEL_LIST_RE =~ active_line
213
+ offset = margin + $1.length
214
+ prefix = $2
215
+ prefix_length = prefix.length
216
+
217
+ next if handled_labeled_list(line, level, margin, offset, prefix)
218
+ end
219
+
220
+ # Headings look like
221
+ # = Main heading
222
+ # == Second level
223
+ # === Third
224
+ #
225
+ # Headings reset the level to 0
226
+
227
+ if active_line[0] == ?= and active_line =~ /^(=+)\s*(.*)/
228
+ prefix_length = $1.length
229
+ prefix_length = 6 if prefix_length > 6
230
+ line.stamp :HEADING, 0, prefix_length
231
+ line.strip_leading(margin + prefix_length)
232
+ next
233
+ end
234
+
235
+ # If the character's a space, then we have verbatim text,
236
+ # otherwise
237
+
238
+ if active_line[0] == SPACE
239
+ line.strip_leading(margin) if margin > 0
240
+ line.stamp :VERBATIM, level
241
+ else
242
+ line.stamp :PARAGRAPH, level
243
+ end
244
+ end
245
+ end
246
+
247
+ ##
248
+ # Handle labeled list entries, We have a special case to deal with.
249
+ # Because the labels can be long, they force the remaining block of text
250
+ # over the to right:
251
+ #
252
+ # this is a long label that I wrote:: and here is the
253
+ # block of text with
254
+ # a silly margin
255
+ #
256
+ # So we allow the special case. If the label is followed by nothing, and
257
+ # if the following line is indented, then we take the indent of that line
258
+ # as the new margin.
259
+ #
260
+ # this is a long label that I wrote::
261
+ # here is a more reasonably indented block which
262
+ # will be attached to the label.
263
+ #
264
+
265
+ def handled_labeled_list(line, level, margin, offset, prefix)
266
+ prefix_length = prefix.length
267
+ text = line.text
268
+ flag = nil
269
+
270
+ case prefix
271
+ when /^\[/ then
272
+ flag = :LABELED
273
+ prefix = prefix[1, prefix.length-2]
274
+ when /:$/ then
275
+ flag = :NOTE
276
+ prefix.chop!
277
+ else
278
+ raise "Invalid List Type: #{self.inspect}"
279
+ end
280
+
281
+ # body is on the next line
282
+ if text.length <= offset then
283
+ original_line = line
284
+ line = @lines.next
285
+ return false unless line
286
+ text = line.text
287
+
288
+ for i in 0..margin
289
+ if text[i] != SPACE
290
+ @lines.unget
291
+ return false
292
+ end
293
+ end
294
+
295
+ i = margin
296
+ i += 1 while text[i] == SPACE
297
+
298
+ if i >= text.length then
299
+ @lines.unget
300
+ return false
301
+ else
302
+ offset = i
303
+ prefix_length = 0
304
+
305
+ if text[offset..-1] =~ SIMPLE_LIST_RE then
306
+ @lines.unget
307
+ line = original_line
308
+ line.text = ''
309
+ else
310
+ @lines.delete original_line
311
+ end
312
+ end
313
+ end
314
+
315
+ line.stamp :LIST, level+1, prefix, flag
316
+ text[margin, prefix_length] = " " * prefix_length
317
+ assign_types_to_lines(offset, level + 1)
318
+ return true
319
+ end
320
+
321
+ ##
322
+ # Return a block consisting of fragments which are paragraphs, list
323
+ # entries or verbatim text. We merge consecutive lines of the same type
324
+ # and level together. We are also slightly tricky with lists: the lines
325
+ # following a list introduction look like paragraph lines at the next
326
+ # level, and we remap them into list entries instead.
327
+
328
+ def group_lines
329
+ @lines.rewind
330
+
331
+ in_list = false
332
+ wanted_type = wanted_level = nil
333
+
334
+ block = LineCollection.new
335
+ group = nil
336
+
337
+ while line = @lines.next
338
+ if line.level == wanted_level and line.type == wanted_type
339
+ group.add_text(line.text)
340
+ else
341
+ group = block.fragment_for(line)
342
+ block.add(group)
343
+
344
+ if line.type == :LIST
345
+ wanted_type = :PARAGRAPH
346
+ else
347
+ wanted_type = line.type
348
+ end
349
+
350
+ wanted_level = line.type == :HEADING ? line.param : line.level
351
+ end
352
+ end
353
+
354
+ block.normalize
355
+ block
356
+ end
357
+
358
+ ##
359
+ # For debugging, we allow access to our line contents as text.
360
+
361
+ def content
362
+ @lines.as_text
363
+ end
364
+ public :content
365
+
366
+ ##
367
+ # For debugging, return the list of line types.
368
+
369
+ def get_line_types
370
+ @lines.line_types
371
+ end
372
+ public :get_line_types
373
+
374
+ end
375
+
376
+ require 'rdoc/markup/fragments'
377
+ require 'rdoc/markup/inline'
378
+ require 'rdoc/markup/lines'
@@ -0,0 +1,8 @@
1
+ require 'rdoc/any_method'
2
+
3
+ ##
4
+ # MetaMethod represents a meta-programmed method
5
+
6
+ class RDoc::MetaMethod < RDoc::AnyMethod
7
+ end
8
+
@@ -0,0 +1,18 @@
1
+ require 'rdoc/class_module'
2
+
3
+ ##
4
+ # A normal class, neither singleton nor anonymous
5
+
6
+ class RDoc::NormalClass < RDoc::ClassModule
7
+
8
+ def inspect # :nodoc:
9
+ superclass = @superclass ? " < #{@superclass}" : nil
10
+ "<%s:0x%x class %s%s includes: %p attributes: %p methods: %p aliases: %p>" % [
11
+ self.class, object_id,
12
+ full_name, superclass, @includes, @attributes, @method_list, @aliases
13
+ ]
14
+ end
15
+
16
+ end
17
+
18
+
@@ -0,0 +1,34 @@
1
+ require 'rdoc/class_module'
2
+
3
+ ##
4
+ # A normal module, like NormalClass
5
+
6
+ class RDoc::NormalModule < RDoc::ClassModule
7
+
8
+ ##
9
+ # Appends +comment+ to the current comment, but separated by a rule
10
+
11
+ def comment=(comment)
12
+ return if comment.empty?
13
+ comment = @comment << "\n# ---\n" << comment unless @comment.empty?
14
+
15
+ super
16
+ end
17
+
18
+ def inspect # :nodoc:
19
+ "#<%s:0x%x module %s includes: %p attributes: %p methods: %p aliases: %p>" % [
20
+ self.class, object_id,
21
+ full_name, @includes, @attributes, @method_list, @aliases
22
+ ]
23
+ end
24
+
25
+ ##
26
+ # This is a module, returns true
27
+
28
+ def module?
29
+ true
30
+ end
31
+
32
+ end
33
+
34
+