rdoc 3.12.2 → 4.0.0.preview2
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.
- checksums.yaml +6 -6
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +3 -2
- data/DEVELOPERS.rdoc +53 -0
- data/History.rdoc +159 -25
- data/LEGAL.rdoc +12 -0
- data/Manifest.txt +56 -3
- data/README.rdoc +87 -19
- data/Rakefile +11 -2
- data/TODO.rdoc +20 -13
- data/bin/rdoc +4 -0
- data/lib/gauntlet_rdoc.rb +1 -1
- data/lib/rdoc.rb +32 -71
- data/lib/rdoc/any_method.rb +75 -21
- data/lib/rdoc/attr.rb +49 -10
- data/lib/rdoc/class_module.rb +182 -32
- data/lib/rdoc/code_object.rb +54 -12
- data/lib/rdoc/comment.rb +8 -1
- data/lib/rdoc/constant.rb +100 -6
- data/lib/rdoc/context.rb +93 -41
- data/lib/rdoc/context/section.rb +143 -28
- data/lib/rdoc/cross_reference.rb +58 -50
- data/lib/rdoc/encoding.rb +34 -29
- data/lib/rdoc/erb_partial.rb +18 -0
- data/lib/rdoc/extend.rb +117 -0
- data/lib/rdoc/generator.rb +11 -6
- data/lib/rdoc/generator/darkfish.rb +250 -62
- data/lib/rdoc/generator/json_index.rb +20 -12
- data/lib/rdoc/generator/markup.rb +10 -12
- data/lib/rdoc/generator/ri.rb +7 -60
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
- data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
- data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/include.rb +12 -3
- data/lib/rdoc/markdown.kpeg +1186 -0
- data/lib/rdoc/markdown.rb +16336 -0
- data/lib/rdoc/markdown/entities.rb +2128 -0
- data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
- data/lib/rdoc/markdown/literals_1_8.rb +454 -0
- data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
- data/lib/rdoc/markdown/literals_1_9.rb +417 -0
- data/lib/rdoc/markup.rb +69 -10
- data/lib/rdoc/markup/attr_changer.rb +2 -5
- data/lib/rdoc/markup/attribute_manager.rb +23 -14
- data/lib/rdoc/markup/attributes.rb +70 -0
- data/lib/rdoc/markup/block_quote.rb +14 -0
- data/lib/rdoc/markup/document.rb +20 -4
- data/lib/rdoc/markup/formatter.rb +17 -6
- data/lib/rdoc/markup/formatter_test_case.rb +93 -24
- data/lib/rdoc/markup/hard_break.rb +31 -0
- data/lib/rdoc/markup/heading.rb +1 -1
- data/lib/rdoc/markup/indented_paragraph.rb +14 -0
- data/lib/rdoc/markup/list.rb +23 -4
- data/lib/rdoc/markup/list_item.rb +17 -4
- data/lib/rdoc/markup/paragraph.rb +14 -0
- data/lib/rdoc/markup/parser.rb +107 -60
- data/lib/rdoc/markup/raw.rb +4 -4
- data/lib/rdoc/markup/special.rb +3 -3
- data/lib/rdoc/markup/to_ansi.rb +7 -1
- data/lib/rdoc/markup/to_html.rb +42 -14
- data/lib/rdoc/markup/to_html_crossref.rb +10 -9
- data/lib/rdoc/markup/to_html_snippet.rb +20 -4
- data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
- data/lib/rdoc/markup/to_label.rb +20 -1
- data/lib/rdoc/markup/to_markdown.rb +134 -0
- data/lib/rdoc/markup/to_rdoc.rb +36 -5
- data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
- data/lib/rdoc/markup/to_tt_only.rb +11 -2
- data/lib/rdoc/markup/verbatim.rb +19 -0
- data/lib/rdoc/method_attr.rb +33 -19
- data/lib/rdoc/normal_class.rb +26 -7
- data/lib/rdoc/normal_module.rb +10 -5
- data/lib/rdoc/options.rb +95 -21
- data/lib/rdoc/parser.rb +6 -2
- data/lib/rdoc/parser/c.rb +212 -97
- data/lib/rdoc/parser/markdown.rb +23 -0
- data/lib/rdoc/parser/ruby.rb +115 -35
- data/lib/rdoc/parser/ruby_tools.rb +8 -3
- data/lib/rdoc/rd.rb +8 -4
- data/lib/rdoc/rd/block_parser.rb +1 -1
- data/lib/rdoc/rd/block_parser.ry +1 -1
- data/lib/rdoc/rdoc.rb +45 -21
- data/lib/rdoc/ri/driver.rb +322 -76
- data/lib/rdoc/ri/paths.rb +90 -31
- data/lib/rdoc/ri/store.rb +2 -353
- data/lib/rdoc/ruby_lex.rb +5 -21
- data/lib/rdoc/ruby_token.rb +2 -3
- data/lib/rdoc/rubygems_hook.rb +21 -9
- data/lib/rdoc/servlet.rb +302 -0
- data/lib/rdoc/stats.rb +28 -20
- data/lib/rdoc/store.rb +881 -0
- data/lib/rdoc/task.rb +2 -1
- data/lib/rdoc/test_case.rb +103 -1
- data/lib/rdoc/text.rb +5 -4
- data/lib/rdoc/tom_doc.rb +17 -16
- data/lib/rdoc/top_level.rb +43 -285
- data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
- data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
- data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
- data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
- data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
- data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
- data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
- data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
- data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
- data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
- data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
- data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
- data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
- data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
- data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
- data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
- data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
- data/test/test_attribute_manager.rb +7 -4
- data/test/test_rdoc_any_method.rb +84 -13
- data/test/test_rdoc_attr.rb +59 -9
- data/test/test_rdoc_class_module.rb +670 -73
- data/test/test_rdoc_code_object.rb +21 -1
- data/test/test_rdoc_comment.rb +1 -1
- data/test/test_rdoc_constant.rb +132 -0
- data/test/test_rdoc_context.rb +84 -18
- data/test/test_rdoc_context_section.rb +99 -15
- data/test/test_rdoc_cross_reference.rb +1 -1
- data/test/test_rdoc_encoding.rb +17 -1
- data/test/test_rdoc_extend.rb +94 -0
- data/test/test_rdoc_generator_darkfish.rb +45 -19
- data/test/test_rdoc_generator_json_index.rb +27 -7
- data/test/test_rdoc_generator_markup.rb +3 -3
- data/test/test_rdoc_generator_ri.rb +11 -9
- data/test/test_rdoc_include.rb +12 -0
- data/test/test_rdoc_markdown.rb +977 -0
- data/test/test_rdoc_markdown_test.rb +1891 -0
- data/test/test_rdoc_markup.rb +1 -1
- data/test/test_rdoc_markup_attribute_manager.rb +2 -2
- data/test/test_rdoc_markup_attributes.rb +39 -0
- data/test/test_rdoc_markup_document.rb +16 -1
- data/test/test_rdoc_markup_formatter.rb +7 -4
- data/test/test_rdoc_markup_hard_break.rb +31 -0
- data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
- data/test/test_rdoc_markup_paragraph.rb +15 -1
- data/test/test_rdoc_markup_parser.rb +152 -89
- data/test/test_rdoc_markup_to_ansi.rb +23 -2
- data/test/test_rdoc_markup_to_bs.rb +24 -0
- data/test/test_rdoc_markup_to_html.rb +50 -19
- data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
- data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
- data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
- data/test/test_rdoc_markup_to_label.rb +63 -1
- data/test/test_rdoc_markup_to_markdown.rb +352 -0
- data/test/test_rdoc_markup_to_rdoc.rb +22 -2
- data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
- data/test/test_rdoc_markup_to_tt_only.rb +20 -0
- data/test/test_rdoc_markup_verbatim.rb +13 -0
- data/test/test_rdoc_method_attr.rb +5 -0
- data/test/test_rdoc_normal_class.rb +24 -5
- data/test/test_rdoc_normal_module.rb +1 -1
- data/test/test_rdoc_options.rb +21 -6
- data/test/test_rdoc_parser.rb +24 -0
- data/test/test_rdoc_parser_c.rb +151 -26
- data/test/test_rdoc_parser_markdown.rb +55 -0
- data/test/test_rdoc_parser_rd.rb +2 -2
- data/test/test_rdoc_parser_ruby.rb +468 -109
- data/test/test_rdoc_parser_simple.rb +2 -2
- data/test/test_rdoc_rd_block_parser.rb +0 -4
- data/test/test_rdoc_rdoc.rb +110 -22
- data/test/test_rdoc_ri_driver.rb +415 -80
- data/test/test_rdoc_ri_paths.rb +122 -13
- data/test/test_rdoc_ruby_lex.rb +5 -61
- data/test/test_rdoc_ruby_token.rb +19 -0
- data/test/test_rdoc_rubygems_hook.rb +64 -43
- data/test/test_rdoc_servlet.rb +429 -0
- data/test/test_rdoc_stats.rb +83 -24
- data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
- data/test/test_rdoc_task.rb +2 -2
- data/test/test_rdoc_text.rb +37 -11
- data/test/test_rdoc_tom_doc.rb +59 -62
- data/test/test_rdoc_top_level.rb +71 -113
- data/test/xref_test_case.rb +7 -9
- metadata +122 -39
- metadata.gz.sig +0 -0
- data/CVE-2013-0256.rdoc +0 -49
- data/lib/rdoc/markup/attribute.rb +0 -51
data/lib/rdoc/task.rb
CHANGED
@@ -128,7 +128,8 @@ class RDoc::Task < Rake::TaskLib
|
|
128
128
|
attr_accessor :template
|
129
129
|
|
130
130
|
##
|
131
|
-
# Name of format generator (
|
131
|
+
# Name of format generator (<tt>--format<tt>) used by rdoc. (defaults to
|
132
|
+
# rdoc's default)
|
132
133
|
|
133
134
|
attr_accessor :generator
|
134
135
|
|
data/lib/rdoc/test_case.rb
CHANGED
@@ -33,12 +33,37 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
|
|
33
33
|
|
34
34
|
@top_level = nil
|
35
35
|
|
36
|
+
@have_encoding = Object.const_defined? :Encoding
|
37
|
+
|
36
38
|
@RM = RDoc::Markup
|
37
39
|
|
38
|
-
RDoc::RDoc.reset
|
39
40
|
RDoc::Markup::PreProcess.reset
|
40
41
|
|
41
42
|
@pwd = Dir.pwd
|
43
|
+
|
44
|
+
@store = RDoc::Store.new
|
45
|
+
|
46
|
+
@rdoc = RDoc::RDoc.new
|
47
|
+
@rdoc.store = @store
|
48
|
+
|
49
|
+
g = Object.new
|
50
|
+
def g.class_dir() end
|
51
|
+
def g.file_dir() end
|
52
|
+
@rdoc.generator = g
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Shortcut for RDoc::Markup::BlankLine.new
|
57
|
+
|
58
|
+
def blank_line
|
59
|
+
@RM::BlankLine.new
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Shortcut for RDoc::Markup::BlockQuote.new with +contents+
|
64
|
+
|
65
|
+
def block *contents
|
66
|
+
@RM::BlockQuote.new(*contents)
|
42
67
|
end
|
43
68
|
|
44
69
|
##
|
@@ -49,6 +74,62 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
|
|
49
74
|
RDoc::Comment.new text, top_level
|
50
75
|
end
|
51
76
|
|
77
|
+
##
|
78
|
+
# Shortcut for RDoc::Markup::Document.new with +contents+
|
79
|
+
|
80
|
+
def doc *contents
|
81
|
+
@RM::Document.new(*contents)
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Shortcut for RDoc::Markup::HardBreak.new
|
86
|
+
|
87
|
+
def hard_break
|
88
|
+
@RM::HardBreak.new
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# Shortcut for RDoc::Markup::Heading.new with +level+ and +text+
|
93
|
+
|
94
|
+
def head level, text
|
95
|
+
@RM::Heading.new level, text
|
96
|
+
end
|
97
|
+
|
98
|
+
##
|
99
|
+
# Shortcut for RDoc::Markup::ListItem.new with +label+ and +parts+
|
100
|
+
|
101
|
+
def item label = nil, *parts
|
102
|
+
@RM::ListItem.new label, *parts
|
103
|
+
end
|
104
|
+
|
105
|
+
##
|
106
|
+
# Shortcut for RDoc::Markup::List.new with +type+ and +items+
|
107
|
+
|
108
|
+
def list type = nil, *items
|
109
|
+
@RM::List.new type, *items
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# Shortcut for RDoc::Markup::Paragraph.new with +contents+
|
114
|
+
|
115
|
+
def para *a
|
116
|
+
@RM::Paragraph.new(*a)
|
117
|
+
end
|
118
|
+
|
119
|
+
##
|
120
|
+
# Shortcut for RDoc::Markup::Rule.new with +weight+
|
121
|
+
|
122
|
+
def rule weight
|
123
|
+
@RM::Rule.new weight
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Shortcut for RDoc::Markup::Raw.new with +contents+
|
128
|
+
|
129
|
+
def raw *contents
|
130
|
+
@RM::Raw.new(*contents)
|
131
|
+
end
|
132
|
+
|
52
133
|
##
|
53
134
|
# Creates a temporary directory changes the current directory to it for the
|
54
135
|
# duration of the block.
|
@@ -65,6 +146,27 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
|
|
65
146
|
end
|
66
147
|
end
|
67
148
|
|
149
|
+
##
|
150
|
+
# Shortcut for RDoc::Markup::Verbatim.new with +parts+
|
151
|
+
|
152
|
+
def verb *parts
|
153
|
+
@RM::Verbatim.new(*parts)
|
154
|
+
end
|
155
|
+
|
156
|
+
##
|
157
|
+
# run capture_io with setting $VERBOSE = true
|
158
|
+
|
159
|
+
def verbose_capture_io
|
160
|
+
capture_io do
|
161
|
+
begin
|
162
|
+
orig_verbose = $VERBOSE
|
163
|
+
$VERBOSE = true
|
164
|
+
yield
|
165
|
+
ensure
|
166
|
+
$VERBOSE = orig_verbose
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
68
170
|
end
|
69
171
|
|
70
172
|
# This hack allows autoload to work when Dir.pwd is changed for Ruby 1.8 since
|
data/lib/rdoc/text.rb
CHANGED
@@ -25,9 +25,10 @@ module RDoc::Text
|
|
25
25
|
# unknown, "rdoc" format is used.
|
26
26
|
|
27
27
|
MARKUP_FORMAT = {
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
28
|
+
'markdown' => RDoc::Markdown,
|
29
|
+
'rdoc' => RDoc::Markup,
|
30
|
+
'rd' => RDoc::RD,
|
31
|
+
'tomdoc' => RDoc::TomDoc,
|
31
32
|
}
|
32
33
|
|
33
34
|
MARKUP_FORMAT.default = RDoc::Markup
|
@@ -67,7 +68,7 @@ module RDoc::Text
|
|
67
68
|
expanded = []
|
68
69
|
|
69
70
|
text.each_line do |line|
|
70
|
-
line.gsub!(/^(
|
71
|
+
line.gsub!(/^((?:.{8})*?)([^\t\r\n]{0,7})\t/) do
|
71
72
|
r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
|
72
73
|
r.force_encoding text.encoding if Object.const_defined? :Encoding
|
73
74
|
r
|
data/lib/rdoc/tom_doc.rb
CHANGED
@@ -10,6 +10,10 @@
|
|
10
10
|
#
|
11
11
|
# https://github.com/mojombo/tomdoc/blob/master/tomdoc.md
|
12
12
|
#
|
13
|
+
# To choose TomDoc as your only default format see RDoc::Options@Saved+Options
|
14
|
+
# for instructions on setting up a <code>.rdoc_options</code> file to store
|
15
|
+
# your project default.
|
16
|
+
#
|
13
17
|
# There are a few differences between this parser and the specification. A
|
14
18
|
# best-effort was made to follow the specification as closely as possible but
|
15
19
|
# some choices to deviate were made.
|
@@ -195,33 +199,30 @@ class RDoc::TomDoc < RDoc::Markup::Parser
|
|
195
199
|
def tokenize text
|
196
200
|
text.sub!(/\A(Public|Internal|Deprecated):\s+/, '')
|
197
201
|
|
198
|
-
|
199
|
-
|
200
|
-
@line = 0
|
201
|
-
@line_pos = 0
|
202
|
+
setup_scanner text
|
202
203
|
|
203
|
-
until s.eos? do
|
204
|
-
pos = s.pos
|
204
|
+
until @s.eos? do
|
205
|
+
pos = @s.pos
|
205
206
|
|
206
207
|
# leading spaces will be reflected by the column of the next token
|
207
208
|
# the only thing we loose are trailing spaces at the end of the file
|
208
|
-
next if s.scan(/ +/)
|
209
|
+
next if @s.scan(/ +/)
|
209
210
|
|
210
211
|
@tokens << case
|
211
|
-
when s.scan(/\r?\n/) then
|
212
|
-
token = [:NEWLINE, s.matched, *token_pos(pos)]
|
213
|
-
@line_pos = s.pos
|
212
|
+
when @s.scan(/\r?\n/) then
|
213
|
+
token = [:NEWLINE, @s.matched, *token_pos(pos)]
|
214
|
+
@line_pos = char_pos @s.pos
|
214
215
|
@line += 1
|
215
216
|
token
|
216
|
-
when s.scan(/(Examples|Signature)$/) then
|
217
|
+
when @s.scan(/(Examples|Signature)$/) then
|
217
218
|
@tokens << [:HEADER, 3, *token_pos(pos)]
|
218
219
|
|
219
|
-
[:TEXT, s[1], *token_pos(pos)]
|
220
|
-
when s.scan(/([:\w]\w*)[ ]+- /) then
|
221
|
-
[:NOTE, s[1], *token_pos(pos)]
|
220
|
+
[:TEXT, @s[1], *token_pos(pos)]
|
221
|
+
when @s.scan(/([:\w]\w*)[ ]+- /) then
|
222
|
+
[:NOTE, @s[1], *token_pos(pos)]
|
222
223
|
else
|
223
|
-
s.scan(/.*/)
|
224
|
-
[:TEXT, s.matched.sub(/\r$/, ''), *token_pos(pos)]
|
224
|
+
@s.scan(/.*/)
|
225
|
+
[:TEXT, @s.matched.sub(/\r$/, ''), *token_pos(pos)]
|
225
226
|
end
|
226
227
|
end
|
227
228
|
|
data/lib/rdoc/top_level.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
|
4
4
|
class RDoc::TopLevel < RDoc::Context
|
5
5
|
|
6
|
+
MARSHAL_VERSION = 0 # :nodoc:
|
7
|
+
|
6
8
|
##
|
7
9
|
# This TopLevel's File::Stat struct
|
8
10
|
|
@@ -33,294 +35,27 @@ class RDoc::TopLevel < RDoc::Context
|
|
33
35
|
attr_accessor :parser
|
34
36
|
|
35
37
|
##
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
@all_classes_hash.values
|
40
|
-
end
|
41
|
-
|
42
|
-
##
|
43
|
-
# Returns all classes and modules discovered by RDoc
|
44
|
-
|
45
|
-
def self.all_classes_and_modules
|
46
|
-
@all_classes_hash.values + @all_modules_hash.values
|
47
|
-
end
|
48
|
-
|
49
|
-
##
|
50
|
-
# Hash of all classes known to RDoc
|
51
|
-
|
52
|
-
def self.all_classes_hash
|
53
|
-
@all_classes_hash
|
54
|
-
end
|
55
|
-
|
56
|
-
##
|
57
|
-
# All TopLevels known to RDoc
|
58
|
-
|
59
|
-
def self.all_files
|
60
|
-
@all_files_hash.values
|
61
|
-
end
|
62
|
-
|
63
|
-
##
|
64
|
-
# Hash of all files known to RDoc
|
65
|
-
|
66
|
-
def self.all_files_hash
|
67
|
-
@all_files_hash
|
68
|
-
end
|
69
|
-
|
70
|
-
##
|
71
|
-
# Returns all modules discovered by RDoc
|
72
|
-
|
73
|
-
def self.all_modules
|
74
|
-
all_modules_hash.values
|
75
|
-
end
|
76
|
-
|
77
|
-
##
|
78
|
-
# Hash of all modules known to RDoc
|
79
|
-
|
80
|
-
def self.all_modules_hash
|
81
|
-
@all_modules_hash
|
82
|
-
end
|
83
|
-
|
84
|
-
##
|
85
|
-
# Prepares the RDoc code object tree for use by a generator.
|
86
|
-
#
|
87
|
-
# It finds unique classes/modules defined, and replaces classes/modules that
|
88
|
-
# are aliases for another one by a copy with RDoc::ClassModule#is_alias_for
|
89
|
-
# set.
|
90
|
-
#
|
91
|
-
# It updates the RDoc::ClassModule#constant_aliases attribute of "real"
|
92
|
-
# classes or modules.
|
93
|
-
#
|
94
|
-
# It also completely removes the classes and modules that should be removed
|
95
|
-
# from the documentation and the methods that have a visibility below
|
96
|
-
# +min_visibility+, which is the <tt>--visibility</tt> option.
|
97
|
-
#
|
98
|
-
# See also RDoc::Context#remove_from_documentation?
|
99
|
-
|
100
|
-
def self.complete min_visibility
|
101
|
-
fix_basic_object_inheritance
|
102
|
-
|
103
|
-
# cache included modules before they are removed from the documentation
|
104
|
-
all_classes_and_modules.each { |cm| cm.ancestors }
|
105
|
-
|
106
|
-
remove_nodoc @all_classes_hash
|
107
|
-
remove_nodoc @all_modules_hash
|
108
|
-
|
109
|
-
@unique_classes = find_unique @all_classes_hash
|
110
|
-
@unique_modules = find_unique @all_modules_hash
|
111
|
-
|
112
|
-
unique_classes_and_modules.each do |cm|
|
113
|
-
cm.complete min_visibility
|
114
|
-
end
|
115
|
-
|
116
|
-
@all_files_hash.each_key do |file_name|
|
117
|
-
tl = @all_files_hash[file_name]
|
118
|
-
|
119
|
-
unless tl.text? then
|
120
|
-
tl.modules_hash.clear
|
121
|
-
tl.classes_hash.clear
|
122
|
-
|
123
|
-
tl.classes_or_modules.each do |cm|
|
124
|
-
name = cm.full_name
|
125
|
-
if cm.type == 'class' then
|
126
|
-
tl.classes_hash[name] = cm if @all_classes_hash[name]
|
127
|
-
else
|
128
|
-
tl.modules_hash[name] = cm if @all_modules_hash[name]
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
##
|
136
|
-
# Finds the class with +name+ in all discovered classes
|
137
|
-
|
138
|
-
def self.find_class_named(name)
|
139
|
-
@all_classes_hash[name]
|
140
|
-
end
|
141
|
-
|
142
|
-
##
|
143
|
-
# Finds the class with +name+ starting in namespace +from+
|
144
|
-
|
145
|
-
def self.find_class_named_from name, from
|
146
|
-
from = find_class_named from unless RDoc::Context === from
|
147
|
-
|
148
|
-
until RDoc::TopLevel === from do
|
149
|
-
return nil unless from
|
150
|
-
|
151
|
-
klass = from.find_class_named name
|
152
|
-
return klass if klass
|
153
|
-
|
154
|
-
from = from.parent
|
155
|
-
end
|
156
|
-
|
157
|
-
find_class_named name
|
158
|
-
end
|
159
|
-
|
160
|
-
##
|
161
|
-
# Finds the class or module with +name+
|
162
|
-
|
163
|
-
def self.find_class_or_module(name)
|
164
|
-
name = $' if name =~ /^::/
|
165
|
-
RDoc::TopLevel.classes_hash[name] || RDoc::TopLevel.modules_hash[name]
|
166
|
-
end
|
167
|
-
|
168
|
-
##
|
169
|
-
# Finds the file with +name+ in all discovered files
|
170
|
-
|
171
|
-
def self.find_file_named(name)
|
172
|
-
@all_files_hash[name]
|
173
|
-
end
|
174
|
-
|
175
|
-
##
|
176
|
-
# Finds the module with +name+ in all discovered modules
|
177
|
-
|
178
|
-
def self.find_module_named(name)
|
179
|
-
modules_hash[name]
|
180
|
-
end
|
181
|
-
|
182
|
-
##
|
183
|
-
# Finds unique classes/modules defined in +all_hash+,
|
184
|
-
# and returns them as an array. Performs the alias
|
185
|
-
# updates in +all_hash+: see ::complete.
|
186
|
-
#--
|
187
|
-
# TODO aliases should be registered by Context#add_module_alias
|
188
|
-
|
189
|
-
def self.find_unique(all_hash)
|
190
|
-
unique = []
|
191
|
-
|
192
|
-
all_hash.each_pair do |full_name, cm|
|
193
|
-
unique << cm if full_name == cm.full_name
|
194
|
-
end
|
195
|
-
|
196
|
-
unique
|
197
|
-
end
|
198
|
-
|
199
|
-
##
|
200
|
-
# Fixes the erroneous <tt>BasicObject < Object</tt> in 1.9.
|
201
|
-
#
|
202
|
-
# Because we assumed all classes without a stated superclass
|
203
|
-
# inherit from Object, we have the above wrong inheritance.
|
204
|
-
#
|
205
|
-
# We fix BasicObject right away if we are running in a Ruby
|
206
|
-
# version >= 1.9. If not, we may be documenting 1.9 source
|
207
|
-
# while running under 1.8: we search the files of BasicObject
|
208
|
-
# for "object.c", and fix the inheritance if we find it.
|
209
|
-
|
210
|
-
def self.fix_basic_object_inheritance
|
211
|
-
basic = all_classes_hash['BasicObject']
|
212
|
-
return unless basic
|
213
|
-
if RUBY_VERSION >= '1.9'
|
214
|
-
basic.superclass = nil
|
215
|
-
elsif basic.in_files.any? { |f| File.basename(f.full_name) == 'object.c' }
|
216
|
-
basic.superclass = nil
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
##
|
221
|
-
# Creates a new RDoc::TopLevel with +file_name+ only if one with the same
|
222
|
-
# name does not exist in all_files.
|
223
|
-
|
224
|
-
def self.new file_name
|
225
|
-
if top_level = @all_files_hash[file_name] then
|
226
|
-
top_level
|
227
|
-
else
|
228
|
-
top_level = super
|
229
|
-
@all_files_hash[file_name] = top_level
|
230
|
-
top_level
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
##
|
235
|
-
# Returns the RDoc::TopLevel that has the given +name+
|
236
|
-
|
237
|
-
def self.page name
|
238
|
-
@all_files_hash.each_value.find do |file|
|
239
|
-
file.text? and file.page_name == name
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
##
|
244
|
-
# Removes from +all_hash+ the contexts that are nodoc or have no content.
|
245
|
-
#
|
246
|
-
# See RDoc::Context#remove_from_documentation?
|
247
|
-
|
248
|
-
def self.remove_nodoc(all_hash)
|
249
|
-
all_hash.keys.each do |name|
|
250
|
-
context = all_hash[name]
|
251
|
-
all_hash.delete(name) if context.remove_from_documentation?
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
##
|
256
|
-
# Empties RDoc of stored class, module and file information
|
257
|
-
|
258
|
-
def self.reset
|
259
|
-
@all_classes_hash = {}
|
260
|
-
@all_modules_hash = {}
|
261
|
-
@all_files_hash = {}
|
262
|
-
end
|
263
|
-
|
264
|
-
##
|
265
|
-
# Returns the unique classes discovered by RDoc.
|
266
|
-
#
|
267
|
-
# ::complete must have been called prior to using this method.
|
38
|
+
# Creates a new TopLevel for the file at +absolute_name+. If documentation
|
39
|
+
# is being generated outside the source dir +relative_name+ is relative to
|
40
|
+
# the source directory.
|
268
41
|
|
269
|
-
def
|
270
|
-
@unique_classes
|
271
|
-
end
|
272
|
-
|
273
|
-
##
|
274
|
-
# Returns the unique classes and modules discovered by RDoc.
|
275
|
-
# ::complete must have been called prior to using this method.
|
276
|
-
|
277
|
-
def self.unique_classes_and_modules
|
278
|
-
@unique_classes + @unique_modules
|
279
|
-
end
|
280
|
-
|
281
|
-
##
|
282
|
-
# Returns the unique modules discovered by RDoc.
|
283
|
-
# ::complete must have been called prior to using this method.
|
284
|
-
|
285
|
-
def self.unique_modules
|
286
|
-
@unique_modules
|
287
|
-
end
|
288
|
-
|
289
|
-
class << self
|
290
|
-
alias classes all_classes
|
291
|
-
alias classes_hash all_classes_hash
|
292
|
-
|
293
|
-
alias files all_files
|
294
|
-
alias files_hash all_files_hash
|
295
|
-
|
296
|
-
alias modules all_modules
|
297
|
-
alias modules_hash all_modules_hash
|
298
|
-
end
|
299
|
-
|
300
|
-
reset
|
301
|
-
|
302
|
-
##
|
303
|
-
# Creates a new TopLevel for +file_name+
|
304
|
-
|
305
|
-
def initialize(file_name)
|
42
|
+
def initialize absolute_name, relative_name = absolute_name
|
306
43
|
super()
|
307
44
|
@name = nil
|
308
|
-
@
|
309
|
-
@
|
310
|
-
@file_stat = File.stat(
|
45
|
+
@absolute_name = absolute_name
|
46
|
+
@relative_name = relative_name
|
47
|
+
@file_stat = File.stat(absolute_name) rescue nil # HACK for testing
|
311
48
|
@diagram = nil
|
312
49
|
@parser = nil
|
313
50
|
|
314
51
|
@classes_or_modules = []
|
315
|
-
|
316
|
-
RDoc::TopLevel.files_hash[file_name] = self
|
317
52
|
end
|
318
53
|
|
319
54
|
##
|
320
|
-
# An RDoc::TopLevel is equal to another with the same
|
55
|
+
# An RDoc::TopLevel is equal to another with the same relative_name
|
321
56
|
|
322
57
|
def == other
|
323
|
-
self.class === other and @
|
58
|
+
self.class === other and @relative_name == other.relative_name
|
324
59
|
end
|
325
60
|
|
326
61
|
alias eql? ==
|
@@ -373,7 +108,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
373
108
|
# Base name of this file
|
374
109
|
|
375
110
|
def base_name
|
376
|
-
File.basename @
|
111
|
+
File.basename @relative_name
|
377
112
|
end
|
378
113
|
|
379
114
|
alias name base_name
|
@@ -393,7 +128,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
393
128
|
# ones of this instance?
|
394
129
|
|
395
130
|
def find_class_or_module name
|
396
|
-
|
131
|
+
@store.find_class_or_module name
|
397
132
|
end
|
398
133
|
|
399
134
|
##
|
@@ -419,10 +154,10 @@ class RDoc::TopLevel < RDoc::Context
|
|
419
154
|
|
420
155
|
##
|
421
156
|
# An RDoc::TopLevel has the same hash as another with the same
|
422
|
-
#
|
157
|
+
# relative_name
|
423
158
|
|
424
159
|
def hash
|
425
|
-
@
|
160
|
+
@relative_name.hash
|
426
161
|
end
|
427
162
|
|
428
163
|
##
|
@@ -450,6 +185,29 @@ class RDoc::TopLevel < RDoc::Context
|
|
450
185
|
@file_stat ? file_stat.mtime : nil
|
451
186
|
end
|
452
187
|
|
188
|
+
##
|
189
|
+
# Dumps this TopLevel for use by ri. See also #marshal_load
|
190
|
+
def marshal_dump
|
191
|
+
[
|
192
|
+
MARSHAL_VERSION,
|
193
|
+
@relative_name,
|
194
|
+
@parser,
|
195
|
+
parse(@comment),
|
196
|
+
]
|
197
|
+
end
|
198
|
+
|
199
|
+
##
|
200
|
+
# Loads this TopLevel from +array+.
|
201
|
+
|
202
|
+
def marshal_load array # :nodoc:
|
203
|
+
initialize array[1]
|
204
|
+
|
205
|
+
@parser = array[2]
|
206
|
+
@comment = array[3]
|
207
|
+
|
208
|
+
@file_stat = nil
|
209
|
+
end
|
210
|
+
|
453
211
|
##
|
454
212
|
# Returns the NormalClass "Object", creating it if not found.
|
455
213
|
#
|
@@ -457,7 +215,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
457
215
|
|
458
216
|
def object_class
|
459
217
|
@object_class ||= begin
|
460
|
-
oc =
|
218
|
+
oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object')
|
461
219
|
oc.record_location self
|
462
220
|
oc
|
463
221
|
end
|
@@ -467,17 +225,17 @@ class RDoc::TopLevel < RDoc::Context
|
|
467
225
|
# Base name of this file without the extension
|
468
226
|
|
469
227
|
def page_name
|
470
|
-
basename = File.basename @
|
228
|
+
basename = File.basename @relative_name
|
471
229
|
basename =~ /\.[^.]*$/
|
472
230
|
|
473
231
|
$` || basename
|
474
232
|
end
|
475
233
|
|
476
234
|
##
|
477
|
-
# Path to this file
|
235
|
+
# Path to this file for use with HTML generator output.
|
478
236
|
|
479
237
|
def path
|
480
|
-
http_url
|
238
|
+
http_url @store.rdoc.generator.file_dir
|
481
239
|
end
|
482
240
|
|
483
241
|
def pretty_print q # :nodoc:
|
@@ -486,7 +244,7 @@ class RDoc::TopLevel < RDoc::Context
|
|
486
244
|
q.breakable
|
487
245
|
|
488
246
|
items = @modules.map { |n,m| m }
|
489
|
-
items.
|
247
|
+
items.concat @modules.map { |n,c| c }
|
490
248
|
q.seplist items do |mod| q.pp mod end
|
491
249
|
end
|
492
250
|
end
|