rdoc 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (52) hide show
  1. data.tar.gz.sig +1 -0
  2. data/History.txt +30 -0
  3. data/Manifest.txt +18 -6
  4. data/Rakefile +52 -0
  5. data/lib/rdoc.rb +69 -69
  6. data/lib/rdoc/code_objects.rb +331 -112
  7. data/lib/rdoc/generator.rb +172 -144
  8. data/lib/rdoc/generator/html.rb +45 -18
  9. data/lib/rdoc/generator/html/frameless.rb +795 -0
  10. data/lib/rdoc/generator/html/hefss.rb +11 -11
  11. data/lib/rdoc/generator/html/html.rb +81 -87
  12. data/lib/rdoc/generator/html/kilmer.rb +10 -10
  13. data/lib/rdoc/generator/html/one_page_html.rb +9 -9
  14. data/lib/rdoc/generator/ri.rb +5 -8
  15. data/lib/rdoc/generator/texinfo.rb +84 -0
  16. data/lib/rdoc/generator/texinfo/class.texinfo.erb +44 -0
  17. data/lib/rdoc/generator/texinfo/file.texinfo.erb +6 -0
  18. data/lib/rdoc/generator/texinfo/method.texinfo.erb +6 -0
  19. data/lib/rdoc/generator/texinfo/texinfo.erb +28 -0
  20. data/lib/rdoc/known_classes.rb +69 -0
  21. data/lib/rdoc/markup.rb +3 -3
  22. data/lib/rdoc/markup/attribute_manager.rb +0 -9
  23. data/lib/rdoc/markup/fragments.rb +1 -1
  24. data/lib/rdoc/markup/preprocess.rb +10 -6
  25. data/lib/rdoc/markup/to_html.rb +55 -8
  26. data/lib/rdoc/markup/to_html_crossref.rb +21 -5
  27. data/lib/rdoc/markup/to_texinfo.rb +69 -0
  28. data/lib/rdoc/options.rb +37 -14
  29. data/lib/rdoc/parser.rb +109 -0
  30. data/lib/rdoc/parser/c.rb +656 -0
  31. data/lib/rdoc/parser/f95.rb +1835 -0
  32. data/lib/rdoc/{parsers/parse_rb.rb → parser/ruby.rb} +1436 -1191
  33. data/lib/rdoc/parser/simple.rb +38 -0
  34. data/lib/rdoc/rdoc.rb +48 -32
  35. data/lib/rdoc/ri.rb +5 -1
  36. data/lib/rdoc/ri/descriptions.rb +8 -5
  37. data/lib/rdoc/ri/driver.rb +148 -49
  38. data/lib/rdoc/stats.rb +94 -4
  39. data/test/test_rdoc_info_formatting.rb +175 -0
  40. data/test/test_rdoc_info_sections.rb +136 -0
  41. data/test/test_rdoc_markup_to_html.rb +30 -0
  42. data/test/test_rdoc_markup_to_html_crossref.rb +18 -0
  43. data/test/{test_rdoc_c_parser.rb → test_rdoc_parser_c.rb} +8 -11
  44. data/test/test_rdoc_parser_ruby.rb +539 -0
  45. data/test/test_rdoc_ri_default_display.rb +17 -16
  46. data/test/test_rdoc_ri_driver.rb +92 -0
  47. metadata +54 -12
  48. metadata.gz.sig +0 -0
  49. data/lib/rdoc/parsers/parse_c.rb +0 -775
  50. data/lib/rdoc/parsers/parse_f95.rb +0 -1841
  51. data/lib/rdoc/parsers/parse_simple.rb +0 -40
  52. data/lib/rdoc/parsers/parserfactory.rb +0 -99
@@ -17,7 +17,7 @@ module RDoc::Generator::HTML::ONE_PAGE_HTML
17
17
  <% unless requires["aref"] then %>
18
18
  <li><%= requires["name"] %></li>
19
19
  <% end %>
20
- <% end # files["requires"] %>
20
+ <% end %><%# files["requires"] %>
21
21
  </ul>
22
22
  <% end %>
23
23
 
@@ -31,7 +31,7 @@ module RDoc::Generator::HTML::ONE_PAGE_HTML
31
31
  <% unless includes["aref"] then %>
32
32
  <li><%= includes["name"] %></li>
33
33
  <% end %>
34
- <% end # classes["includes"] %>
34
+ <% end %><%# classes["includes"] %>
35
35
  </ul>
36
36
  <% end %>
37
37
 
@@ -42,7 +42,7 @@ module RDoc::Generator::HTML::ONE_PAGE_HTML
42
42
  <table>
