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
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# Subclass of the RDoc::Markup::ToHtml class that supports looking up method
|
4
4
|
# names, classes, etc to create links. RDoc::CrossReference is used to
|
@@ -39,26 +39,37 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
39
39
|
@hyperlink_all = @options.hyperlink_all
|
40
40
|
@show_hash = @options.show_hash
|
41
41
|
|
42
|
-
crossref_re = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
|
43
|
-
@markup.add_special crossref_re, :CROSSREF
|
44
|
-
|
45
42
|
@cross_reference = RDoc::CrossReference.new @context
|
46
43
|
end
|
47
44
|
|
45
|
+
def init_link_notation_regexp_handlings
|
46
|
+
add_regexp_handling_RDOCLINK
|
47
|
+
|
48
|
+
# The crossref must be linked before tidylink because Klass.method[:sym]
|
49
|
+
# will be processed as a tidylink first and will be broken.
|
50
|
+
crossref_re = @options.hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
|
51
|
+
@markup.add_regexp_handling crossref_re, :CROSSREF
|
52
|
+
|
53
|
+
add_regexp_handling_TIDYLINK
|
54
|
+
end
|
55
|
+
|
48
56
|
##
|
49
57
|
# Creates a link to the reference +name+ if the name exists. If +text+ is
|
50
58
|
# given it is used as the link text, otherwise +name+ is used.
|
51
59
|
|
52
|
-
def cross_reference name, text = nil
|
60
|
+
def cross_reference name, text = nil, code = true
|
53
61
|
lookup = name
|
54
62
|
|
55
63
|
name = name[1..-1] unless @show_hash if name[0, 1] == '#'
|
56
64
|
|
57
|
-
name
|
58
|
-
|
59
|
-
|
65
|
+
if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
|
66
|
+
text ||= "#{CGI.unescape $'} at <code>#{$1}</code>"
|
67
|
+
code = false
|
68
|
+
else
|
69
|
+
text ||= name
|
70
|
+
end
|
60
71
|
|
61
|
-
link lookup, text
|
72
|
+
link lookup, text, code
|
62
73
|
end
|
63
74
|
|
64
75
|
##
|
@@ -68,8 +79,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
68
79
|
# example, ToHtml is found, even without the <tt>RDoc::Markup::</tt> prefix,
|
69
80
|
# because we look for it in module Markup first.
|
70
81
|
|
71
|
-
def
|
72
|
-
name =
|
82
|
+
def handle_regexp_CROSSREF(target)
|
83
|
+
name = target.text
|
73
84
|
|
74
85
|
return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails
|
75
86
|
|
@@ -87,22 +98,22 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
87
98
|
# Handles <tt>rdoc-ref:</tt> scheme links and allows RDoc::Markup::ToHtml to
|
88
99
|
# handle other schemes.
|
89
100
|
|
90
|
-
def
|
91
|
-
return cross_reference $' if
|
101
|
+
def handle_regexp_HYPERLINK target
|
102
|
+
return cross_reference $' if target.text =~ /\Ardoc-ref:/
|
92
103
|
|
93
104
|
super
|
94
105
|
end
|
95
106
|
|
96
107
|
##
|
97
|
-
# +
|
108
|
+
# +target+ is an rdoc-schemed link that will be converted into a hyperlink.
|
98
109
|
# For the rdoc-ref scheme the cross-reference will be looked up and the
|
99
110
|
# given name will be used.
|
100
111
|
#
|
101
112
|
# All other contents are handled by
|
102
|
-
# {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#
|
113
|
+
# {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK]
|
103
114
|
|
104
|
-
def
|
105
|
-
url =
|
115
|
+
def handle_regexp_RDOCLINK target
|
116
|
+
url = target.text
|
106
117
|
|
107
118
|
case url
|
108
119
|
when /\Ardoc-ref:/ then
|
@@ -119,38 +130,42 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
119
130
|
def gen_url url, text
|
120
131
|
return super unless url =~ /\Ardoc-ref:/
|
121
132
|
|
122
|
-
|
133
|
+
name = $'
|
134
|
+
cross_reference name, text, name == text
|
123
135
|
end
|
124
136
|
|
125
137
|
##
|
126
138
|
# Creates an HTML link to +name+ with the given +text+.
|
127
139
|
|
128
|
-
def link name, text
|
129
|
-
|
130
|
-
|
131
|
-
if name =~ /(.*[^#:])@/ then
|
140
|
+
def link name, text, code = true
|
141
|
+
if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
|
132
142
|
name = $1
|
133
143
|
label = $'
|
134
144
|
end
|
135
145
|
|
136
146
|
ref = @cross_reference.resolve name, text
|
137
147
|
|
138
|
-
text = ref.output_name @context if
|
139
|
-
RDoc::MethodAttr === ref and text == original_name
|
140
|
-
|
141
148
|
case ref
|
142
149
|
when String then
|
143
150
|
ref
|
144
151
|
else
|
145
152
|
path = ref.as_href @from_path
|
146
153
|
|
154
|
+
if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
|
155
|
+
text = "<code>#{CGI.escapeHTML text}</code>"
|
156
|
+
end
|
157
|
+
|
147
158
|
if path =~ /#/ then
|
148
159
|
path << "-label-#{label}"
|
149
160
|
elsif ref.sections and
|
150
161
|
ref.sections.any? { |section| label == section.title } then
|
151
162
|
path << "##{label}"
|
152
163
|
else
|
153
|
-
|
164
|
+
if ref.respond_to?(:aref)
|
165
|
+
path << "##{ref.aref}-label-#{label}"
|
166
|
+
else
|
167
|
+
path << "#label-#{label}"
|
168
|
+
end
|
154
169
|
end if label
|
155
170
|
|
156
171
|
"<a href=\"#{path}\">#{text}</a>"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# Outputs RDoc markup as paragraphs with inline markup only.
|
4
4
|
|
@@ -44,7 +44,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
|
|
44
44
|
@mask = 0
|
45
45
|
@paragraphs = 0
|
46
46
|
|
47
|
-
@markup.
|
47
|
+
@markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
|
48
48
|
end
|
49
49
|
|
50
50
|
##
|
@@ -71,7 +71,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
|
|
71
71
|
|
72
72
|
text = paragraph.text @hard_break
|
73
73
|
|
74
|
-
@res << "#{para}#{
|
74
|
+
@res << "#{para}#{to_html text}\n"
|
75
75
|
|
76
76
|
add_paragraph
|
77
77
|
end
|
@@ -123,16 +123,16 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
|
|
123
123
|
end
|
124
124
|
|
125
125
|
##
|
126
|
-
# Removes escaping from the cross-references in +
|
126
|
+
# Removes escaping from the cross-references in +target+
|
127
127
|
|
128
|
-
def
|
129
|
-
|
128
|
+
def handle_regexp_CROSSREF target
|
129
|
+
target.text.sub(/\A\\/, '')
|
130
130
|
end
|
131
131
|
|
132
132
|
##
|
133
|
-
# +
|
133
|
+
# +target+ is a <code><br></code>
|
134
134
|
|
135
|
-
def
|
135
|
+
def handle_regexp_HARD_BREAK target
|
136
136
|
@characters -= 4
|
137
137
|
'<br>'
|
138
138
|
end
|
@@ -226,8 +226,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
|
|
226
226
|
when String then
|
227
227
|
text = convert_string item
|
228
228
|
res << truncate(text)
|
229
|
-
when RDoc::Markup::
|
230
|
-
text =
|
229
|
+
when RDoc::Markup::RegexpHandling then
|
230
|
+
text = convert_regexp_handling item
|
231
231
|
res << truncate(text)
|
232
232
|
else
|
233
233
|
raise "Unknown flow element: #{item.inspect}"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# Joins the parts of an RDoc::Markup::Paragraph into a single String.
|
4
4
|
#
|
@@ -23,37 +23,11 @@ class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter
|
|
23
23
|
# Converts the parts of +paragraph+ to a single entry.
|
24
24
|
|
25
25
|
def accept_paragraph paragraph
|
26
|
-
parts =
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
if string then
|
32
|
-
string << part
|
33
|
-
else
|
34
|
-
parts << part
|
35
|
-
string = part
|
36
|
-
end
|
37
|
-
else
|
38
|
-
parts << part
|
39
|
-
string = false
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
parts = parts.map do |part|
|
44
|
-
if String === part then
|
45
|
-
part.rstrip
|
46
|
-
else
|
47
|
-
part
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# TODO use Enumerable#chunk when Ruby 1.8 support is dropped
|
52
|
-
#parts = paragraph.parts.chunk do |part|
|
53
|
-
# String === part
|
54
|
-
#end.map do |string, chunk|
|
55
|
-
# string ? chunk.join.rstrip : chunk
|
56
|
-
#end.flatten
|
26
|
+
parts = paragraph.parts.chunk do |part|
|
27
|
+
String === part
|
28
|
+
end.map do |string, chunk|
|
29
|
+
string ? chunk.join.rstrip : chunk
|
30
|
+
end.flatten
|
57
31
|
|
58
32
|
paragraph.parts.replace parts
|
59
33
|
end
|
@@ -67,6 +41,7 @@ class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter
|
|
67
41
|
alias accept_raw ignore
|
68
42
|
alias accept_rule ignore
|
69
43
|
alias accept_verbatim ignore
|
44
|
+
alias accept_table ignore
|
70
45
|
|
71
46
|
end
|
72
47
|
|
data/lib/rdoc/markup/to_label.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
require 'cgi'
|
3
3
|
|
4
4
|
##
|
@@ -16,8 +16,8 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
|
|
16
16
|
def initialize markup = nil
|
17
17
|
super nil, markup
|
18
18
|
|
19
|
-
@markup.
|
20
|
-
@markup.
|
19
|
+
@markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
|
20
|
+
@markup.add_regexp_handling(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK)
|
21
21
|
|
22
22
|
add_tag :BOLD, '', ''
|
23
23
|
add_tag :TT, '', ''
|
@@ -36,20 +36,20 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
|
|
36
36
|
end
|
37
37
|
|
38
38
|
##
|
39
|
-
# Converts the CROSSREF +
|
39
|
+
# Converts the CROSSREF +target+ to plain text, removing the suppression
|
40
40
|
# marker, if any
|
41
41
|
|
42
|
-
def
|
43
|
-
text =
|
42
|
+
def handle_regexp_CROSSREF target
|
43
|
+
text = target.text
|
44
44
|
|
45
45
|
text.sub(/^\\/, '')
|
46
46
|
end
|
47
47
|
|
48
48
|
##
|
49
|
-
# Converts the TIDYLINK +
|
49
|
+
# Converts the TIDYLINK +target+ to just the text part
|
50
50
|
|
51
|
-
def
|
52
|
-
text =
|
51
|
+
def handle_regexp_TIDYLINK target
|
52
|
+
text = target.text
|
53
53
|
|
54
54
|
return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
|
55
55
|
|
@@ -68,7 +68,7 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
|
|
68
68
|
alias accept_rule ignore
|
69
69
|
alias accept_verbatim ignore
|
70
70
|
alias end_accepting ignore
|
71
|
-
alias
|
71
|
+
alias handle_regexp_HARD_BREAK ignore
|
72
72
|
alias start_accepting ignore
|
73
73
|
|
74
74
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
# :markup: markdown
|
3
3
|
|
4
4
|
##
|
@@ -19,8 +19,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
|
|
19
19
|
@headings[5] = ['##### ', '']
|
20
20
|
@headings[6] = ['###### ', '']
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
add_regexp_handling_RDOCLINK
|
23
|
+
add_regexp_handling_TIDYLINK
|
24
24
|
|
25
25
|
@hard_break = " \n"
|
26
26
|
end
|
@@ -37,7 +37,7 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
|
|
37
37
|
##
|
38
38
|
# Adds a newline to the output
|
39
39
|
|
40
|
-
def
|
40
|
+
def handle_regexp_HARD_BREAK target
|
41
41
|
" \n"
|
42
42
|
end
|
43
43
|
|
@@ -131,7 +131,7 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
|
|
131
131
|
@res << part
|
132
132
|
end
|
133
133
|
|
134
|
-
@res << "\n"
|
134
|
+
@res << "\n"
|
135
135
|
end
|
136
136
|
|
137
137
|
##
|
@@ -166,8 +166,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
|
|
166
166
|
##
|
167
167
|
# Converts the RDoc markup tidylink into a Markdown.style link.
|
168
168
|
|
169
|
-
def
|
170
|
-
text =
|
169
|
+
def handle_regexp_TIDYLINK target
|
170
|
+
text = target.text
|
171
171
|
|
172
172
|
return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
|
173
173
|
|
@@ -184,8 +184,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
|
|
184
184
|
##
|
185
185
|
# Converts the rdoc-...: links into a Markdown.style links.
|
186
186
|
|
187
|
-
def
|
188
|
-
handle_rdoc_link
|
187
|
+
def handle_regexp_RDOCLINK target
|
188
|
+
handle_rdoc_link target.text
|
189
189
|
end
|
190
190
|
|
191
191
|
end
|
data/lib/rdoc/markup/to_rdoc.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# Outputs RDoc markup as RDoc markup! (mostly)
|
4
4
|
|
@@ -45,7 +45,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
45
45
|
def initialize markup = nil
|
46
46
|
super nil, markup
|
47
47
|
|
48
|
-
@markup.
|
48
|
+
@markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF)
|
49
49
|
@width = 78
|
50
50
|
init_tags
|
51
51
|
|
@@ -234,7 +234,35 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
234
234
|
@res << part
|
235
235
|
end
|
236
236
|
|
237
|
-
@res << "\n"
|
237
|
+
@res << "\n"
|
238
|
+
end
|
239
|
+
|
240
|
+
##
|
241
|
+
# Adds +table+ to the output
|
242
|
+
|
243
|
+
def accept_table header, body, aligns
|
244
|
+
widths = header.zip(body) do |h, b|
|
245
|
+
[h.size, b.size].max
|
246
|
+
end
|
247
|
+
aligns = aligns.map do |a|
|
248
|
+
case a
|
249
|
+
when nil
|
250
|
+
:center
|
251
|
+
when :left
|
252
|
+
:ljust
|
253
|
+
when :right
|
254
|
+
:rjust
|
255
|
+
end
|
256
|
+
end
|
257
|
+
@res << header.zip(widths, aligns) do |h, w, a|
|
258
|
+
h.__send__(a, w)
|
259
|
+
end.join("|").rstrip << "\n"
|
260
|
+
@res << widths.map {|w| "-" * w }.join("|") << "\n"
|
261
|
+
body.each do |row|
|
262
|
+
@res << row.zip(widths, aligns) do |t, w, a|
|
263
|
+
t.__send__(a, w)
|
264
|
+
end.join("|").rstrip << "\n"
|
265
|
+
end
|
238
266
|
end
|
239
267
|
|
240
268
|
##
|
@@ -253,10 +281,10 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
253
281
|
end
|
254
282
|
|
255
283
|
##
|
256
|
-
# Removes preceding \\ from the suppressed crossref +
|
284
|
+
# Removes preceding \\ from the suppressed crossref +target+
|
257
285
|
|
258
|
-
def
|
259
|
-
text =
|
286
|
+
def handle_regexp_SUPPRESSED_CROSSREF target
|
287
|
+
text = target.text
|
260
288
|
text = text.sub('\\', '') unless in_tt?
|
261
289
|
text
|
262
290
|
end
|
@@ -264,7 +292,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
264
292
|
##
|
265
293
|
# Adds a newline to the output
|
266
294
|
|
267
|
-
def
|
295
|
+
def handle_regexp_HARD_BREAK target
|
268
296
|
"\n"
|
269
297
|
end
|
270
298
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# Extracts just the RDoc::Markup::Heading elements from a
|
4
4
|
# RDoc::Markup::Document to help build a table of contents
|
@@ -82,6 +82,7 @@ class RDoc::Markup::ToTableOfContents < RDoc::Markup::Formatter
|
|
82
82
|
alias accept_list_item_end ignore
|
83
83
|
alias accept_list_end_bullet ignore
|
84
84
|
alias accept_list_start ignore
|
85
|
+
alias accept_table ignore
|
85
86
|
# :startdoc:
|
86
87
|
|
87
88
|
end
|
data/lib/rdoc/markup/to_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# Extracts sections of text enclosed in plus, tt or code. Used to discover
|
4
4
|
# undocumented parameters.
|
@@ -91,8 +91,8 @@ class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter
|
|
91
91
|
when RDoc::Markup::AttrChanger then
|
92
92
|
off_tags res, item
|
93
93
|
on_tags res, item
|
94
|
-
when RDoc::Markup::
|
95
|
-
@res <<
|
94
|
+
when RDoc::Markup::RegexpHandling then
|
95
|
+
@res << convert_regexp_handling(item) if in_tt? # TODO can this happen?
|
96
96
|
else
|
97
97
|
raise "Unknown flow element: #{item.inspect}"
|
98
98
|
end
|
data/lib/rdoc/markup/verbatim.rb
CHANGED
data/lib/rdoc/markup.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# RDoc::Markup parses plain text documents and attempts to decompose them into
|
4
4
|
# their constituent parts. Some of these parts are high-level: paragraphs,
|
@@ -65,17 +65,16 @@
|
|
65
65
|
# puts h.convert(input_string)
|
66
66
|
#
|
67
67
|
# You can extend the RDoc::Markup parser to recognize new markup
|
68
|
-
# sequences, and to add
|
69
|
-
#
|
70
|
-
# and also make the sequences {word} and \<no>text...</no> signify
|
68
|
+
# sequences, and to add regexp handling. Here we make WikiWords significant to
|
69
|
+
# the parser, and also make the sequences {word} and \<no>text...</no> signify
|
71
70
|
# strike-through text. We then subclass the HTML output class to deal
|
72
71
|
# with these:
|
73
72
|
#
|
74
73
|
# require 'rdoc'
|
75
74
|
#
|
76
75
|
# class WikiHtml < RDoc::Markup::ToHtml
|
77
|
-
# def
|
78
|
-
# "<font color=red>" +
|
76
|
+
# def handle_regexp_WIKIWORD(target)
|
77
|
+
# "<font color=red>" + target.text + "</font>"
|
79
78
|
# end
|
80
79
|
# end
|
81
80
|
#
|
@@ -83,7 +82,7 @@
|
|
83
82
|
# markup.add_word_pair("{", "}", :STRIKE)
|
84
83
|
# markup.add_html("no", :STRIKE)
|
85
84
|
#
|
86
|
-
# markup.
|
85
|
+
# markup.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
|
87
86
|
#
|
88
87
|
# wh = WikiHtml.new RDoc::Options.new, markup
|
89
88
|
# wh.add_tag(:STRIKE, "<strike>", "</strike>")
|
@@ -377,7 +376,7 @@
|
|
377
376
|
#
|
378
377
|
# Example links:
|
379
378
|
#
|
380
|
-
# https://github.com/
|
379
|
+
# https://github.com/ruby/rdoc
|
381
380
|
# mailto:user@example.com
|
382
381
|
# {RDoc Documentation}[http://rdoc.rubyforge.org]
|
383
382
|
# {RDoc Markup}[rdoc-ref:RDoc::Markup]
|
@@ -764,7 +763,7 @@ Ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} #{RUBY_RELEASE_DATE}
|
|
764
763
|
|
765
764
|
Please file a bug report with the above information at:
|
766
765
|
|
767
|
-
https://github.com/
|
766
|
+
https://github.com/ruby/rdoc/issues
|
768
767
|
|
769
768
|
EOF
|
770
769
|
raise
|
@@ -800,13 +799,12 @@ https://github.com/rdoc/rdoc/issues
|
|
800
799
|
# Add to other inline sequences. For example, we could add WikiWords using
|
801
800
|
# something like:
|
802
801
|
#
|
803
|
-
# parser.
|
802
|
+
# parser.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
|
804
803
|
#
|
805
|
-
# Each wiki word will be presented to the output formatter
|
806
|
-
# accept_special method.
|
804
|
+
# Each wiki word will be presented to the output formatter.
|
807
805
|
|
808
|
-
def
|
809
|
-
@attribute_manager.
|
806
|
+
def add_regexp_handling(pattern, name)
|
807
|
+
@attribute_manager.add_regexp_handling(pattern, name)
|
810
808
|
end
|
811
809
|
|
812
810
|
##
|
@@ -832,7 +830,7 @@ https://github.com/rdoc/rdoc/issues
|
|
832
830
|
autoload :AttrSpan, 'rdoc/markup/attr_span'
|
833
831
|
autoload :Attributes, 'rdoc/markup/attributes'
|
834
832
|
autoload :AttributeManager, 'rdoc/markup/attribute_manager'
|
835
|
-
autoload :
|
833
|
+
autoload :RegexpHandling, 'rdoc/markup/regexp_handling'
|
836
834
|
|
837
835
|
# RDoc::Markup AST
|
838
836
|
autoload :BlankLine, 'rdoc/markup/blank_line'
|
@@ -845,14 +843,13 @@ https://github.com/rdoc/rdoc/issues
|
|
845
843
|
autoload :List, 'rdoc/markup/list'
|
846
844
|
autoload :ListItem, 'rdoc/markup/list_item'
|
847
845
|
autoload :Paragraph, 'rdoc/markup/paragraph'
|
846
|
+
autoload :Table, 'rdoc/markup/table'
|
848
847
|
autoload :Raw, 'rdoc/markup/raw'
|
849
848
|
autoload :Rule, 'rdoc/markup/rule'
|
850
849
|
autoload :Verbatim, 'rdoc/markup/verbatim'
|
851
850
|
|
852
851
|
# Formatters
|
853
852
|
autoload :Formatter, 'rdoc/markup/formatter'
|
854
|
-
autoload :FormatterTestCase, 'rdoc/markup/formatter_test_case'
|
855
|
-
autoload :TextFormatterTestCase, 'rdoc/markup/text_formatter_test_case'
|
856
853
|
|
857
854
|
autoload :ToAnsi, 'rdoc/markup/to_ansi'
|
858
855
|
autoload :ToBs, 'rdoc/markup/to_bs'
|
data/lib/rdoc/meta_method.rb
CHANGED
data/lib/rdoc/method_attr.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# Abstract class representing either a method or an attribute.
|
4
4
|
|
@@ -188,7 +188,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
188
188
|
next if String === ancestor
|
189
189
|
next if parent == ancestor
|
190
190
|
|
191
|
-
other = ancestor.find_method_named('#'
|
191
|
+
other = ancestor.find_method_named('#' + name) ||
|
192
192
|
ancestor.find_attribute_named(name)
|
193
193
|
|
194
194
|
return other if other
|
data/lib/rdoc/mixin.rb
CHANGED
data/lib/rdoc/normal_class.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
##
|
3
3
|
# A normal class, neither singleton nor anonymous
|
4
4
|
|
@@ -47,9 +47,9 @@ class RDoc::NormalClass < RDoc::ClassModule
|
|
47
47
|
def to_s # :nodoc:
|
48
48
|
display = "#{self.class.name} #{self.full_name}"
|
49
49
|
if superclass
|
50
|
-
display
|
50
|
+
display += ' < ' + (superclass.is_a?(String) ? superclass : superclass.full_name)
|
51
51
|
end
|
52
|
-
display
|
52
|
+
display += ' -> ' + is_alias_for.to_s if is_alias_for
|
53
53
|
display
|
54
54
|
end
|
55
55
|
|
data/lib/rdoc/normal_module.rb
CHANGED