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.
- data.tar.gz.sig +1 -0
- data/History.txt +30 -0
- data/Manifest.txt +18 -6
- data/Rakefile +52 -0
- data/lib/rdoc.rb +69 -69
- data/lib/rdoc/code_objects.rb +331 -112
- data/lib/rdoc/generator.rb +172 -144
- data/lib/rdoc/generator/html.rb +45 -18
- data/lib/rdoc/generator/html/frameless.rb +795 -0
- data/lib/rdoc/generator/html/hefss.rb +11 -11
- data/lib/rdoc/generator/html/html.rb +81 -87
- data/lib/rdoc/generator/html/kilmer.rb +10 -10
- data/lib/rdoc/generator/html/one_page_html.rb +9 -9
- data/lib/rdoc/generator/ri.rb +5 -8
- data/lib/rdoc/generator/texinfo.rb +84 -0
- data/lib/rdoc/generator/texinfo/class.texinfo.erb +44 -0
- data/lib/rdoc/generator/texinfo/file.texinfo.erb +6 -0
- data/lib/rdoc/generator/texinfo/method.texinfo.erb +6 -0
- data/lib/rdoc/generator/texinfo/texinfo.erb +28 -0
- data/lib/rdoc/known_classes.rb +69 -0
- data/lib/rdoc/markup.rb +3 -3
- data/lib/rdoc/markup/attribute_manager.rb +0 -9
- data/lib/rdoc/markup/fragments.rb +1 -1
- data/lib/rdoc/markup/preprocess.rb +10 -6
- data/lib/rdoc/markup/to_html.rb +55 -8
- data/lib/rdoc/markup/to_html_crossref.rb +21 -5
- data/lib/rdoc/markup/to_texinfo.rb +69 -0
- data/lib/rdoc/options.rb +37 -14
- data/lib/rdoc/parser.rb +109 -0
- data/lib/rdoc/parser/c.rb +656 -0
- data/lib/rdoc/parser/f95.rb +1835 -0
- data/lib/rdoc/{parsers/parse_rb.rb → parser/ruby.rb} +1436 -1191
- data/lib/rdoc/parser/simple.rb +38 -0
- data/lib/rdoc/rdoc.rb +48 -32
- data/lib/rdoc/ri.rb +5 -1
- data/lib/rdoc/ri/descriptions.rb +8 -5
- data/lib/rdoc/ri/driver.rb +148 -49
- data/lib/rdoc/stats.rb +94 -4
- data/test/test_rdoc_info_formatting.rb +175 -0
- data/test/test_rdoc_info_sections.rb +136 -0
- data/test/test_rdoc_markup_to_html.rb +30 -0
- data/test/test_rdoc_markup_to_html_crossref.rb +18 -0
- data/test/{test_rdoc_c_parser.rb → test_rdoc_parser_c.rb} +8 -11
- data/test/test_rdoc_parser_ruby.rb +539 -0
- data/test/test_rdoc_ri_default_display.rb +17 -16
- data/test/test_rdoc_ri_driver.rb +92 -0
- metadata +54 -12
- metadata.gz.sig +0 -0
- data/lib/rdoc/parsers/parse_c.rb +0 -775
- data/lib/rdoc/parsers/parse_f95.rb +0 -1841
- data/lib/rdoc/parsers/parse_simple.rb +0 -40
- data/lib/rdoc/parsers/parserfactory.rb +0 -99
data/lib/rdoc/stats.rb
CHANGED
@@ -5,11 +5,49 @@ require 'rdoc'
|
|
5
5
|
|
6
6
|
class RDoc::Stats
|
7
7
|
|
8
|
-
|
8
|
+
attr_reader :num_classes
|
9
|
+
attr_reader :num_files
|
10
|
+
attr_reader :num_methods
|
11
|
+
attr_reader :num_modules
|
12
|
+
|
13
|
+
def initialize(verbosity = 1)
|
14
|
+
@num_classes = 0
|
15
|
+
@num_files = 0
|
16
|
+
@num_methods = 0
|
17
|
+
@num_modules = 0
|
9
18
|
|
10
|
-
def initialize
|
11
|
-
@num_files = @num_classes = @num_modules = @num_methods = 0
|
12
19
|
@start = Time.now
|
20
|
+
|
21
|
+
@display = case verbosity
|
22
|
+
when 0 then Quiet.new
|
23
|
+
when 1 then Normal.new
|
24
|
+
else Verbose.new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_alias(as)
|
29
|
+
@display.print_alias as
|
30
|
+
@num_methods += 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_class(klass)
|
34
|
+
@display.print_class klass
|
35
|
+
@num_classes += 1
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_file(file)
|
39
|
+
@display.print_file file
|
40
|
+
@num_files += 1
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_method(method)
|
44
|
+
@display.print_method method
|
45
|
+
@num_methods += 1
|
46
|
+
end
|
47
|
+
|
48
|
+
def add_module(mod)
|
49
|
+
@display.print_module mod
|
50
|
+
@num_modules += 1
|
13
51
|
end
|
14
52
|
|
15
53
|
def print
|
@@ -17,7 +55,59 @@ class RDoc::Stats
|
|
17
55
|
puts "Classes: #@num_classes"
|
18
56
|
puts "Modules: #@num_modules"
|
19
57
|
puts "Methods: #@num_methods"
|
20
|
-
puts "Elapsed: " + sprintf("%0.
|
58
|
+
puts "Elapsed: " + sprintf("%0.1fs", Time.now - @start)
|
59
|
+
end
|
60
|
+
|
61
|
+
class Quiet
|
62
|
+
def print_alias(*) end
|
63
|
+
def print_class(*) end
|
64
|
+
def print_file(*) end
|
65
|
+
def print_method(*) end
|
66
|
+
def print_module(*) end
|
67
|
+
end
|
68
|
+
|
69
|
+
class Normal
|
70
|
+
def print_alias(as)
|
71
|
+
print 'a'
|
72
|
+
end
|
73
|
+
|
74
|
+
def print_class(klass)
|
75
|
+
print 'C'
|
76
|
+
end
|
77
|
+
|
78
|
+
def print_file(file)
|
79
|
+
print "\n#{file}: "
|
80
|
+
end
|
81
|
+
|
82
|
+
def print_method(method)
|
83
|
+
print 'm'
|
84
|
+
end
|
85
|
+
|
86
|
+
def print_module(mod)
|
87
|
+
print 'M'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class Verbose
|
92
|
+
def print_alias(as)
|
93
|
+
puts "\t\talias #{as.new_name} #{as.old_name}"
|
94
|
+
end
|
95
|
+
|
96
|
+
def print_class(klass)
|
97
|
+
puts "\tclass #{klass.full_name}"
|
98
|
+
end
|
99
|
+
|
100
|
+
def print_file(file)
|
101
|
+
puts file
|
102
|
+
end
|
103
|
+
|
104
|
+
def print_method(method)
|
105
|
+
puts "\t\t#{method.singleton ? '::' : '#'}#{method.name}"
|
106
|
+
end
|
107
|
+
|
108
|
+
def print_module(mod)
|
109
|
+
puts "\tmodule #{mod.full_name}"
|
110
|
+
end
|
21
111
|
end
|
22
112
|
|
23
113
|
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
require 'rdoc/generator/texinfo'
|
6
|
+
|
7
|
+
# From chapter 18 of the Pickaxe 3rd ed. and the TexInfo manual.
|
8
|
+
class TestRdocInfoFormatting < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@output_dir = File.join Dir.tmpdir, "test_rdoc_info_formatting_#{$$}"
|
11
|
+
@output_file = File.join @output_dir, 'rdoc.texinfo'
|
12
|
+
|
13
|
+
RDoc::RDoc.new.document(['--fmt=texinfo', '--quiet',
|
14
|
+
File.expand_path(__FILE__),
|
15
|
+
"--op=#{@output_dir}"])
|
16
|
+
@text = File.read @output_file
|
17
|
+
|
18
|
+
# File.open('rdoc.texinfo', 'w') { |f| f.puts @text }
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
FileUtils.rm_rf @output_dir
|
23
|
+
end
|
24
|
+
|
25
|
+
# Make sure tags like *this* do not make HTML
|
26
|
+
def test_descriptions_are_not_html
|
27
|
+
assert_no_match Regexp.new("\<b\>this\<\/b\>"), @text, "We had some HTML; icky!"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Ensure we get a reasonable amount
|
31
|
+
#
|
32
|
+
# of space in between paragraphs.
|
33
|
+
def test_paragraphs_are_spaced
|
34
|
+
assert_match(/amount\n\n\nof space/, @text)
|
35
|
+
end
|
36
|
+
|
37
|
+
# @ and {} should be at-sign-prefixed
|
38
|
+
def test_escaping
|
39
|
+
assert_match(/@@ and @\{@\} should be at-sign-prefixed/)
|
40
|
+
end
|
41
|
+
|
42
|
+
# This tests that *bold* and <b>bold me</b> become @strong{bolded}
|
43
|
+
def test_bold
|
44
|
+
# Seems like a limitation of the Info format: @strong{bold}
|
45
|
+
# becomes *bold* when read in Info or M-x info. highly lame!
|
46
|
+
assert_match(/@strong\{bold\}/)
|
47
|
+
assert_match(/@strong\{bold me\}/)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Test that _italics_ and <em>italicize me</em> becomes @emph{italicized}
|
51
|
+
def test_italics
|
52
|
+
assert_match(/@emph\{italics\}/)
|
53
|
+
assert_match(/@emph\{italicize me\}/)
|
54
|
+
end
|
55
|
+
|
56
|
+
# And that typewriter +text+ and <tt>typewriter me</tt> becomes @code{typewriter}
|
57
|
+
def test_tt
|
58
|
+
assert_match(/@code\{text\}/)
|
59
|
+
assert_match(/@code\{typewriter me\}/)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Check that
|
63
|
+
# anything indented is
|
64
|
+
# verbatim @verb{|foo bar baz|}
|
65
|
+
def test_literal_code
|
66
|
+
assert_match("@verb{| anything indented is
|
67
|
+
verbatim @@verb@{|foo bar baz|@}
|
68
|
+
|}")
|
69
|
+
end
|
70
|
+
|
71
|
+
# = Huge heading should be a @majorheading
|
72
|
+
# == There is also @chapheading
|
73
|
+
# === Everything deeper becomes a regular @heading
|
74
|
+
# ====== Regardless of its nesting level
|
75
|
+
def test_headings
|
76
|
+
assert_match(/@majorheading\{Huge heading should be a @@majorheading\}/)
|
77
|
+
assert_match(/@chapheading\{There is also @@chapheading\}/)
|
78
|
+
assert_match(/@heading\{Everything deeper becomes a regular @@heading\}/)
|
79
|
+
assert_match(/@heading\{Regardless of its nesting level\}/)
|
80
|
+
end
|
81
|
+
|
82
|
+
# * list item
|
83
|
+
# * list item2
|
84
|
+
#
|
85
|
+
# with a paragraph in between
|
86
|
+
#
|
87
|
+
# - hyphen lists
|
88
|
+
# - are also allowed
|
89
|
+
# and items may flow over lines
|
90
|
+
def test_bullet_lists
|
91
|
+
assert_match("@itemize @bullet
|
92
|
+
@item
|
93
|
+
list item
|
94
|
+
@item
|
95
|
+
list item2
|
96
|
+
@end itemize")
|
97
|
+
assert_match("@itemize @bullet
|
98
|
+
@item
|
99
|
+
hyphen lists
|
100
|
+
@item
|
101
|
+
are also allowed and items may flow over lines
|
102
|
+
@end itemize")
|
103
|
+
end
|
104
|
+
|
105
|
+
# 2. numbered lists
|
106
|
+
# 8. are made by
|
107
|
+
# 9. a digit followed by a period
|
108
|
+
def test_numbered_lists
|
109
|
+
end
|
110
|
+
|
111
|
+
# a. alpha lists
|
112
|
+
# b. should be parsed too
|
113
|
+
def test_alpha_lists
|
114
|
+
end
|
115
|
+
|
116
|
+
# [cat] small domestic animal
|
117
|
+
# [+cat+] command to copy standard input
|
118
|
+
# to standard output
|
119
|
+
def test_labelled_lists
|
120
|
+
end
|
121
|
+
|
122
|
+
# * First item.
|
123
|
+
# * Inner item.
|
124
|
+
# * Second inner item.
|
125
|
+
# * Second outer item.
|
126
|
+
def test_nested_lists
|
127
|
+
assert_match("@itemize @bullet
|
128
|
+
@item
|
129
|
+
First item.
|
130
|
+
@itemize @bullet
|
131
|
+
@item
|
132
|
+
Inner item.
|
133
|
+
@item
|
134
|
+
Second inner item.
|
135
|
+
@end itemize
|
136
|
+
@item
|
137
|
+
Second outer item.
|
138
|
+
@end itemize")
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_internal_hyperlinks
|
142
|
+
# be sure to test multi-word hyperlinks as well.
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_hyperlink_targets
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_web_links
|
149
|
+
# An example of the two-argument form: The official
|
150
|
+
# @uref{ftp://ftp.gnu.org/gnu, GNU ftp site} holds programs and texts.
|
151
|
+
|
152
|
+
# produces:
|
153
|
+
# The official GNU ftp site (ftp://ftp.gnu.org/gnu)
|
154
|
+
# holds programs and texts.
|
155
|
+
# and the HTML output is this:
|
156
|
+
# The official <a href="ftp://ftp.gnu.org/gnu">GNU ftp site</a>
|
157
|
+
# holds programs and texts.
|
158
|
+
end
|
159
|
+
|
160
|
+
# three or more hyphens
|
161
|
+
# ----
|
162
|
+
# should produce a horizontal rule
|
163
|
+
def test_horizontal_rule
|
164
|
+
# gah; not sure texinfo supports horizontal rules
|
165
|
+
end
|
166
|
+
|
167
|
+
private
|
168
|
+
|
169
|
+
# We don't want the whole string inspected if we pass our own
|
170
|
+
# message in.
|
171
|
+
def assert_match(regex, string = @text,
|
172
|
+
message = "Didn't find #{regex.inspect} in #{string}.")
|
173
|
+
assert string[regex] #, message
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'tmpdir'
|
5
|
+
|
6
|
+
require 'rdoc/generator/texinfo'
|
7
|
+
|
8
|
+
# give us access to check this stuff before it's rendered
|
9
|
+
class RDoc::Generator::Texinfo; attr_reader :files, :classes; end
|
10
|
+
class RDoc::RDoc; attr_reader :options; attr_reader :gen; end
|
11
|
+
|
12
|
+
class TestRdocInfoSections < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@output_dir = File.join Dir.tmpdir, "test_rdoc_info_sections_#{$$}"
|
16
|
+
@output_file = File.join @output_dir, 'rdoc.texinfo'
|
17
|
+
|
18
|
+
@input_file = Tempfile.new 'my_file.rb'
|
19
|
+
|
20
|
+
open @input_file.path, 'w' do |io|
|
21
|
+
io.write TEST_DOC
|
22
|
+
end
|
23
|
+
|
24
|
+
RDoc::Parser.alias_extension '.rb', File.extname(@input_file.path)
|
25
|
+
|
26
|
+
@rdoc = RDoc::RDoc.new
|
27
|
+
@rdoc.document(['--fmt=texinfo', '--quiet', @input_file.path,
|
28
|
+
"--op=#{@output_dir}"])
|
29
|
+
|
30
|
+
@text = File.read @output_file
|
31
|
+
end
|
32
|
+
|
33
|
+
def teardown
|
34
|
+
@input_file.close
|
35
|
+
FileUtils.rm_rf @output_dir
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_output_exists
|
39
|
+
assert ! @text.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_each_class_has_a_chapter
|
43
|
+
assert_section "Class MyClass", '@chapter'
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_class_descriptions_are_given
|
47
|
+
assert_match(/Documentation for my class/, @text.gsub("\n", ' '))
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_included_modules_are_given
|
51
|
+
assert_match(/Includes.* MyModule/m, @text)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_class_methods_are_given
|
55
|
+
assert_match(/my_class_method\(my_first_argument\)/, @text)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_classes_instance_methods_are_given
|
59
|
+
assert_section 'Class MyClass#my_method'
|
60
|
+
assert_match(/my_method\(my_first_argument\)/, @text)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_each_module_has_a_chapter
|
64
|
+
assert_section 'MyModule', '@chapter'
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_methods_are_shown_only_once
|
68
|
+
methods = @rdoc.gen.classes.map do |c|
|
69
|
+
c.methods.map do |m|
|
70
|
+
c.name + '#' + m.name
|
71
|
+
end
|
72
|
+
end.flatten
|
73
|
+
|
74
|
+
assert_equal methods, methods.uniq
|
75
|
+
end
|
76
|
+
|
77
|
+
# if system "makeinfo --version > /dev/null"
|
78
|
+
# def test_compiles_to_info
|
79
|
+
# makeinfo_output = `cd #{@output_dir} && makeinfo rdoc.texinfo`
|
80
|
+
# assert(File.exist?(File.join(@output_dir, 'rdoc.info')),
|
81
|
+
# "Info file was not compiled: #{makeinfo_output}")
|
82
|
+
# end
|
83
|
+
# end
|
84
|
+
|
85
|
+
# def test_constants_are_documented_somehow
|
86
|
+
# assert_section 'DEFAULT_FILENAME' # what kind of section?
|
87
|
+
# assert_section 'DEFAULT_INFO_FILENAME'
|
88
|
+
# end
|
89
|
+
|
90
|
+
# def test_oh_yeah_dont_forget_files
|
91
|
+
# end
|
92
|
+
|
93
|
+
def assert_section(name, command = '@section')
|
94
|
+
assert_match Regexp.new("^#{command}.*#{Regexp.escape name}"), @text, "Could not find a #{command} #{name}"
|
95
|
+
end
|
96
|
+
|
97
|
+
TEST_DOC = <<-DOC
|
98
|
+
##
|
99
|
+
# Documentation for my module
|
100
|
+
|
101
|
+
module MyModule
|
102
|
+
|
103
|
+
##
|
104
|
+
# Documentation for my included method
|
105
|
+
|
106
|
+
def my_included_method() end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# Documentation for my class
|
112
|
+
|
113
|
+
class MyClass
|
114
|
+
|
115
|
+
include MyModule
|
116
|
+
|
117
|
+
##
|
118
|
+
# Documentation for my constant
|
119
|
+
|
120
|
+
MY_CONSTANT = 'my value'
|
121
|
+
|
122
|
+
##
|
123
|
+
# Documentation for my class method
|
124
|
+
|
125
|
+
def self.my_class_method(my_first_argument) end
|
126
|
+
|
127
|
+
##
|
128
|
+
# Documentation for my method
|
129
|
+
|
130
|
+
def my_method(my_first_argument) end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
DOC
|
135
|
+
|
136
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rdoc/markup'
|
3
|
+
require 'rdoc/markup/to_html'
|
4
|
+
|
5
|
+
class TestRdocMarkupToHtml < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@am = RDoc::Markup::AttributeManager.new
|
9
|
+
@th = RDoc::Markup::ToHtml.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_tt_formatting
|
13
|
+
assert_equal "<p>\n<tt>--</tt> — <tt>(c)</tt> ©\n</p>\n",
|
14
|
+
util_format("<tt>--</tt> -- <tt>(c)</tt> (c)")
|
15
|
+
assert_equal "<p>\n<b>—</b>\n</p>\n", util_format("<b>--</b>")
|
16
|
+
end
|
17
|
+
|
18
|
+
def util_fragment(text)
|
19
|
+
RDoc::Markup::Fragment.new 0, nil, nil, text
|
20
|
+
end
|
21
|
+
|
22
|
+
def util_format(text)
|
23
|
+
fragment = util_fragment text
|
24
|
+
|
25
|
+
@th.start_accepting
|
26
|
+
@th.accept_paragraph @am, fragment
|
27
|
+
@th.end_accepting
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|