43
43
  <% sections["attributes"].each do |attributes| %>
44
44
  <tr><td><%= attributes["name"] %></td><td><%= attributes["rw"] %></td><td><%= attributes["a_desc"] %></td></tr>
45
- <% end # sections["attributes"] %>
45
+ <% end %><%# sections["attributes"] %>
46
46
  </table>
47
47
  <% end %>
48
48
 
@@ -68,11 +68,11 @@ module RDoc::Generator::HTML::ONE_PAGE_HTML
68
68
  <%= methods["sourcecode"] %>
69
69
  </pre></blockquote>
70
70
  <% end %>
71
- <% end # method_list["methods"] %>
71
+ <% end %><%# method_list["methods"] %>
72
72
  <% end %>
73
- <% end # sections["method_list"] %>
73
+ <% end %><%# sections["method_list"] %>
74
74
  <% end %>
75
- <% end # classes["sections"] %>
75
+ <% end %><%# classes["sections"] %>
76
76
  <% end %>
77
77
  EOF
78
78
 
@@ -91,7 +91,7 @@ module RDoc::Generator::HTML::ONE_PAGE_HTML
91
91
  <tr><td>Modified:</td><td><%= files["dtm_modified"] %></td></tr>
92
92
  </table>
93
93
  } + CONTENTS_XML + %{
94
- <% end # values["files"] %>
94
+ <% end %><%# values["files"] %>
95
95
 
96
96
  <% if values["classes"] then %>
97
97
  <h2>Classes</h2>
@@ -107,11 +107,11 @@ module RDoc::Generator::HTML::ONE_PAGE_HTML
107
107
  (in files
108
108
  <% classes["infiles"].each do |infiles| %>
109
109
  <%= href infiles["full_path_url"], infiles["full_path"] %>
110
- <% end # classes["infiles"] %>
110
+ <% end %><%# classes["infiles"] %>
111
111
  )
112
112
  <% end %>
113
113
  } + CONTENTS_XML + %{
114
- <% end # values["classes"] %>
114
+ <% end %><%# values["classes"] %>
115
115
  <% end %>
116
116
  </body>
117
117
  </html>
@@ -16,12 +16,8 @@ class RDoc::Generator::RI
16
16
  new(options)
17
17
  end
18
18
 
19
- class << self
20
- protected :new
21
- end
22
-
23
19
  ##
24
- # Set up a new RDoc::Generator::RI.
20
+ # Set up a new ri generator
25
21
 
26
22
  def initialize(options) #:not-new:
27
23
  @options = options
@@ -45,18 +41,19 @@ class RDoc::Generator::RI
45
41
  def process_class(from_class)
46
42
  generate_class_info(from_class)
47
43
 
48
- # now recure into this classes constituent classess
44
+ # now recurse into this class' constituent classes
49
45
  from_class.each_classmodule do |mod|
50
46
  process_class(mod)
51
47
  end
52
48
  end
53
49
 
54
50
  def generate_class_info(cls)
55
- if cls === RDoc::NormalModule
51
+ case cls
52
+ when RDoc::NormalModule then
56
53
  cls_desc = RDoc::RI::ModuleDescription.new
57
54
  else
58
55
  cls_desc = RDoc::RI::ClassDescription.new
59
- cls_desc.superclass = cls.superclass
56
+ cls_desc.superclass = cls.superclass
60
57
  end
61
58
 
62
59
  cls_desc.name = cls.name
@@ -0,0 +1,84 @@
1
+ require 'rdoc/rdoc'
2
+ require 'rdoc/generator'
3
+ require 'rdoc/markup/to_texinfo'
4
+
5
+ module RDoc
6
+ RDoc::GENERATORS['texinfo'] = RDoc::Generator.new("rdoc/generator/texinfo",
7
+ :Texinfo,
8
+ 'texinfo')
9
+ module Generator
10
+ # This generates Texinfo files for viewing with GNU Info or Emacs
11
+ # from RDoc extracted from Ruby source files.
12
+ class Texinfo
13
+ # What should the .info file be named by default?
14
+ DEFAULT_INFO_FILENAME = 'rdoc.info'
15
+
16
+ include Generator::MarkUp
17
+
18
+ # Accept some options
19
+ def initialize(options)
20
+ @options = options
21
+ @options.inline_source = true
22
+ @options.op_name ||= 'rdoc.texinfo'
23
+ @options.formatter = ::RDoc::Markup::ToTexInfo.new
24
+ end
25
+
26
+ # Generate the +texinfo+ files
27
+ def generate(toplevels)
28
+ @toplevels = toplevels
29
+ @files, @classes = ::RDoc::Generator::Context.build_indicies(@toplevels,
30
+ @options)
31
+
32
+ (@files + @classes).each { |x| x.value_hash }
33
+
34
+ open(@options.op_name, 'w') do |f|
35
+ f.puts TexinfoTemplate.new('files' => @files,
36
+ 'classes' => @classes,
37
+ 'filename' => @options.op_name.gsub(/texinfo/, 'info'),
38
+ 'title' => @options.title).render
39
+ end
40
+ # TODO: create info files and install?
41
+ end
42
+
43
+ class << self
44
+ # Factory? We don't need no stinkin' factory!
45
+ alias_method :for, :new
46
+ end
47
+ end
48
+
49
+ # Basically just a wrapper around ERB.
50
+ # Should probably use RDoc::TemplatePage instead
51
+ class TexinfoTemplate
52
+ BASE_DIR = ::File.expand_path(::File.dirname(__FILE__)) # have to calculate this when the file's loaded.
53
+
54
+ def initialize(values, file = 'texinfo.erb')
55
+ @v, @file = [values, file]
56
+ end
57
+
58
+ def template
59
+ ::File.read(::File.join(BASE_DIR, 'texinfo', @file))
60
+ end
61
+
62
+ # Go!
63
+ def render
64
+ ERB.new(template).result binding
65
+ end
66
+
67
+ def href(location, text)
68
+ text # TODO: how does texinfo do hyperlinks?
69
+ end
70
+
71
+ def target(name, text)
72
+ text # TODO: how do hyperlink targets work?
73
+ end
74
+
75
+ # TODO: this is probably implemented elsewhere?
76
+ def method_prefix(section)
77
+ { 'Class' => '.',
78
+ 'Module' => '::',
79
+ 'Instance' => '#',
80
+ }[section['category']]
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,44 @@
1
+ @node <%= @v['class']['full_name'].gsub(/::/, '-') %>
2
+ @chapter <%= @v['class']["classmod"] %> <%= @v['class']['full_name'] %>
3
+
4
+ <% if @v['class']["parent"] and @v['class']['par_url'] %>
5
+ Inherits <%= href @v['class']["par_url"], @v['class']["parent"] %><% end %>
6
+
7
+ <%= @v['class']["description"] %>
8
+
9
+ <% if @v['class']["includes"] %>
10
+ Includes
11
+ <% @v['class']["includes"].each do |include| %>
12
+ * <%= href include["aref"], include["name"] %>
13
+ <% end # @v['class']["includes"] %>
14
+ <% end %>
15
+
16
+ <% if @v['class']["sections"] %>
17
+ <% @v['class']["sections"].each do |section| %>
18
+ <% if section["attributes"] %>
19
+ Attributes
20
+ <% section["attributes"].each do |attributes| %>
21
+ * <%= attributes["name"] %> <%= attributes["rw"] %> <%= attributes["a_desc"] %>
22
+ <% end # section["attributes"] %>
23
+ <% end %>
24
+ <% end %>
25
+
26
+ <% @v['class']["sections"].each do |section| %>
27
+ <% if section["method_list"] %>
28
+ Methods
29
+ @menu
30
+ <% section["method_list"].each_with_index do |method_list, i| %>
31
+ <%= i %>
32
+ <% (method_list["methods"] || []).each do |method| %>
33
+ * <%= @v['class']['full_name'].gsub(/::/, '-') %><%= method_prefix method_list %><%= method['name'] %>::<% end %>
34
+ <% end %>
35
+ @end menu
36
+
37
+ <% section["method_list"].each do |method_list| %>
38
+ <% (method_list["methods"] || []).uniq.each do |method| %>
39
+ <%= TexinfoTemplate.new(@v.merge({'method' => method, 'list' => method_list}),
40
+ 'method.texinfo.erb').render %><% end %>
41
+ <% end # section["method_list"] %>
42
+ <% end %>
43
+ <% end # @v['class']["sections"] %>
44
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <% if false %>
2
+ <h2>File: <%= @v['file']["short_name"] %></h2>
3
+ Path: <%= @v['file']["full_path"] %>
4
+
5
+ <%= TexinfoTemplate.new(@v, 'content.texinfo.erb').render %>
6
+ <% end %>
@@ -0,0 +1,6 @@
1
+ @node <%= @v['class']['full_name'].gsub(/::/, '-') %><%= method_prefix @v['list'] %><%= @v['method']['name'] %>
2
+ @section <%= @v['class']["classmod"] %> <%= @v['class']['full_name'] %><%= method_prefix @v['list'] %><%= @v['method']['name'] %>
3
+ <%= @v['method']["type"] %> <%= @v['method']["category"] %> method:
4
+ <%= target @v['method']["aref"], @v['method']['callseq'] ||
5
+ @v['method']["name"] + @v['method']["params"] %>
6
+ <%= @v['method']["m_desc"] %>
@@ -0,0 +1,28 @@
1
+ \input texinfo @c -*-texinfo-*-
2
+ @c %**start of header
3
+ @setfilename <%= @v['filename'] %>
4
+ @settitle <%= @v['title'] %>
5
+ @c %**end of header
6
+
7
+ @contents @c TODO: whitespace is a mess... =\
8
+
9
+ @ifnottex
10
+ @node Top
11
+
12
+ @top <%= @v['title'] %>
13
+ @end ifnottex
14
+
15
+ <% if @f = @v['files'].detect { |f| f.name =~ /Readme/i } %>
16
+ <%= @f.values['description'] %><% end %>
17
+
18
+ @menu
19
+ <% @v['classes'].each do |klass| %>
20
+ * <%= klass.name.gsub(/::/, '-') %>::<% end %>
21
+ @c TODO: add files
22
+ @end menu
23
+
24
+ <% (@v['classes'] || []).each_with_index do |klass, i| %>
25
+ <%= TexinfoTemplate.new(@v.merge('class' => klass.values),
26
+ 'class.texinfo.erb').render %><% end %>
27
+
28
+ @bye
@@ -0,0 +1,69 @@
1
+ module RDoc
2
+
3
+ ##
4
+ # Ruby's built-in classes, modules and exceptions
5
+
6
+ KNOWN_CLASSES = {
7
+ "rb_cArray" => "Array",
8
+ "rb_cBignum" => "Bignum",
9
+ "rb_cClass" => "Class",
10
+ "rb_cData" => "Data",
11
+ "rb_cDir" => "Dir",
12
+ "rb_cFalseClass" => "FalseClass",
13
+ "rb_cFile" => "File",
14
+ "rb_cFixnum" => "Fixnum",
15
+ "rb_cFloat" => "Float",
16
+ "rb_cHash" => "Hash",
17
+ "rb_cIO" => "IO",
18
+ "rb_cInteger" => "Integer",
19
+ "rb_cModule" => "Module",
20
+ "rb_cNilClass" => "NilClass",
21
+ "rb_cNumeric" => "Numeric",
22
+ "rb_cObject" => "Object",
23
+ "rb_cProc" => "Proc",
24
+ "rb_cRange" => "Range",
25
+ "rb_cRegexp" => "Regexp",
26
+ "rb_cRubyVM" => "RubyVM",
27
+ "rb_cString" => "String",
28
+ "rb_cStruct" => "Struct",
29
+ "rb_cSymbol" => "Symbol",
30
+ "rb_cThread" => "Thread",
31
+ "rb_cTime" => "Time",
32
+ "rb_cTrueClass" => "TrueClass",
33
+
34
+ "rb_eArgError" => "ArgError",
35
+ "rb_eEOFError" => "EOFError",
36
+ "rb_eException" => "Exception",
37
+ "rb_eFatal" => "Fatal",
38
+ "rb_eFloatDomainError" => "FloatDomainError",
39
+ "rb_eIOError" => "IOError",
40
+ "rb_eIndexError" => "IndexError",
41
+ "rb_eInterrupt" => "Interrupt",
42
+ "rb_eLoadError" => "LoadError",
43
+ "rb_eNameError" => "NameError",
44
+ "rb_eNoMemError" => "NoMemError",
45
+ "rb_eNotImpError" => "NotImpError",
46
+ "rb_eRangeError" => "RangeError",
47
+ "rb_eRuntimeError" => "RuntimeError",
48
+ "rb_eScriptError" => "ScriptError",
49
+ "rb_eSecurityError" => "SecurityError",
50
+ "rb_eSignal" => "Signal",
51
+ "rb_eStandardError" => "StandardError",
52
+ "rb_eSyntaxError" => "SyntaxError",
53
+ "rb_eSystemCallError" => "SystemCallError",
54
+ "rb_eSystemExit" => "SystemExit",
55
+ "rb_eTypeError" => "TypeError",
56
+ "rb_eZeroDivError" => "ZeroDivError",
57
+
58
+ "rb_mComparable" => "Comparable",
59
+ "rb_mEnumerable" => "Enumerable",
60
+ "rb_mErrno" => "Errno",
61
+ "rb_mFileTest" => "FileTest",
62
+ "rb_mGC" => "GC",
63
+ "rb_mKernel" => "Kernel",
64
+ "rb_mMath" => "Math",
65
+ "rb_mPrecision" => "Precision",
66
+ "rb_mProcess" => "Process"
67
+ }
68
+
69
+ end
@@ -17,7 +17,7 @@ require 'rdoc'
17
17
  # RDoc::Markup is intended to be the basis for a family of tools which share
18
18
  # the common requirement that simple, plain-text should be rendered in a
19
19
  # variety of different output formats and media. It is envisaged that
20
- # RDoc::Markup could be the basis for formating RDoc style comment blocks,
20
+ # RDoc::Markup could be the basis for formatting RDoc style comment blocks,
21
21
  # Wiki entries, and online FAQs.
22
22
  #
23
23
  # = Basic Formatting
@@ -129,7 +129,7 @@ require 'rdoc'
129
129
  #
130
130
  # You can extend the RDoc::Markup parser to recognise new markup
131
131
  # sequences, and to add special processing for text that matches a
132
- # regular epxression. Here we make WikiWords significant to the parser,
132
+ # regular expression. Here we make WikiWords significant to the parser,
133
133
  # and also make the sequences {word} and \<no>text...</no> signify
134
134
  # strike-through text. When then subclass the HTML output class to deal
135
135
  # with these:
@@ -197,7 +197,7 @@ class RDoc::Markup
197
197
 
198
198
  ##
199
199
  # Add to the sequences used to add formatting to an individual word (such
200
- # as *bold*). Matching entries will generate attibutes that the output
200
+ # as *bold*). Matching entries will generate attributes that the output
201
201
  # formatters can recognize by their +name+.
202
202
 
203
203
  def add_word_pair(start, stop, name)
@@ -144,8 +144,6 @@ class RDoc::Markup::AttributeManager
144
144
  add_html("b", :BOLD)
145
145
  add_html("tt", :TT)
146
146
  add_html("code", :TT)
147
-
148
- add_special(/<!--(.*?)-->/, :COMMENT)
149
147
  end
150
148
 
151
149
  def add_word_pair(start, stop, name)
@@ -176,21 +174,16 @@ class RDoc::Markup::AttributeManager
176
174
  def flow(str)
177
175
  @str = str
178
176
 
179
- puts("Before flow, str='#{@str.dump}'") if $DEBUG_RDOC
180
177
  mask_protected_sequences
181
178
 
182
179
  @attrs = RDoc::Markup::AttrSpan.new @str.length
183
180
 
184
- puts("After protecting, str='#{@str.dump}'") if $DEBUG_RDOC
185
-
186
181
  convert_attrs(@str, @attrs)
187
182
  convert_html(@str, @attrs)
188
183
  convert_specials(str, @attrs)
189
184
 
190
185
  unmask_protected_sequences
191
186
 
192
- puts("After flow, str='#{@str.dump}'") if $DEBUG_RDOC
193
-
194
187
  return split_into_flow
195
188
  end
196
189
 
@@ -217,8 +210,6 @@ class RDoc::Markup::AttributeManager
217
210
  end
218
211
 
219
212
  def split_into_flow
220
- display_attributes if $DEBUG_RDOC
221
-
222
213
  res = []
223
214
  current_attr = 0
224
215
  str = ""
@@ -11,7 +11,7 @@ class RDoc::Markup
11
11
  attr_reader :level, :param, :txt
12
12
  attr_accessor :type
13
13
 
14
- ######
14
+ ##
15
15
  # This is a simple factory system that lets us associate fragement
16
16
  # types (a string) with a subclass of fragment
17
17
 
@@ -14,21 +14,25 @@ class RDoc::Markup::PreProcess
14
14
 
15
15
  ##
16
16
  # Look for common options in a chunk of text. Options that we don't handle
17
- # are passed back to our caller as |directive, param|
17
+ # are yielded to the caller.
18
18
 
19
19
  def handle(text)
20
- text.gsub!(/^([ \t#]*):(\w+):\s*(.+)?\n/) do
20
+ text.gsub!(/^([ \t]*#?[ \t]*):(\w+):([ \t]*)(.+)?\n/) do
21
+ next $& if $3.empty? and $4 and $4[0, 1] == ':'
22
+
21
23
  prefix = $1
22
24
  directive = $2.downcase
23
- param = $3
25
+ param = $4
24
26
 
25
27
  case directive
26
- when "include"
28
+ when 'include' then
27
29
  filename = param.split[0]
28
- include_file(filename, prefix)
30
+ include_file filename, prefix
29
31
 
30
32
  else
31
- yield(directive, param)
33
+ result = yield directive, param
34
+ result = "#{prefix}:#{directive}: #{param}\n" unless result
35
+ result
32
36
  end
33
37
  end
34
38
  end