rdoc 5.1.0 → 6.3.1
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 +5 -5
- data/CONTRIBUTING.rdoc +4 -4
- data/Gemfile +9 -0
- data/History.rdoc +4 -4
- data/README.rdoc +5 -6
- data/Rakefile +35 -67
- data/lib/rdoc/alias.rb +1 -1
- data/lib/rdoc/anon_class.rb +1 -1
- data/lib/rdoc/any_method.rb +59 -15
- data/lib/rdoc/attr.rb +1 -1
- data/lib/rdoc/class_module.rb +5 -3
- data/lib/rdoc/code_object.rb +2 -9
- data/lib/rdoc/code_objects.rb +1 -1
- data/lib/rdoc/comment.rb +32 -11
- data/lib/rdoc/constant.rb +3 -3
- data/lib/rdoc/context/section.rb +1 -14
- data/lib/rdoc/context.rb +63 -20
- data/lib/rdoc/cross_reference.rb +33 -15
- data/lib/rdoc/encoding.rb +58 -30
- data/lib/rdoc/erb_partial.rb +2 -2
- data/lib/rdoc/erbio.rb +8 -4
- data/lib/rdoc/extend.rb +1 -1
- data/lib/rdoc/generator/darkfish.rb +60 -29
- data/lib/rdoc/generator/json_index.rb +6 -3
- data/lib/rdoc/generator/markup.rb +3 -13
- data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
- data/lib/rdoc/generator/pot/po.rb +3 -3
- data/lib/rdoc/generator/pot/po_entry.rb +11 -11
- data/lib/rdoc/generator/pot.rb +4 -4
- data/lib/rdoc/generator/ri.rb +1 -1
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +9 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
- 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 +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/class.rhtml +45 -47
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -6
- data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +22 -99
- data/lib/rdoc/generator/template/darkfish/js/search.js +32 -31
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
- data/lib/rdoc/generator/template/json_index/js/navigation.js +4 -41
- data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
- data/lib/rdoc/generator.rb +1 -1
- data/lib/rdoc/ghost_method.rb +1 -1
- data/lib/rdoc/i18n/locale.rb +1 -1
- data/lib/rdoc/i18n/text.rb +5 -5
- data/lib/rdoc/i18n.rb +3 -3
- data/lib/rdoc/include.rb +1 -1
- data/lib/rdoc/known_classes.rb +1 -1
- data/lib/rdoc/markdown/entities.rb +1 -1
- data/lib/rdoc/markdown/literals.kpeg +1 -0
- data/lib/rdoc/markdown/literals.rb +19 -7
- data/lib/rdoc/markdown.kpeg +92 -44
- data/lib/rdoc/markdown.rb +1171 -610
- data/lib/rdoc/markup/attr_changer.rb +1 -1
- data/lib/rdoc/markup/attr_span.rb +9 -3
- data/lib/rdoc/markup/attribute_manager.rb +115 -50
- data/lib/rdoc/markup/attributes.rb +7 -7
- data/lib/rdoc/markup/blank_line.rb +1 -1
- data/lib/rdoc/markup/block_quote.rb +1 -1
- data/lib/rdoc/markup/document.rb +1 -1
- data/lib/rdoc/markup/formatter.rb +25 -24
- data/lib/rdoc/markup/hard_break.rb +1 -1
- data/lib/rdoc/markup/heading.rb +4 -4
- data/lib/rdoc/markup/include.rb +1 -1
- data/lib/rdoc/markup/indented_paragraph.rb +1 -1
- data/lib/rdoc/markup/list.rb +1 -1
- data/lib/rdoc/markup/list_item.rb +1 -1
- data/lib/rdoc/markup/paragraph.rb +1 -1
- data/lib/rdoc/markup/parser.rb +79 -47
- data/lib/rdoc/markup/pre_process.rb +11 -6
- data/lib/rdoc/markup/raw.rb +1 -1
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +1 -1
- data/lib/rdoc/markup/to_ansi.rb +1 -1
- data/lib/rdoc/markup/to_bs.rb +4 -4
- data/lib/rdoc/markup/to_html.rb +68 -26
- data/lib/rdoc/markup/to_html_crossref.rb +41 -26
- data/lib/rdoc/markup/to_html_snippet.rb +10 -10
- data/lib/rdoc/markup/to_joined_paragraph.rb +7 -32
- data/lib/rdoc/markup/to_label.rb +10 -10
- data/lib/rdoc/markup/to_markdown.rb +9 -9
- data/lib/rdoc/markup/to_rdoc.rb +35 -7
- data/lib/rdoc/markup/to_table_of_contents.rb +2 -1
- data/lib/rdoc/markup/to_test.rb +1 -1
- data/lib/rdoc/markup/to_tt_only.rb +3 -3
- data/lib/rdoc/markup/verbatim.rb +1 -1
- data/lib/rdoc/markup.rb +14 -17
- data/lib/rdoc/meta_method.rb +1 -1
- data/lib/rdoc/method_attr.rb +2 -2
- data/lib/rdoc/mixin.rb +1 -1
- data/lib/rdoc/normal_class.rb +3 -3
- data/lib/rdoc/normal_module.rb +1 -1
- data/lib/rdoc/options.rb +79 -21
- data/lib/rdoc/parser/c.rb +147 -194
- data/lib/rdoc/parser/changelog.rb +150 -19
- data/lib/rdoc/parser/markdown.rb +1 -1
- data/lib/rdoc/parser/rd.rb +1 -1
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +632 -466
- data/lib/rdoc/parser/ruby_tools.rb +33 -34
- data/lib/rdoc/parser/simple.rb +3 -3
- data/lib/rdoc/parser/text.rb +1 -1
- data/lib/rdoc/parser.rb +9 -34
- data/lib/rdoc/rd/block_parser.rb +47 -46
- data/lib/rdoc/rd/block_parser.ry +2 -2
- data/lib/rdoc/rd/inline.rb +5 -5
- data/lib/rdoc/rd/inline_parser.rb +139 -138
- data/lib/rdoc/rd/inline_parser.ry +1 -1
- data/lib/rdoc/rd.rb +1 -1
- data/lib/rdoc/rdoc.rb +54 -41
- data/lib/rdoc/require.rb +1 -1
- data/lib/rdoc/ri/driver.rb +132 -42
- data/lib/rdoc/ri/formatter.rb +1 -1
- data/lib/rdoc/ri/paths.rb +4 -18
- data/lib/rdoc/ri/store.rb +1 -1
- data/lib/rdoc/ri/task.rb +2 -2
- data/lib/rdoc/ri.rb +1 -1
- data/lib/rdoc/rubygems_hook.rb +3 -3
- data/lib/rdoc/servlet.rb +21 -12
- data/lib/rdoc/single_class.rb +1 -1
- data/lib/rdoc/stats/normal.rb +24 -18
- data/lib/rdoc/stats/quiet.rb +1 -1
- data/lib/rdoc/stats/verbose.rb +1 -1
- data/lib/rdoc/stats.rb +1 -1
- data/lib/rdoc/store.rb +38 -27
- data/lib/rdoc/task.rb +2 -2
- data/lib/rdoc/text.rb +16 -21
- data/lib/rdoc/token_stream.rb +56 -33
- data/lib/rdoc/tom_doc.rb +17 -12
- data/lib/rdoc/top_level.rb +9 -3
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +24 -10
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +206 -15
- metadata +15 -64
- data/.document +0 -5
- data/.gitignore +0 -13
- data/.travis.yml +0 -24
- data/lib/gauntlet_rdoc.rb +0 -82
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
- 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/lib/rdoc/context.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
require 'cgi'
|
3
3
|
|
4
4
|
##
|
@@ -239,7 +239,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
239
239
|
|
240
240
|
if known then
|
241
241
|
known.comment = attribute.comment if known.comment.empty?
|
242
|
-
elsif registered = @methods_hash[attribute.pretty_name
|
242
|
+
elsif registered = @methods_hash[attribute.pretty_name + '='] and
|
243
243
|
RDoc::Attr === registered then
|
244
244
|
registered.rw = 'RW'
|
245
245
|
else
|
@@ -249,7 +249,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
249
249
|
end
|
250
250
|
|
251
251
|
if attribute.rw.index 'W' then
|
252
|
-
key = attribute.pretty_name
|
252
|
+
key = attribute.pretty_name + '='
|
253
253
|
known = @methods_hash[key]
|
254
254
|
|
255
255
|
if known then
|
@@ -407,6 +407,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
407
407
|
mod.section = current_section # TODO declaring context? something is
|
408
408
|
# wrong here...
|
409
409
|
mod.parent = self
|
410
|
+
mod.full_name = nil
|
410
411
|
mod.store = @store
|
411
412
|
|
412
413
|
unless @done_documenting then
|
@@ -414,6 +415,10 @@ class RDoc::Context < RDoc::CodeObject
|
|
414
415
|
# this must be done AFTER adding mod to its parent, so that the full
|
415
416
|
# name is correct:
|
416
417
|
all_hash[mod.full_name] = mod
|
418
|
+
if @store.unmatched_constant_alias[mod.full_name] then
|
419
|
+
to, file = @store.unmatched_constant_alias[mod.full_name]
|
420
|
+
add_module_alias mod, mod.name, to, file
|
421
|
+
end
|
417
422
|
end
|
418
423
|
|
419
424
|
mod
|
@@ -510,41 +515,53 @@ class RDoc::Context < RDoc::CodeObject
|
|
510
515
|
add_class_or_module mod, @modules, @store.modules_hash
|
511
516
|
end
|
512
517
|
|
518
|
+
##
|
519
|
+
# Adds a module by +RDoc::NormalModule+ instance. See also #add_module.
|
520
|
+
|
521
|
+
def add_module_by_normal_module(mod)
|
522
|
+
add_class_or_module mod, @modules, @store.modules_hash
|
523
|
+
end
|
524
|
+
|
513
525
|
##
|
514
526
|
# Adds an alias from +from+ (a class or module) to +name+ which was defined
|
515
527
|
# in +file+.
|
516
528
|
|
517
|
-
def add_module_alias from,
|
529
|
+
def add_module_alias from, from_name, to, file
|
518
530
|
return from if @done_documenting
|
519
531
|
|
520
|
-
|
532
|
+
to_full_name = child_name to.name
|
521
533
|
|
522
534
|
# if we already know this name, don't register an alias:
|
523
535
|
# see the metaprogramming in lib/active_support/basic_object.rb,
|
524
536
|
# where we already know BasicObject is a class when we find
|
525
537
|
# BasicObject = BlankSlate
|
526
|
-
return from if @store.find_class_or_module
|
538
|
+
return from if @store.find_class_or_module to_full_name
|
527
539
|
|
528
|
-
|
529
|
-
|
530
|
-
|
540
|
+
unless from
|
541
|
+
@store.unmatched_constant_alias[child_name(from_name)] = [to, file]
|
542
|
+
return to
|
543
|
+
end
|
544
|
+
|
545
|
+
new_to = from.dup
|
546
|
+
new_to.name = to.name
|
547
|
+
new_to.full_name = nil
|
531
548
|
|
532
|
-
if
|
533
|
-
@store.modules_hash[
|
534
|
-
@modules[name] =
|
549
|
+
if new_to.module? then
|
550
|
+
@store.modules_hash[to_full_name] = new_to
|
551
|
+
@modules[to.name] = new_to
|
535
552
|
else
|
536
|
-
@store.classes_hash[
|
537
|
-
@classes[name] =
|
553
|
+
@store.classes_hash[to_full_name] = new_to
|
554
|
+
@classes[to.name] = new_to
|
538
555
|
end
|
539
556
|
|
540
557
|
# Registers a constant for this alias. The constant value and comment
|
541
558
|
# will be updated later, when the Ruby parser adds the constant
|
542
|
-
const = RDoc::Constant.new name, nil,
|
559
|
+
const = RDoc::Constant.new to.name, nil, new_to.comment
|
543
560
|
const.record_location file
|
544
561
|
const.is_alias_for = from
|
545
562
|
add_constant const
|
546
563
|
|
547
|
-
|
564
|
+
new_to
|
548
565
|
end
|
549
566
|
|
550
567
|
##
|
@@ -762,7 +779,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
762
779
|
attributes.default = []
|
763
780
|
|
764
781
|
sort_sections.each do |section|
|
765
|
-
yield section, constants[section].sort, attributes[section].sort
|
782
|
+
yield section, constants[section].select(&:display?).sort, attributes[section].select(&:display?).sort
|
766
783
|
end
|
767
784
|
end
|
768
785
|
|
@@ -863,7 +880,13 @@ class RDoc::Context < RDoc::CodeObject
|
|
863
880
|
# Finds a method named +name+ with singleton value +singleton+.
|
864
881
|
|
865
882
|
def find_method(name, singleton)
|
866
|
-
@method_list.find { |m|
|
883
|
+
@method_list.find { |m|
|
884
|
+
if m.singleton
|
885
|
+
m.name == name && m.singleton == singleton
|
886
|
+
else
|
887
|
+
m.name == name && !m.singleton && !singleton
|
888
|
+
end
|
889
|
+
}
|
867
890
|
end
|
868
891
|
|
869
892
|
##
|
@@ -967,13 +990,21 @@ class RDoc::Context < RDoc::CodeObject
|
|
967
990
|
@instance_attributes ||= attributes.reject { |a| a.singleton }
|
968
991
|
end
|
969
992
|
|
993
|
+
##
|
994
|
+
# Instance methods
|
995
|
+
|
996
|
+
def instance_methods
|
997
|
+
@instance_methods ||= method_list.reject { |a| a.singleton }
|
998
|
+
end
|
999
|
+
|
970
1000
|
##
|
971
1001
|
# Instance methods
|
972
1002
|
#--
|
973
|
-
# TODO
|
1003
|
+
# TODO remove this later
|
974
1004
|
|
975
1005
|
def instance_method_list
|
976
|
-
|
1006
|
+
warn '#instance_method_list is obsoleted, please use #instance_methods'
|
1007
|
+
@instance_methods ||= method_list.reject { |a| a.singleton }
|
977
1008
|
end
|
978
1009
|
|
979
1010
|
##
|
@@ -1079,6 +1110,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
1079
1110
|
return if [:private, :nodoc].include? min_visibility
|
1080
1111
|
remove_invisible_in @method_list, min_visibility
|
1081
1112
|
remove_invisible_in @attributes, min_visibility
|
1113
|
+
remove_invisible_in @constants, min_visibility
|
1082
1114
|
end
|
1083
1115
|
|
1084
1116
|
##
|
@@ -1165,6 +1197,17 @@ class RDoc::Context < RDoc::CodeObject
|
|
1165
1197
|
end
|
1166
1198
|
end
|
1167
1199
|
|
1200
|
+
##
|
1201
|
+
# Given an array +names+ of constants, set the visibility of each constant to
|
1202
|
+
# +visibility+
|
1203
|
+
|
1204
|
+
def set_constant_visibility_for(names, visibility)
|
1205
|
+
names.each do |name|
|
1206
|
+
constant = @constants_hash[name] or next
|
1207
|
+
constant.visibility = visibility
|
1208
|
+
end
|
1209
|
+
end
|
1210
|
+
|
1168
1211
|
##
|
1169
1212
|
# Sorts sections alphabetically (default) or in TomDoc fashion (none,
|
1170
1213
|
# Public, Internal, Deprecated)
|
data/lib/rdoc/cross_reference.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# RDoc::CrossReference is a reusable way to create cross references for names.
|
4
4
|
|
@@ -19,16 +19,16 @@ class RDoc::CrossReference
|
|
19
19
|
#
|
20
20
|
# See CLASS_REGEXP_STR
|
21
21
|
|
22
|
-
METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]
|
22
|
+
METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>|\+@|-@|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
|
23
23
|
|
24
24
|
##
|
25
25
|
# Regular expressions matching text that should potentially have
|
26
|
-
# cross-reference links generated are passed to
|
27
|
-
# these expressions are meant to pick up text for which cross-references
|
26
|
+
# cross-reference links generated are passed to add_regexp_handling. Note
|
27
|
+
# that these expressions are meant to pick up text for which cross-references
|
28
28
|
# have been suppressed, since the suppression characters are removed by the
|
29
29
|
# code that is triggered.
|
30
30
|
|
31
|
-
CROSSREF_REGEXP = /(
|
31
|
+
CROSSREF_REGEXP = /(?:^|[\s()])
|
32
32
|
(
|
33
33
|
(?:
|
34
34
|
# A::B::C.meth
|
@@ -76,7 +76,7 @@ class RDoc::CrossReference
|
|
76
76
|
# Version of CROSSREF_REGEXP used when <tt>--hyperlink-all</tt> is specified.
|
77
77
|
|
78
78
|
ALL_CROSSREF_REGEXP = /
|
79
|
-
(
|
79
|
+
(?:^|[\s()])
|
80
80
|
(
|
81
81
|
(?:
|
82
82
|
# A::B::C.meth
|
@@ -127,23 +127,41 @@ class RDoc::CrossReference
|
|
127
127
|
|
128
128
|
if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
|
129
129
|
type = $2
|
130
|
-
|
131
|
-
|
130
|
+
if '.' == type # will find either #method or ::method
|
131
|
+
method = $3
|
132
|
+
else
|
133
|
+
method = "#{type}#{$3}"
|
134
|
+
end
|
132
135
|
container = @context.find_symbol_module($1)
|
133
136
|
elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
|
134
137
|
type = $1
|
135
|
-
|
136
|
-
|
138
|
+
if '.' == type
|
139
|
+
method = $2
|
140
|
+
else
|
141
|
+
method = "#{type}#{$2}"
|
142
|
+
end
|
137
143
|
container = @context
|
138
144
|
else
|
145
|
+
type = nil
|
139
146
|
container = nil
|
140
147
|
end
|
141
148
|
|
142
149
|
if container then
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
150
|
+
unless RDoc::TopLevel === container then
|
151
|
+
if '.' == type then
|
152
|
+
if 'new' == method then # AnyClassName.new will be class method
|
153
|
+
ref = container.find_local_symbol method
|
154
|
+
ref = container.find_ancestor_local_symbol method unless ref
|
155
|
+
else
|
156
|
+
ref = container.find_local_symbol "::#{method}"
|
157
|
+
ref = container.find_ancestor_local_symbol "::#{method}" unless ref
|
158
|
+
ref = container.find_local_symbol "##{method}" unless ref
|
159
|
+
ref = container.find_ancestor_local_symbol "##{method}" unless ref
|
160
|
+
end
|
161
|
+
else
|
162
|
+
ref = container.find_local_symbol method
|
163
|
+
ref = container.find_ancestor_local_symbol method unless ref
|
164
|
+
end
|
147
165
|
end
|
148
166
|
end
|
149
167
|
|
@@ -155,7 +173,7 @@ class RDoc::CrossReference
|
|
155
173
|
end unless ref
|
156
174
|
|
157
175
|
# Try a page name
|
158
|
-
ref = @store.page name if not ref and name =~
|
176
|
+
ref = @store.page name if not ref and name =~ /^[\w.]+$/
|
159
177
|
|
160
178
|
ref = nil if RDoc::Alias === ref # external alias, can't link to it
|
161
179
|
|
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"
|
@@ -77,32 +91,46 @@ module RDoc::Encoding
|
|
77
91
|
first_line = $1
|
78
92
|
|
79
93
|
if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i
|
80
|
-
string.sub
|
94
|
+
string = string.sub first_line, ''
|
81
95
|
end
|
96
|
+
|
97
|
+
string
|
82
98
|
end
|
83
99
|
|
84
100
|
##
|
85
|
-
#
|
101
|
+
# Detects the encoding of +string+ based on the magic comment
|
86
102
|
|
87
|
-
def self.
|
88
|
-
|
89
|
-
|
90
|
-
string =~ /\A(?:#!.*\n)?(.*\n)/
|
103
|
+
def self.detect_encoding string
|
104
|
+
result = HEADER_REGEXP.match string
|
105
|
+
name = result && result[:name]
|
91
106
|
|
92
|
-
|
93
|
-
|
94
|
-
name = case first_line
|
95
|
-
when /^<\?xml[^?]*encoding=(["'])(.*?)\1/ then $2
|
96
|
-
when /\b(?:en)?coding[=:]\s*([^\s;]+)/i then $1
|
97
|
-
else return
|
98
|
-
end
|
107
|
+
name ? Encoding.find(name) : nil
|
108
|
+
end
|
99
109
|
|
100
|
-
|
110
|
+
##
|
111
|
+
# Removes magic comments and shebang
|
101
112
|
|
102
|
-
|
113
|
+
def self.remove_magic_comment string
|
114
|
+
string.sub HEADER_REGEXP do |s|
|
115
|
+
s.gsub(/[^\n]/, '')
|
116
|
+
end
|
117
|
+
end
|
103
118
|
|
104
|
-
|
105
|
-
|
119
|
+
##
|
120
|
+
# Changes encoding based on +encoding+ without converting and returns new
|
121
|
+
# string
|
122
|
+
|
123
|
+
def self.change_encoding text, encoding
|
124
|
+
if text.kind_of? RDoc::Comment
|
125
|
+
text.encode! encoding
|
126
|
+
else
|
127
|
+
# TODO: Remove this condition after Ruby 2.2 EOL
|
128
|
+
if RUBY_VERSION < '2.3.0'
|
129
|
+
text.force_encoding encoding
|
130
|
+
else
|
131
|
+
String.new text, encoding: encoding
|
132
|
+
end
|
133
|
+
end
|
106
134
|
end
|
107
135
|
|
108
136
|
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,7 +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
|
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,12 @@ 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, safe_level = nil,
|
24
|
-
|
23
|
+
def initialize str, safe_level = nil, legacy_trim_mode = nil, legacy_eoutvar = 'io', trim_mode: nil, eoutvar: 'io'
|
24
|
+
if RUBY_VERSION >= '2.6'
|
25
|
+
super(str, trim_mode: trim_mode, eoutvar: eoutvar)
|
26
|
+
else
|
27
|
+
super(str, safe_level, legacy_trim_mode, legacy_eoutvar)
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
##
|
data/lib/rdoc/extend.rb
CHANGED
@@ -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
|
@@ -269,7 +269,7 @@ class RDoc::Generator::Darkfish
|
|
269
269
|
|
270
270
|
@options.static_path.each do |path|
|
271
271
|
unless File.directory? path then
|
272
|
-
FileUtils.install path, @outputdir, fu_options.merge(:mode => 0644)
|
272
|
+
FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644)
|
273
273
|
next
|
274
274
|
end
|
275
275
|
|
@@ -278,9 +278,9 @@ class RDoc::Generator::Darkfish
|
|
278
278
|
dest_file = @outputdir + entry
|
279
279
|
|
280
280
|
if File.directory? entry then
|
281
|
-
FileUtils.mkdir_p entry, fu_options
|
281
|
+
FileUtils.mkdir_p entry, **fu_options
|
282
282
|
else
|
283
|
-
FileUtils.install entry, dest_file, fu_options.merge(:mode => 0644)
|
283
|
+
FileUtils.install entry, dest_file, **fu_options.merge(:mode => 0644)
|
284
284
|
end
|
285
285
|
end
|
286
286
|
end
|
@@ -313,12 +313,16 @@ class RDoc::Generator::Darkfish
|
|
313
313
|
search_index_rel_prefix = rel_prefix
|
314
314
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
315
315
|
|
316
|
-
|
317
|
-
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
|
316
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
318
317
|
|
319
318
|
@title = @options.title
|
320
319
|
|
321
|
-
render_template template_file, out_file do |io|
|
320
|
+
render_template template_file, out_file do |io|
|
321
|
+
here = binding
|
322
|
+
# suppress 1.9.3 warning
|
323
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
324
|
+
here
|
325
|
+
end
|
322
326
|
rescue => e
|
323
327
|
error = RDoc::Error.new \
|
324
328
|
"error generating index.html: #{e.message} (#{e.class})"
|
@@ -343,14 +347,19 @@ class RDoc::Generator::Darkfish
|
|
343
347
|
search_index_rel_prefix = rel_prefix
|
344
348
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
345
349
|
|
346
|
-
|
347
|
-
|
348
|
-
svninfo = svninfo = get_svninfo(current)
|
350
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
351
|
+
svninfo = get_svninfo(current)
|
349
352
|
|
350
353
|
@title = "#{klass.type} #{klass.full_name} - #{@options.title}"
|
351
354
|
|
352
355
|
debug_msg " rendering #{out_file}"
|
353
|
-
render_template template_file, out_file do |io|
|
356
|
+
render_template template_file, out_file do |io|
|
357
|
+
here = binding
|
358
|
+
# suppress 1.9.3 warning
|
359
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
360
|
+
here.local_variable_set(:svninfo, svninfo)
|
361
|
+
here
|
362
|
+
end
|
354
363
|
end
|
355
364
|
|
356
365
|
##
|
@@ -416,8 +425,7 @@ class RDoc::Generator::Darkfish
|
|
416
425
|
search_index_rel_prefix = rel_prefix
|
417
426
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
418
427
|
|
419
|
-
|
420
|
-
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
|
428
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
421
429
|
|
422
430
|
unless filepage_file then
|
423
431
|
if file.text? then
|
@@ -434,7 +442,13 @@ class RDoc::Generator::Darkfish
|
|
434
442
|
@title += " - #{@options.title}"
|
435
443
|
template_file ||= filepage_file
|
436
444
|
|
437
|
-
render_template template_file, out_file do |io|
|
445
|
+
render_template template_file, out_file do |io|
|
446
|
+
here = binding
|
447
|
+
# suppress 1.9.3 warning
|
448
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
449
|
+
here.local_variable_set(:current, current)
|
450
|
+
here
|
451
|
+
end
|
438
452
|
end
|
439
453
|
rescue => e
|
440
454
|
error =
|
@@ -458,14 +472,19 @@ class RDoc::Generator::Darkfish
|
|
458
472
|
search_index_rel_prefix = rel_prefix
|
459
473
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
460
474
|
|
461
|
-
|
462
|
-
|
463
|
-
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
|
475
|
+
current = file
|
476
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
464
477
|
|
465
478
|
@title = "#{file.page_name} - #{@options.title}"
|
466
479
|
|
467
480
|
debug_msg " rendering #{out_file}"
|
468
|
-
render_template template_file, out_file do |io|
|
481
|
+
render_template template_file, out_file do |io|
|
482
|
+
here = binding
|
483
|
+
# suppress 1.9.3 warning
|
484
|
+
here.local_variable_set(:current, current)
|
485
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
486
|
+
here
|
487
|
+
end
|
469
488
|
end
|
470
489
|
|
471
490
|
##
|
@@ -483,12 +502,16 @@ class RDoc::Generator::Darkfish
|
|
483
502
|
search_index_rel_prefix = rel_prefix
|
484
503
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
485
504
|
|
486
|
-
|
487
|
-
asset_rel_prefix = asset_rel_prefix = ''
|
505
|
+
asset_rel_prefix = ''
|
488
506
|
|
489
507
|
@title = 'Not Found'
|
490
508
|
|
491
|
-
render_template template_file do |io|
|
509
|
+
render_template template_file do |io|
|
510
|
+
here = binding
|
511
|
+
# suppress 1.9.3 warning
|
512
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
513
|
+
here
|
514
|
+
end
|
492
515
|
rescue => e
|
493
516
|
error = RDoc::Error.new \
|
494
517
|
"error generating servlet_not_found: #{e.message} (#{e.class})"
|
@@ -540,12 +563,16 @@ class RDoc::Generator::Darkfish
|
|
540
563
|
search_index_rel_prefix = rel_prefix
|
541
564
|
search_index_rel_prefix += @asset_rel_path if @file_output
|
542
565
|
|
543
|
-
|
544
|
-
asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
|
566
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
545
567
|
|
546
568
|
@title = "Table of Contents - #{@options.title}"
|
547
569
|
|
548
|
-
render_template template_file, out_file do |io|
|
570
|
+
render_template template_file, out_file do |io|
|
571
|
+
here = binding
|
572
|
+
# suppress 1.9.3 warning
|
573
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
574
|
+
here
|
575
|
+
end
|
549
576
|
rescue => e
|
550
577
|
error = RDoc::Error.new \
|
551
578
|
"error generating table_of_contents.html: #{e.message} (#{e.class})"
|
@@ -558,16 +585,16 @@ class RDoc::Generator::Darkfish
|
|
558
585
|
return unless source.exist?
|
559
586
|
|
560
587
|
begin
|
561
|
-
FileUtils.mkdir_p File.dirname(destination), options
|
588
|
+
FileUtils.mkdir_p File.dirname(destination), **options
|
562
589
|
|
563
590
|
begin
|
564
|
-
FileUtils.ln source, destination, options
|
591
|
+
FileUtils.ln source, destination, **options
|
565
592
|
rescue Errno::EEXIST
|
566
593
|
FileUtils.rm destination
|
567
594
|
retry
|
568
595
|
end
|
569
596
|
rescue
|
570
|
-
FileUtils.cp source, destination, options
|
597
|
+
FileUtils.cp source, destination, **options
|
571
598
|
end
|
572
599
|
end
|
573
600
|
|
@@ -751,7 +778,11 @@ class RDoc::Generator::Darkfish
|
|
751
778
|
erbout = "_erbout_#{file_var}"
|
752
779
|
end
|
753
780
|
|
754
|
-
|
781
|
+
if RUBY_VERSION >= '2.6'
|
782
|
+
template = klass.new template, trim_mode: '-', eoutvar: erbout
|
783
|
+
else
|
784
|
+
template = klass.new template, nil, '-', erbout
|
785
|
+
end
|
755
786
|
@template_cache[file] = template
|
756
787
|
template
|
757
788
|
end
|