rdoc 5.1.0 → 6.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CONTRIBUTING.rdoc +5 -6
- data/ExampleMarkdown.md +2 -0
- data/ExampleRDoc.rdoc +2 -0
- data/History.rdoc +68 -66
- data/LEGAL.rdoc +1 -1
- data/LICENSE.rdoc +2 -0
- data/README.rdoc +18 -6
- data/RI.md +842 -0
- data/TODO.rdoc +8 -7
- data/exe/rdoc +0 -1
- data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -12
- data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +1 -2
- data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +83 -26
- data/lib/rdoc/{attr.rb → code_object/attr.rb} +5 -9
- data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +112 -24
- data/lib/rdoc/{constant.rb → code_object/constant.rb} +4 -5
- data/lib/rdoc/{context → code_object/context}/section.rb +13 -83
- data/lib/rdoc/{context.rb → code_object/context.rb} +69 -70
- data/lib/rdoc/{extend.rb → code_object/extend.rb} +1 -2
- data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +1 -2
- data/lib/rdoc/{include.rb → code_object/include.rb} +1 -2
- data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +1 -2
- data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +22 -31
- data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +1 -2
- data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +4 -5
- data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
- data/lib/rdoc/{require.rb → code_object/require.rb} +2 -3
- data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +6 -2
- data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +22 -32
- data/lib/rdoc/code_object.rb +8 -41
- data/lib/rdoc/code_objects.rb +2 -3
- data/lib/rdoc/comment.rb +48 -41
- data/lib/rdoc/cross_reference.rb +77 -33
- data/lib/rdoc/encoding.rb +50 -38
- data/lib/rdoc/erb_partial.rb +2 -3
- data/lib/rdoc/erbio.rb +4 -5
- data/lib/rdoc/generator/darkfish.rb +178 -125
- data/lib/rdoc/generator/json_index.rb +9 -22
- data/lib/rdoc/generator/markup.rb +6 -17
- data/lib/rdoc/generator/pot/message_extractor.rb +4 -4
- data/lib/rdoc/generator/pot/po.rb +3 -3
- data/lib/rdoc/generator/pot/po_entry.rb +12 -12
- data/lib/rdoc/generator/pot.rb +4 -8
- data/lib/rdoc/generator/ri.rb +1 -2
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -12
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +19 -10
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +26 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +27 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +125 -78
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +430 -339
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +13 -13
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -92
- data/lib/rdoc/generator/template/darkfish/js/search.js +35 -34
- data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +20 -18
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +32 -20
- data/lib/rdoc/generator/template/json_index/js/navigation.js +12 -49
- data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
- data/lib/rdoc/generator.rb +6 -6
- data/lib/rdoc/i18n/locale.rb +1 -1
- data/lib/rdoc/i18n/text.rb +5 -5
- data/lib/rdoc/i18n.rb +4 -4
- data/lib/rdoc/known_classes.rb +6 -5
- data/lib/rdoc/markdown/entities.rb +1 -2
- data/lib/rdoc/markdown/literals.kpeg +1 -2
- data/lib/rdoc/markdown/literals.rb +99 -50
- data/lib/rdoc/markdown.kpeg +115 -58
- data/lib/rdoc/markdown.rb +1584 -902
- data/lib/rdoc/markup/attr_changer.rb +1 -2
- data/lib/rdoc/markup/attr_span.rb +9 -4
- data/lib/rdoc/markup/attribute_manager.rb +118 -57
- data/lib/rdoc/markup/attributes.rb +7 -8
- data/lib/rdoc/markup/blank_line.rb +1 -2
- data/lib/rdoc/markup/block_quote.rb +1 -2
- data/lib/rdoc/markup/document.rb +1 -2
- data/lib/rdoc/markup/formatter.rb +44 -37
- data/lib/rdoc/markup/hard_break.rb +1 -2
- data/lib/rdoc/markup/heading.rb +11 -6
- data/lib/rdoc/markup/include.rb +1 -2
- data/lib/rdoc/markup/indented_paragraph.rb +1 -2
- data/lib/rdoc/markup/list.rb +1 -2
- data/lib/rdoc/markup/list_item.rb +1 -2
- data/lib/rdoc/markup/paragraph.rb +1 -2
- data/lib/rdoc/markup/parser.rb +90 -48
- data/lib/rdoc/markup/pre_process.rb +38 -11
- data/lib/rdoc/markup/raw.rb +1 -2
- data/lib/rdoc/markup/regexp_handling.rb +40 -0
- data/lib/rdoc/markup/rule.rb +1 -2
- data/lib/rdoc/markup/table.rb +56 -0
- data/lib/rdoc/markup/to_ansi.rb +1 -2
- data/lib/rdoc/markup/to_bs.rb +30 -5
- data/lib/rdoc/markup/to_html.rb +95 -40
- data/lib/rdoc/markup/to_html_crossref.rb +108 -43
- data/lib/rdoc/markup/to_html_snippet.rb +13 -11
- data/lib/rdoc/markup/to_joined_paragraph.rb +6 -32
- data/lib/rdoc/markup/to_label.rb +11 -12
- data/lib/rdoc/markup/to_markdown.rb +13 -14
- data/lib/rdoc/markup/to_rdoc.rb +49 -31
- data/lib/rdoc/markup/to_table_of_contents.rb +2 -2
- data/lib/rdoc/markup/to_test.rb +1 -2
- data/lib/rdoc/markup/to_tt_only.rb +3 -4
- data/lib/rdoc/markup/verbatim.rb +1 -2
- data/lib/rdoc/markup.rb +64 -694
- data/lib/rdoc/options.rb +226 -44
- data/lib/rdoc/parser/c.rb +231 -246
- data/lib/rdoc/parser/changelog.rb +169 -23
- data/lib/rdoc/parser/markdown.rb +1 -3
- data/lib/rdoc/parser/prism_ruby.rb +1092 -0
- data/lib/rdoc/parser/rd.rb +1 -2
- data/lib/rdoc/parser/ripper_state_lex.rb +302 -0
- data/lib/rdoc/parser/ruby.rb +695 -478
- data/lib/rdoc/parser/ruby_tools.rb +33 -36
- data/lib/rdoc/parser/simple.rb +4 -4
- data/lib/rdoc/parser/text.rb +1 -2
- data/lib/rdoc/parser.rb +37 -42
- data/lib/rdoc/rd/block_parser.rb +708 -57
- data/lib/rdoc/rd/block_parser.ry +15 -11
- data/lib/rdoc/rd/inline.rb +5 -6
- data/lib/rdoc/rd/inline_parser.rb +787 -140
- data/lib/rdoc/rd/inline_parser.ry +1 -1
- data/lib/rdoc/rd.rb +4 -5
- data/lib/rdoc/rdoc.rb +72 -87
- data/lib/rdoc/ri/driver.rb +236 -152
- data/lib/rdoc/ri/formatter.rb +1 -1
- data/lib/rdoc/ri/paths.rb +4 -18
- data/lib/rdoc/ri/store.rb +1 -2
- data/lib/rdoc/ri/task.rb +2 -2
- data/lib/rdoc/ri.rb +5 -6
- data/lib/rdoc/rubygems_hook.rb +98 -20
- data/lib/rdoc/servlet.rb +30 -20
- data/lib/rdoc/stats/normal.rb +24 -18
- data/lib/rdoc/stats/quiet.rb +1 -2
- data/lib/rdoc/stats/verbose.rb +1 -3
- data/lib/rdoc/stats.rb +6 -7
- data/lib/rdoc/store.rb +84 -55
- data/lib/rdoc/task.rb +35 -10
- data/lib/rdoc/text.rb +40 -27
- data/lib/rdoc/token_stream.rb +56 -34
- data/lib/rdoc/tom_doc.rb +18 -19
- data/lib/rdoc/version.rb +10 -0
- data/lib/rdoc.rb +80 -56
- data/lib/rubygems_plugin.rb +23 -0
- data/man/ri.1 +247 -0
- metadata +45 -99
- data/.document +0 -5
- data/.gitignore +0 -13
- data/.travis.yml +0 -24
- data/Gemfile +0 -3
- data/RI.rdoc +0 -57
- data/Rakefile +0 -133
- data/bin/console +0 -7
- data/bin/setup +0 -6
- data/lib/gauntlet_rdoc.rb +0 -82
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
- data/lib/rdoc/generator/template/json_index/.document +0 -1
- data/lib/rdoc/markup/formatter_test_case.rb +0 -764
- data/lib/rdoc/markup/inline.rb +0 -2
- data/lib/rdoc/markup/special.rb +0 -41
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
- data/lib/rdoc/ruby_lex.rb +0 -1367
- data/lib/rdoc/ruby_token.rb +0 -461
- data/lib/rdoc/test_case.rb +0 -204
- data/rdoc.gemspec +0 -57
data/lib/rdoc/encoding.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# coding: US-ASCII
|
2
|
-
# frozen_string_literal:
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
4
|
##
|
5
5
|
# This class is a wrapper around File IO and Encoding that helps RDoc load
|
@@ -7,6 +7,18 @@
|
|
7
7
|
|
8
8
|
module RDoc::Encoding
|
9
9
|
|
10
|
+
HEADER_REGEXP = /^
|
11
|
+
(?:
|
12
|
+
\A\#!.*\n
|
13
|
+
|
|
14
|
+
^\#\s+frozen[-_]string[-_]literal[=:].+\n
|
15
|
+
|
|
16
|
+
^\#[^\n]+\b(?:en)?coding[=:]\s*(?<name>[^\s;]+).*\n
|
17
|
+
|
|
18
|
+
<\?xml[^?]*encoding=(?<quote>["'])(?<name>.*?)\k<quote>.*\n
|
19
|
+
)+
|
20
|
+
/xi # :nodoc:
|
21
|
+
|
10
22
|
##
|
11
23
|
# Reads the contents of +filename+ and handles any encoding directives in
|
12
24
|
# the file.
|
@@ -18,31 +30,32 @@ module RDoc::Encoding
|
|
18
30
|
# unknown character in the target encoding will be replaced with '?'
|
19
31
|
|
20
32
|
def self.read_file filename, encoding, force_transcode = false
|
21
|
-
content = open filename, "rb" do |f| f.read end
|
33
|
+
content = File.open filename, "rb" do |f| f.read end
|
22
34
|
content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/
|
23
35
|
|
24
36
|
utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
|
25
37
|
|
26
|
-
RDoc::Encoding.
|
38
|
+
enc = RDoc::Encoding.detect_encoding content
|
39
|
+
content = RDoc::Encoding.change_encoding content, enc if enc
|
27
40
|
|
28
41
|
begin
|
29
42
|
encoding ||= Encoding.default_external
|
30
43
|
orig_encoding = content.encoding
|
31
44
|
|
32
45
|
if not orig_encoding.ascii_compatible? then
|
33
|
-
content.encode
|
46
|
+
content = content.encode encoding
|
34
47
|
elsif utf8 then
|
35
|
-
content.
|
36
|
-
content.encode
|
48
|
+
content = RDoc::Encoding.change_encoding content, Encoding::UTF_8
|
49
|
+
content = content.encode encoding
|
37
50
|
else
|
38
51
|
# assume the content is in our output encoding
|
39
|
-
content.
|
52
|
+
content = RDoc::Encoding.change_encoding content, encoding
|
40
53
|
end
|
41
54
|
|
42
55
|
unless content.valid_encoding? then
|
43
56
|
# revert and try to transcode
|
44
|
-
content.
|
45
|
-
content.encode
|
57
|
+
content = RDoc::Encoding.change_encoding content, orig_encoding
|
58
|
+
content = content.encode encoding
|
46
59
|
end
|
47
60
|
|
48
61
|
unless content.valid_encoding? then
|
@@ -52,10 +65,11 @@ module RDoc::Encoding
|
|
52
65
|
rescue Encoding::InvalidByteSequenceError,
|
53
66
|
Encoding::UndefinedConversionError => e
|
54
67
|
if force_transcode then
|
55
|
-
content.
|
56
|
-
content.encode
|
57
|
-
|
58
|
-
|
68
|
+
content = RDoc::Encoding.change_encoding content, orig_encoding
|
69
|
+
content = content.encode(encoding,
|
70
|
+
:invalid => :replace,
|
71
|
+
:undef => :replace,
|
72
|
+
:replace => '?')
|
59
73
|
return content
|
60
74
|
else
|
61
75
|
warn "unable to convert #{e.message} for #{filename}, skipping"
|
@@ -72,37 +86,35 @@ module RDoc::Encoding
|
|
72
86
|
nil
|
73
87
|
end
|
74
88
|
|
75
|
-
def self.remove_frozen_string_literal string
|
76
|
-
string =~ /\A(?:#!.*\n)?(.*\n)/
|
77
|
-
first_line = $1
|
78
|
-
|
79
|
-
if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i
|
80
|
-
string.sub! first_line, ''
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
89
|
##
|
85
|
-
#
|
86
|
-
|
87
|
-
def self.set_encoding string
|
88
|
-
remove_frozen_string_literal string
|
89
|
-
|
90
|
-
string =~ /\A(?:#!.*\n)?(.*\n)/
|
90
|
+
# Detects the encoding of +string+ based on the magic comment
|
91
91
|
|
92
|
-
|
92
|
+
def self.detect_encoding string
|
93
|
+
result = HEADER_REGEXP.match string
|
94
|
+
name = result && result[:name]
|
93
95
|
|
94
|
-
name
|
95
|
-
|
96
|
-
when /\b(?:en)?coding[=:]\s*([^\s;]+)/i then $1
|
97
|
-
else return
|
98
|
-
end
|
96
|
+
name ? Encoding.find(name) : nil
|
97
|
+
end
|
99
98
|
|
100
|
-
|
99
|
+
##
|
100
|
+
# Removes magic comments and shebang
|
101
101
|
|
102
|
-
|
102
|
+
def self.remove_magic_comment string
|
103
|
+
string.sub HEADER_REGEXP do |s|
|
104
|
+
s.gsub(/[^\n]/, '')
|
105
|
+
end
|
106
|
+
end
|
103
107
|
|
104
|
-
|
105
|
-
|
108
|
+
##
|
109
|
+
# Changes encoding based on +encoding+ without converting and returns new
|
110
|
+
# string
|
111
|
+
|
112
|
+
def self.change_encoding text, encoding
|
113
|
+
if text.kind_of? RDoc::Comment
|
114
|
+
text.encode! encoding
|
115
|
+
else
|
116
|
+
String.new text, encoding: encoding
|
117
|
+
end
|
106
118
|
end
|
107
119
|
|
108
120
|
end
|
data/lib/rdoc/erb_partial.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# Allows an ERB template to be rendered in the context (binding) of an
|
4
4
|
# existing ERB template evaluation.
|
@@ -12,8 +12,7 @@ class RDoc::ERBPartial < ERB
|
|
12
12
|
def set_eoutvar compiler, eoutvar = '_erbout'
|
13
13
|
super
|
14
14
|
|
15
|
-
compiler.pre_cmd = ["#{eoutvar} ||= ''"]
|
15
|
+
compiler.pre_cmd = ["#{eoutvar} ||= +''"]
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
19
|
-
|
data/lib/rdoc/erbio.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
require 'erb'
|
3
3
|
|
4
4
|
##
|
@@ -9,7 +9,7 @@ require 'erb'
|
|
9
9
|
#
|
10
10
|
# erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil
|
11
11
|
#
|
12
|
-
# open 'hello.txt', 'w' do |io|
|
12
|
+
# File.open 'hello.txt', 'w' do |io|
|
13
13
|
# erbio.result binding
|
14
14
|
# end
|
15
15
|
#
|
@@ -20,8 +20,8 @@ class RDoc::ERBIO < ERB
|
|
20
20
|
##
|
21
21
|
# Defaults +eoutvar+ to 'io', otherwise is identical to ERB's initialize
|
22
22
|
|
23
|
-
def initialize str,
|
24
|
-
super
|
23
|
+
def initialize str, trim_mode: nil, eoutvar: 'io'
|
24
|
+
super(str, trim_mode: trim_mode, eoutvar: eoutvar)
|
25
25
|
end
|
26
26
|
|
27
27
|
##
|
@@ -35,4 +35,3 @@ class RDoc::ERBIO < ERB
|
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
38
|
-
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
# -*- mode: ruby; ruby-indent-level: 2; tab-width: 2 -*-
|
3
3
|
|
4
4
|
require 'erb'
|
5
5
|
require 'fileutils'
|
6
6
|
require 'pathname'
|
7
|
-
|
7
|
+
require_relative 'markup'
|
8
8
|
|
9
9
|
##
|
10
10
|
# Darkfish RDoc HTML Generator
|
@@ -73,12 +73,6 @@ class RDoc::Generator::Darkfish
|
|
73
73
|
css/rdoc.css
|
74
74
|
]
|
75
75
|
|
76
|
-
##
|
77
|
-
# Path to this file's parent directory. Used to find templates and other
|
78
|
-
# resources.
|
79
|
-
|
80
|
-
GENERATOR_DIR = File.join 'rdoc', 'generator'
|
81
|
-
|
82
76
|
##
|
83
77
|
# Release Version
|
84
78
|
|
@@ -184,22 +178,6 @@ class RDoc::Generator::Darkfish
|
|
184
178
|
$stderr.puts(*msg)
|
185
179
|
end
|
186
180
|
|
187
|
-
##
|
188
|
-
# Directory where generated class HTML files live relative to the output
|
189
|
-
# dir.
|
190
|
-
|
191
|
-
def class_dir
|
192
|
-
nil
|
193
|
-
end
|
194
|
-
|
195
|
-
##
|
196
|
-
# Directory where generated class HTML files live relative to the output
|
197
|
-
# dir.
|
198
|
-
|
199
|
-
def file_dir
|
200
|
-
nil
|
201
|
-
end
|
202
|
-
|
203
181
|
##
|
204
182
|
# Create the directories the generated docs will live in if they don't
|
205
183
|
# already exist.
|
@@ -220,8 +198,8 @@ class RDoc::Generator::Darkfish
|
|
220
198
|
install_rdoc_static_file @template_dir + item, "./#{item}", options
|
221
199
|
end
|
222
200
|
|
223
|
-
@options.template_stylesheets.
|
224
|
-
FileUtils.cp
|
201
|
+
unless @options.template_stylesheets.empty?
|
202
|
+
FileUtils.cp @options.template_stylesheets, '.', **options
|
225
203
|
end
|
226
204
|
|
227
205
|
Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
|
@@ -269,7 +247,7 @@ class RDoc::Generator::Darkfish
|
|
269
247
|
|
270
248
|
@options.static_path.each do |path|
|
271
249
|
unless File.directory? path then
|
272
|
-
FileUtils.install path, @outputdir, fu_options.merge(:mode => 0644)
|
250
|
+
FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644)
|
273
251
|
next
|
274
252
|
end
|
275
253
|
|
@@ -278,9 +256,9 @@ class RDoc::Generator::Darkfish
|
|
278
256
|
dest_file = @outputdir + entry
|
279
257
|
|
280
258
|
if File.directory? entry then
|
281
|
-
FileUtils.mkdir_p entry, fu_options
|
259
|
+
FileUtils.mkdir_p entry, **fu_options
|
282
260
|
else
|
283
|
-
FileUtils.install entry, dest_file, fu_options.merge(:mode => 0644)
|
261
|
+
FileUtils.install entry, dest_file, **fu_options.merge(:mode => 0644)
|
284
262
|
end
|
285
263
|
end
|
286
264
|
end
|
@@ -301,8 +279,6 @@ class RDoc::Generator::Darkfish
|
|
301
279
|
# Generate an index page which lists all the classes which are documented.
|
302
280
|
|
303
281
|
def generate_index
|
304
|
-
setup
|
305
|
-
|
306
282
|
template_file = @template_dir + 'index.rhtml'
|
307
283
|
return unless template_file.exist?
|
308
284
|
|
@@ -313,12 +289,19 @@ class RDoc::Generator::Darkfish
|
|
313
289
|
search_index_rel_prefix = rel_prefix
|
314
290
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
315
291
|
|
316
|
-
|
317
|
-
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
|
292
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
318
293
|
|
319
294
|
@title = @options.title
|
295
|
+
@main_page = @files.find { |f| f.full_name == @options.main_page }
|
320
296
|
|
321
|
-
render_template template_file, out_file do |io|
|
297
|
+
render_template template_file, out_file do |io|
|
298
|
+
here = binding
|
299
|
+
# suppress 1.9.3 warning
|
300
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
301
|
+
# some partials rely on the presence of current variable to render
|
302
|
+
here.local_variable_set(:current, @main_page) if @main_page
|
303
|
+
here
|
304
|
+
end
|
322
305
|
rescue => e
|
323
306
|
error = RDoc::Error.new \
|
324
307
|
"error generating index.html: #{e.message} (#{e.class})"
|
@@ -331,8 +314,6 @@ class RDoc::Generator::Darkfish
|
|
331
314
|
# Generates a class file for +klass+
|
332
315
|
|
333
316
|
def generate_class klass, template_file = nil
|
334
|
-
setup
|
335
|
-
|
336
317
|
current = klass
|
337
318
|
|
338
319
|
template_file ||= @template_dir + 'class.rhtml'
|
@@ -343,22 +324,26 @@ class RDoc::Generator::Darkfish
|
|
343
324
|
search_index_rel_prefix = rel_prefix
|
344
325
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
345
326
|
|
346
|
-
|
347
|
-
|
348
|
-
|
327
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
328
|
+
|
329
|
+
breadcrumb = # used in templates
|
330
|
+
breadcrumb = generate_nesting_namespaces_breadcrumb(current, rel_prefix)
|
349
331
|
|
350
332
|
@title = "#{klass.type} #{klass.full_name} - #{@options.title}"
|
351
333
|
|
352
334
|
debug_msg " rendering #{out_file}"
|
353
|
-
render_template template_file, out_file do |io|
|
335
|
+
render_template template_file, out_file do |io|
|
336
|
+
here = binding
|
337
|
+
# suppress 1.9.3 warning
|
338
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
339
|
+
here
|
340
|
+
end
|
354
341
|
end
|
355
342
|
|
356
343
|
##
|
357
344
|
# Generate a documentation file for each class and module
|
358
345
|
|
359
346
|
def generate_class_files
|
360
|
-
setup
|
361
|
-
|
362
347
|
template_file = @template_dir + 'class.rhtml'
|
363
348
|
template_file = @template_dir + 'classpage.rhtml' unless
|
364
349
|
template_file.exist?
|
@@ -384,8 +369,6 @@ class RDoc::Generator::Darkfish
|
|
384
369
|
# Generate a documentation file for each file
|
385
370
|
|
386
371
|
def generate_file_files
|
387
|
-
setup
|
388
|
-
|
389
372
|
page_file = @template_dir + 'page.rhtml'
|
390
373
|
fileinfo_file = @template_dir + 'fileinfo.rhtml'
|
391
374
|
|
@@ -416,8 +399,7 @@ class RDoc::Generator::Darkfish
|
|
416
399
|
search_index_rel_prefix = rel_prefix
|
417
400
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
418
401
|
|
419
|
-
|
420
|
-
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
|
402
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
421
403
|
|
422
404
|
unless filepage_file then
|
423
405
|
if file.text? then
|
@@ -434,7 +416,13 @@ class RDoc::Generator::Darkfish
|
|
434
416
|
@title += " - #{@options.title}"
|
435
417
|
template_file ||= filepage_file
|
436
418
|
|
437
|
-
render_template template_file, out_file do |io|
|
419
|
+
render_template template_file, out_file do |io|
|
420
|
+
here = binding
|
421
|
+
# suppress 1.9.3 warning
|
422
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
423
|
+
here.local_variable_set(:current, current)
|
424
|
+
here
|
425
|
+
end
|
438
426
|
end
|
439
427
|
rescue => e
|
440
428
|
error =
|
@@ -448,8 +436,6 @@ class RDoc::Generator::Darkfish
|
|
448
436
|
# Generate a page file for +file+
|
449
437
|
|
450
438
|
def generate_page file
|
451
|
-
setup
|
452
|
-
|
453
439
|
template_file = @template_dir + 'page.rhtml'
|
454
440
|
|
455
441
|
out_file = @outputdir + file.path
|
@@ -458,22 +444,25 @@ class RDoc::Generator::Darkfish
|
|
458
444
|
search_index_rel_prefix = rel_prefix
|
459
445
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
460
446
|
|
461
|
-
|
462
|
-
|
463
|
-
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
|
447
|
+
current = file
|
448
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
464
449
|
|
465
450
|
@title = "#{file.page_name} - #{@options.title}"
|
466
451
|
|
467
452
|
debug_msg " rendering #{out_file}"
|
468
|
-
render_template template_file, out_file do |io|
|
453
|
+
render_template template_file, out_file do |io|
|
454
|
+
here = binding
|
455
|
+
# suppress 1.9.3 warning
|
456
|
+
here.local_variable_set(:current, current)
|
457
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
458
|
+
here
|
459
|
+
end
|
469
460
|
end
|
470
461
|
|
471
462
|
##
|
472
463
|
# Generates the 404 page for the RDoc servlet
|
473
464
|
|
474
465
|
def generate_servlet_not_found message
|
475
|
-
setup
|
476
|
-
|
477
466
|
template_file = @template_dir + 'servlet_not_found.rhtml'
|
478
467
|
return unless template_file.exist?
|
479
468
|
|
@@ -483,12 +472,16 @@ class RDoc::Generator::Darkfish
|
|
483
472
|
search_index_rel_prefix = rel_prefix
|
484
473
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
485
474
|
|
486
|
-
|
487
|
-
asset_rel_prefix = asset_rel_prefix = ''
|
475
|
+
asset_rel_prefix = ''
|
488
476
|
|
489
477
|
@title = 'Not Found'
|
490
478
|
|
491
|
-
render_template template_file do |io|
|
479
|
+
render_template template_file do |io|
|
480
|
+
here = binding
|
481
|
+
# suppress 1.9.3 warning
|
482
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
483
|
+
here
|
484
|
+
end
|
492
485
|
rescue => e
|
493
486
|
error = RDoc::Error.new \
|
494
487
|
"error generating servlet_not_found: #{e.message} (#{e.class})"
|
@@ -501,8 +494,6 @@ class RDoc::Generator::Darkfish
|
|
501
494
|
# Generates the servlet root page for the RDoc servlet
|
502
495
|
|
503
496
|
def generate_servlet_root installed
|
504
|
-
setup
|
505
|
-
|
506
497
|
template_file = @template_dir + 'servlet_root.rhtml'
|
507
498
|
return unless template_file.exist?
|
508
499
|
|
@@ -528,8 +519,6 @@ class RDoc::Generator::Darkfish
|
|
528
519
|
# Generate an index page which lists all the classes which are documented.
|
529
520
|
|
530
521
|
def generate_table_of_contents
|
531
|
-
setup
|
532
|
-
|
533
522
|
template_file = @template_dir + 'table_of_contents.rhtml'
|
534
523
|
return unless template_file.exist?
|
535
524
|
|
@@ -540,12 +529,16 @@ class RDoc::Generator::Darkfish
|
|
540
529
|
search_index_rel_prefix = rel_prefix
|
541
530
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
542
531
|
|
543
|
-
|
544
|
-
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
|
532
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
545
533
|
|
546
534
|
@title = "Table of Contents - #{@options.title}"
|
547
535
|
|
548
|
-
render_template template_file, out_file do |io|
|
536
|
+
render_template template_file, out_file do |io|
|
537
|
+
here = binding
|
538
|
+
# suppress 1.9.3 warning
|
539
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
540
|
+
here
|
541
|
+
end
|
549
542
|
rescue => e
|
550
543
|
error = RDoc::Error.new \
|
551
544
|
"error generating table_of_contents.html: #{e.message} (#{e.class})"
|
@@ -558,16 +551,16 @@ class RDoc::Generator::Darkfish
|
|
558
551
|
return unless source.exist?
|
559
552
|
|
560
553
|
begin
|
561
|
-
FileUtils.mkdir_p File.dirname(destination), options
|
554
|
+
FileUtils.mkdir_p File.dirname(destination), **options
|
562
555
|
|
563
556
|
begin
|
564
|
-
FileUtils.ln source, destination, options
|
557
|
+
FileUtils.ln source, destination, **options
|
565
558
|
rescue Errno::EEXIST
|
566
559
|
FileUtils.rm destination
|
567
560
|
retry
|
568
561
|
end
|
569
562
|
rescue
|
570
|
-
FileUtils.cp source, destination, options
|
563
|
+
FileUtils.cp source, destination, **options
|
571
564
|
end
|
572
565
|
end
|
573
566
|
|
@@ -583,62 +576,10 @@ class RDoc::Generator::Darkfish
|
|
583
576
|
|
584
577
|
@classes = @store.all_classes_and_modules.sort
|
585
578
|
@files = @store.all_files.sort
|
586
|
-
@methods = @classes.
|
579
|
+
@methods = @classes.flat_map { |m| m.method_list }.sort
|
587
580
|
@modsort = get_sorted_module_list @classes
|
588
581
|
end
|
589
582
|
|
590
|
-
##
|
591
|
-
# Return a string describing the amount of time in the given number of
|
592
|
-
# seconds in terms a human can understand easily.
|
593
|
-
|
594
|
-
def time_delta_string seconds
|
595
|
-
return 'less than a minute' if seconds < 60
|
596
|
-
return "#{seconds / 60} minute#{seconds / 60 == 1 ? '' : 's'}" if
|
597
|
-
seconds < 3000 # 50 minutes
|
598
|
-
return 'about one hour' if seconds < 5400 # 90 minutes
|
599
|
-
return "#{seconds / 3600} hours" if seconds < 64800 # 18 hours
|
600
|
-
return 'one day' if seconds < 86400 # 1 day
|
601
|
-
return 'about one day' if seconds < 172800 # 2 days
|
602
|
-
return "#{seconds / 86400} days" if seconds < 604800 # 1 week
|
603
|
-
return 'about one week' if seconds < 1209600 # 2 week
|
604
|
-
return "#{seconds / 604800} weeks" if seconds < 7257600 # 3 months
|
605
|
-
return "#{seconds / 2419200} months" if seconds < 31536000 # 1 year
|
606
|
-
return "#{seconds / 31536000} years"
|
607
|
-
end
|
608
|
-
|
609
|
-
# %q$Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $"
|
610
|
-
SVNID_PATTERN = /
|
611
|
-
\$Id:\s
|
612
|
-
(\S+)\s # filename
|
613
|
-
(\d+)\s # rev
|
614
|
-
(\d{4}-\d{2}-\d{2})\s # Date (YYYY-MM-DD)
|
615
|
-
(\d{2}:\d{2}:\d{2}Z)\s # Time (HH:MM:SSZ)
|
616
|
-
(\w+)\s # committer
|
617
|
-
\$$
|
618
|
-
/x
|
619
|
-
|
620
|
-
##
|
621
|
-
# Try to extract Subversion information out of the first constant whose
|
622
|
-
# value looks like a subversion Id tag. If no matching constant is found,
|
623
|
-
# and empty hash is returned.
|
624
|
-
|
625
|
-
def get_svninfo klass
|
626
|
-
constants = klass.constants or return {}
|
627
|
-
|
628
|
-
constants.find { |c| c.value =~ SVNID_PATTERN } or return {}
|
629
|
-
|
630
|
-
filename, rev, date, time, committer = $~.captures
|
631
|
-
commitdate = Time.parse "#{date} #{time}"
|
632
|
-
|
633
|
-
return {
|
634
|
-
:filename => filename,
|
635
|
-
:rev => Integer(rev),
|
636
|
-
:commitdate => commitdate,
|
637
|
-
:commitdelta => time_delta_string(Time.now - commitdate),
|
638
|
-
:committer => committer,
|
639
|
-
}
|
640
|
-
end
|
641
|
-
|
642
583
|
##
|
643
584
|
# Creates a template from its components and the +body_file+.
|
644
585
|
#
|
@@ -650,7 +591,6 @@ class RDoc::Generator::Darkfish
|
|
650
591
|
return body if body =~ /<html/
|
651
592
|
|
652
593
|
head_file = @template_dir + '_head.rhtml'
|
653
|
-
footer_file = @template_dir + '_footer.rhtml'
|
654
594
|
|
655
595
|
<<-TEMPLATE
|
656
596
|
<!DOCTYPE html>
|
@@ -660,8 +600,6 @@ class RDoc::Generator::Darkfish
|
|
660
600
|
#{head_file.read}
|
661
601
|
|
662
602
|
#{body}
|
663
|
-
|
664
|
-
#{footer_file.read}
|
665
603
|
TEMPLATE
|
666
604
|
end
|
667
605
|
|
@@ -751,9 +689,124 @@ class RDoc::Generator::Darkfish
|
|
751
689
|
erbout = "_erbout_#{file_var}"
|
752
690
|
end
|
753
691
|
|
754
|
-
template = klass.new template,
|
692
|
+
template = klass.new template, trim_mode: '-', eoutvar: erbout
|
755
693
|
@template_cache[file] = template
|
756
694
|
template
|
757
695
|
end
|
758
696
|
|
697
|
+
# :stopdoc:
|
698
|
+
ParagraphExcerptRegexpOther = %r[\b\w[^./:]++\.]
|
699
|
+
# use \p/\P{letter} instead of \w/\W in Unicode
|
700
|
+
ParagraphExcerptRegexpUnicode = %r[\b\p{letter}[^./:]++\.]
|
701
|
+
# :startdoc:
|
702
|
+
|
703
|
+
# Returns an excerpt of the comment for usage in meta description tags
|
704
|
+
def excerpt(comment)
|
705
|
+
text = case comment
|
706
|
+
when RDoc::Comment
|
707
|
+
comment.text
|
708
|
+
else
|
709
|
+
comment
|
710
|
+
end
|
711
|
+
|
712
|
+
# Match from a capital letter to the first period, discarding any links, so
|
713
|
+
# that we don't end up matching badges in the README
|
714
|
+
pattern = ParagraphExcerptRegexpUnicode
|
715
|
+
begin
|
716
|
+
first_paragraph_match = text.match(pattern)
|
717
|
+
rescue Encoding::CompatibilityError
|
718
|
+
# The doc is non-ASCII text and encoded in other than Unicode base encodings.
|
719
|
+
raise if pattern == ParagraphExcerptRegexpOther
|
720
|
+
pattern = ParagraphExcerptRegexpOther
|
721
|
+
retry
|
722
|
+
end
|
723
|
+
return text[0...150].tr_s("\n", " ").squeeze(" ") unless first_paragraph_match
|
724
|
+
|
725
|
+
extracted_text = first_paragraph_match[0]
|
726
|
+
second_paragraph = text.match(pattern, first_paragraph_match.end(0))
|
727
|
+
extracted_text << " " << second_paragraph[0] if second_paragraph
|
728
|
+
|
729
|
+
extracted_text[0...150].tr_s("\n", " ").squeeze(" ")
|
730
|
+
end
|
731
|
+
|
732
|
+
def generate_ancestor_list(ancestors, klass)
|
733
|
+
return '' if ancestors.empty?
|
734
|
+
|
735
|
+
ancestor = ancestors.shift
|
736
|
+
content = +'<ul><li>'
|
737
|
+
|
738
|
+
if ancestor.is_a?(RDoc::NormalClass)
|
739
|
+
content << "<a href=\"#{klass.aref_to ancestor.path}\">#{ancestor.full_name}</a>"
|
740
|
+
else
|
741
|
+
content << ancestor.to_s
|
742
|
+
end
|
743
|
+
|
744
|
+
# Recursively call the method for the remaining ancestors
|
745
|
+
content << generate_ancestor_list(ancestors, klass)
|
746
|
+
|
747
|
+
content << '</li></ul>'
|
748
|
+
end
|
749
|
+
|
750
|
+
def generate_class_link(klass, rel_prefix)
|
751
|
+
if klass.display?
|
752
|
+
%(<code><a href="#{rel_prefix}/#{klass.path}">#{klass.name}</a></code>)
|
753
|
+
else
|
754
|
+
%(<code>#{klass.name}</code>)
|
755
|
+
end
|
756
|
+
end
|
757
|
+
|
758
|
+
def generate_class_index_content(classes, rel_prefix)
|
759
|
+
grouped_classes = group_classes_by_namespace_for_sidebar(classes)
|
760
|
+
return '' unless top = grouped_classes[nil]
|
761
|
+
|
762
|
+
solo = top.one? { |klass| klass.display? }
|
763
|
+
traverse_classes(top, grouped_classes, rel_prefix, solo)
|
764
|
+
end
|
765
|
+
|
766
|
+
def traverse_classes(klasses, grouped_classes, rel_prefix, solo = false)
|
767
|
+
content = +'<ul class="link-list">'
|
768
|
+
|
769
|
+
klasses.each do |index_klass|
|
770
|
+
if children = grouped_classes[index_klass.full_name]
|
771
|
+
content << %(<li><details#{solo ? ' open' : ''}><summary>#{generate_class_link(index_klass, rel_prefix)}</summary>)
|
772
|
+
content << traverse_classes(children, grouped_classes, rel_prefix)
|
773
|
+
content << '</details></li>'
|
774
|
+
solo = false
|
775
|
+
elsif index_klass.display?
|
776
|
+
content << %(<li>#{generate_class_link(index_klass, rel_prefix)}</li>)
|
777
|
+
end
|
778
|
+
end
|
779
|
+
|
780
|
+
"#{content}</ul>"
|
781
|
+
end
|
782
|
+
|
783
|
+
def group_classes_by_namespace_for_sidebar(classes)
|
784
|
+
grouped_classes = classes.group_by do |klass|
|
785
|
+
klass.full_name[/\A[^:]++(?:::[^:]++(?=::))*+(?=::[^:]*+\z)/]
|
786
|
+
end.select do |_, klasses|
|
787
|
+
klasses.any?(&:display?)
|
788
|
+
end
|
789
|
+
|
790
|
+
grouped_classes.values.each(&:uniq!)
|
791
|
+
grouped_classes
|
792
|
+
end
|
793
|
+
|
794
|
+
private
|
795
|
+
|
796
|
+
def nesting_namespaces_to_class_modules klass
|
797
|
+
tree = {}
|
798
|
+
|
799
|
+
klass.nesting_namespaces.zip(klass.fully_qualified_nesting_namespaces) do |ns, fqns|
|
800
|
+
tree[ns] = @store.classes_hash[fqns] || @store.modules_hash[fqns]
|
801
|
+
end
|
802
|
+
|
803
|
+
tree
|
804
|
+
end
|
805
|
+
|
806
|
+
def generate_nesting_namespaces_breadcrumb klass, rel_prefix
|
807
|
+
nesting_namespaces_to_class_modules(klass).map do |namespace, class_module|
|
808
|
+
path = class_module ? (rel_prefix + class_module.path).to_s : ""
|
809
|
+
{ name: namespace, path: path, self: klass.full_name == class_module&.full_name }
|
810
|
+
end
|
811
|
+
end
|
759
812
|
end
|