rdoc 6.3.4.1 → 8.0.0
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 +4 -4
- data/CONTRIBUTING.md +195 -0
- data/History.rdoc +65 -63
- data/LEGAL.rdoc +7 -1
- data/LICENSE.rdoc +6 -0
- data/README.md +236 -0
- data/RI.md +842 -0
- data/TODO.rdoc +8 -7
- data/doc/markup_reference/markdown.md +659 -0
- data/doc/markup_reference/rdoc.rdoc +1169 -0
- data/exe/rdoc +0 -1
- data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -18
- data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +50 -24
- data/lib/rdoc/{attr.rb → code_object/attr.rb} +16 -14
- data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +225 -58
- data/lib/rdoc/{constant.rb → code_object/constant.rb} +44 -10
- data/lib/rdoc/code_object/context/section.rb +182 -0
- data/lib/rdoc/{context.rb → code_object/context.rb} +78 -106
- data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -1
- data/lib/rdoc/{include.rb → code_object/include.rb} +0 -1
- data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +46 -48
- data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +6 -4
- data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +2 -3
- data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
- data/lib/rdoc/{require.rb → code_object/require.rb} +1 -2
- data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +5 -1
- data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +60 -63
- data/lib/rdoc/code_object.rb +11 -39
- data/lib/rdoc/code_objects.rb +1 -2
- data/lib/rdoc/comment.rb +202 -99
- data/lib/rdoc/cross_reference.rb +75 -62
- data/lib/rdoc/encoding.rb +8 -24
- data/lib/rdoc/erb_partial.rb +1 -2
- data/lib/rdoc/erbio.rb +3 -8
- data/lib/rdoc/generator/aliki.rb +200 -0
- data/lib/rdoc/generator/darkfish.rb +156 -122
- data/lib/rdoc/generator/json_index.rb +8 -24
- data/lib/rdoc/generator/markup.rb +70 -34
- data/lib/rdoc/generator/pot/message_extractor.rb +7 -7
- data/lib/rdoc/generator/pot/po.rb +1 -1
- data/lib/rdoc/generator/pot/po_entry.rb +8 -8
- data/lib/rdoc/generator/pot.rb +1 -5
- data/lib/rdoc/generator/ri.rb +1 -2
- data/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
- data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
- data/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
- data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
- data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
- data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
- data/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
- data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
- data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
- data/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
- data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
- data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
- data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
- data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -14
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +11 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +11 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +25 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +2 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +28 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +138 -90
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +420 -358
- 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 +14 -12
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +59 -3
- data/lib/rdoc/generator/template/darkfish/js/search.js +15 -5
- data/lib/rdoc/generator/template/darkfish/page.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +12 -9
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +24 -21
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +35 -21
- data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
- data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
- data/lib/rdoc/generator.rb +6 -5
- data/lib/rdoc/i18n/text.rb +3 -3
- data/lib/rdoc/i18n.rb +1 -1
- data/lib/rdoc/known_classes.rb +5 -4
- data/lib/rdoc/markdown/entities.rb +0 -1
- data/lib/rdoc/markdown/literals.kpeg +0 -2
- data/lib/rdoc/markdown/literals.rb +0 -1
- data/lib/rdoc/markdown.kpeg +140 -62
- data/lib/rdoc/markdown.rb +1015 -873
- data/lib/rdoc/markup/blank_line.rb +25 -24
- data/lib/rdoc/markup/block_quote.rb +1 -2
- data/lib/rdoc/markup/document.rb +10 -11
- data/lib/rdoc/markup/element.rb +21 -0
- data/lib/rdoc/markup/formatter.rb +134 -115
- data/lib/rdoc/markup/hard_break.rb +30 -28
- data/lib/rdoc/markup/heading.rb +163 -72
- data/lib/rdoc/markup/include.rb +3 -4
- data/lib/rdoc/markup/indented_paragraph.rb +4 -5
- data/lib/rdoc/markup/inline_parser.rb +312 -0
- data/lib/rdoc/markup/list.rb +6 -7
- data/lib/rdoc/markup/list_item.rb +6 -7
- data/lib/rdoc/markup/paragraph.rb +2 -3
- data/lib/rdoc/markup/parser.rb +29 -19
- data/lib/rdoc/markup/pre_process.rb +39 -18
- data/lib/rdoc/markup/raw.rb +52 -56
- data/lib/rdoc/markup/rule.rb +2 -3
- data/lib/rdoc/markup/table.rb +49 -32
- data/lib/rdoc/markup/to_ansi.rb +58 -8
- data/lib/rdoc/markup/to_bs.rb +47 -38
- data/lib/rdoc/markup/to_html.rb +343 -105
- data/lib/rdoc/markup/to_html_crossref.rb +143 -58
- data/lib/rdoc/markup/to_html_snippet.rb +78 -76
- data/lib/rdoc/markup/to_joined_paragraph.rb +3 -9
- data/lib/rdoc/markup/to_label.rb +34 -25
- data/lib/rdoc/markup/to_markdown.rb +74 -51
- data/lib/rdoc/markup/to_rdoc.rb +141 -82
- data/lib/rdoc/markup/to_table_of_contents.rb +4 -5
- data/lib/rdoc/markup/to_test.rb +10 -3
- data/lib/rdoc/markup/to_tt_only.rb +17 -31
- data/lib/rdoc/markup/verbatim.rb +5 -6
- data/lib/rdoc/markup.rb +59 -707
- data/lib/rdoc/options.rb +228 -101
- data/lib/rdoc/parser/c.rb +186 -184
- data/lib/rdoc/parser/changelog.rb +57 -13
- data/lib/rdoc/parser/markdown.rb +0 -2
- data/lib/rdoc/parser/rbs.rb +275 -0
- data/lib/rdoc/parser/rd.rb +0 -1
- data/lib/rdoc/parser/ruby.rb +963 -2024
- data/lib/rdoc/parser/ruby_colorizer.rb +253 -0
- data/lib/rdoc/parser/simple.rb +6 -23
- data/lib/rdoc/parser/text.rb +0 -1
- data/lib/rdoc/parser.rb +35 -14
- data/lib/rdoc/rbs_helper.rb +186 -0
- data/lib/rdoc/rd/block_parser.rb +659 -11
- data/lib/rdoc/rd/block_parser.ry +13 -9
- data/lib/rdoc/rd/inline.rb +4 -5
- data/lib/rdoc/rd/inline_parser.rb +646 -2
- data/lib/rdoc/rd.rb +4 -5
- data/lib/rdoc/rdoc.rb +234 -90
- data/lib/rdoc/ri/driver.rb +172 -172
- data/lib/rdoc/ri/paths.rb +3 -3
- data/lib/rdoc/{servlet.rb → ri/servlet.rb} +28 -27
- data/lib/rdoc/ri/store.rb +0 -1
- data/lib/rdoc/ri/task.rb +3 -3
- data/lib/rdoc/ri.rb +5 -5
- data/lib/rdoc/rubygems_hook.rb +106 -25
- data/lib/rdoc/server.rb +460 -0
- data/lib/rdoc/stats/normal.rb +1 -1
- data/lib/rdoc/stats/quiet.rb +1 -2
- data/lib/rdoc/stats/verbose.rb +3 -5
- data/lib/rdoc/stats.rb +158 -136
- data/lib/rdoc/store.rb +267 -48
- data/lib/rdoc/task.rb +54 -28
- data/lib/rdoc/text.rb +60 -120
- data/lib/rdoc/token_stream.rb +30 -45
- data/lib/rdoc/tom_doc.rb +9 -15
- data/lib/rdoc/version.rb +3 -1
- data/lib/rdoc.rb +90 -52
- data/lib/rubygems_plugin.rb +14 -0
- data/man/ri.1 +2 -0
- data/rdoc-logo.svg +43 -0
- data/rdoc.gemspec +25 -200
- metadata +120 -53
- data/CONTRIBUTING.rdoc +0 -220
- data/ExampleMarkdown.md +0 -37
- data/ExampleRDoc.rdoc +0 -208
- data/Gemfile +0 -12
- data/README.rdoc +0 -129
- data/RI.rdoc +0 -57
- data/Rakefile +0 -101
- data/bin/console +0 -7
- data/bin/setup +0 -6
- data/lib/rdoc/anon_class.rb +0 -11
- data/lib/rdoc/context/section.rb +0 -232
- 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/json_index/.document +0 -1
- data/lib/rdoc/ghost_method.rb +0 -7
- data/lib/rdoc/markup/attr_changer.rb +0 -23
- data/lib/rdoc/markup/attr_span.rb +0 -36
- data/lib/rdoc/markup/attribute_manager.rb +0 -409
- data/lib/rdoc/markup/attributes.rb +0 -71
- data/lib/rdoc/markup/regexp_handling.rb +0 -41
- data/lib/rdoc/meta_method.rb +0 -7
- data/lib/rdoc/parser/ripper_state_lex.rb +0 -590
- data/lib/rdoc/parser/ruby_tools.rb +0 -167
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
##
|
|
3
|
-
# An empty line. This class is a singleton.
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# An empty line
|
|
6
|
+
class BlankLine < Element
|
|
7
|
+
@instance = new
|
|
8
|
+
|
|
9
|
+
# RDoc::Markup::BlankLine is a singleton
|
|
10
|
+
#: () -> BlankLine
|
|
11
|
+
def self.new
|
|
12
|
+
@instance
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Calls #accept_blank_line on +visitor+
|
|
16
|
+
# @override
|
|
17
|
+
#: (untyped) -> void
|
|
18
|
+
def accept(visitor)
|
|
19
|
+
visitor.accept_blank_line(self)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @override
|
|
23
|
+
#: (PP) -> void
|
|
24
|
+
def pretty_print(q) # :nodoc:
|
|
25
|
+
q.text("blankline")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
25
28
|
end
|
|
26
|
-
|
|
27
29
|
end
|
|
28
|
-
|
data/lib/rdoc/markup/document.rb
CHANGED
|
@@ -26,7 +26,7 @@ class RDoc::Markup::Document
|
|
|
26
26
|
##
|
|
27
27
|
# Creates a new Document with +parts+
|
|
28
28
|
|
|
29
|
-
def initialize
|
|
29
|
+
def initialize(*parts)
|
|
30
30
|
@parts = []
|
|
31
31
|
@parts.concat parts
|
|
32
32
|
|
|
@@ -37,7 +37,7 @@ class RDoc::Markup::Document
|
|
|
37
37
|
##
|
|
38
38
|
# Appends +part+ to the document
|
|
39
39
|
|
|
40
|
-
def <<
|
|
40
|
+
def <<(part)
|
|
41
41
|
case part
|
|
42
42
|
when RDoc::Markup::Document then
|
|
43
43
|
unless part.empty? then
|
|
@@ -53,7 +53,7 @@ class RDoc::Markup::Document
|
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
def ==
|
|
56
|
+
def ==(other) # :nodoc:
|
|
57
57
|
self.class == other.class and
|
|
58
58
|
@file == other.file and
|
|
59
59
|
@parts == other.parts
|
|
@@ -62,7 +62,7 @@ class RDoc::Markup::Document
|
|
|
62
62
|
##
|
|
63
63
|
# Runs this document and all its #items through +visitor+
|
|
64
64
|
|
|
65
|
-
def accept
|
|
65
|
+
def accept(visitor)
|
|
66
66
|
visitor.start_accepting
|
|
67
67
|
|
|
68
68
|
visitor.accept_document self
|
|
@@ -73,14 +73,14 @@ class RDoc::Markup::Document
|
|
|
73
73
|
##
|
|
74
74
|
# Concatenates the given +parts+ onto the document
|
|
75
75
|
|
|
76
|
-
def concat
|
|
76
|
+
def concat(parts)
|
|
77
77
|
self.parts.concat parts
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
##
|
|
81
81
|
# Enumerator for the parts of this document
|
|
82
82
|
|
|
83
|
-
def each
|
|
83
|
+
def each(&block)
|
|
84
84
|
@parts.each(&block)
|
|
85
85
|
end
|
|
86
86
|
|
|
@@ -94,7 +94,7 @@ class RDoc::Markup::Document
|
|
|
94
94
|
##
|
|
95
95
|
# The file this Document was created from.
|
|
96
96
|
|
|
97
|
-
def file=
|
|
97
|
+
def file=(location)
|
|
98
98
|
@file = case location
|
|
99
99
|
when RDoc::TopLevel then
|
|
100
100
|
location.relative_name
|
|
@@ -111,7 +111,7 @@ class RDoc::Markup::Document
|
|
|
111
111
|
#
|
|
112
112
|
# The information in +other+ is preferred over the receiver
|
|
113
113
|
|
|
114
|
-
def merge
|
|
114
|
+
def merge(other)
|
|
115
115
|
if empty? then
|
|
116
116
|
@parts = other.parts
|
|
117
117
|
return self
|
|
@@ -135,7 +135,7 @@ class RDoc::Markup::Document
|
|
|
135
135
|
RDoc::Markup::Document === @parts.first
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
-
def pretty_print
|
|
138
|
+
def pretty_print(q) # :nodoc:
|
|
139
139
|
start = @file ? "[doc (#{@file}): " : '[doc: '
|
|
140
140
|
|
|
141
141
|
q.group 2, start, ']' do
|
|
@@ -148,7 +148,7 @@ class RDoc::Markup::Document
|
|
|
148
148
|
##
|
|
149
149
|
# Appends +parts+ to the document
|
|
150
150
|
|
|
151
|
-
def push
|
|
151
|
+
def push(*parts)
|
|
152
152
|
self.parts.concat parts
|
|
153
153
|
end
|
|
154
154
|
|
|
@@ -162,4 +162,3 @@ class RDoc::Markup::Document
|
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
end
|
|
165
|
-
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# Base class defining the interface for all markup elements found in documentation
|
|
6
|
+
# @abstract
|
|
7
|
+
class Element
|
|
8
|
+
# @abstract
|
|
9
|
+
#: (untyped) -> void
|
|
10
|
+
def accept(visitor)
|
|
11
|
+
raise NotImplementedError, "#{self.class} must implement the accept method"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# @abstract
|
|
15
|
+
#: (PP) -> void
|
|
16
|
+
def pretty_print(q)
|
|
17
|
+
raise NotImplementedError, "#{self.class} must implement the pretty_print method"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -10,18 +10,14 @@
|
|
|
10
10
|
# RDoc::Markup::FormatterTestCase. If you're writing a text-output formatter
|
|
11
11
|
# use RDoc::Markup::TextFormatterTestCase which provides extra test cases.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
##
|
|
16
|
-
# Tag for inline markup containing a +bit+ for the bitmask and the +on+ and
|
|
17
|
-
# +off+ triggers.
|
|
13
|
+
require 'rdoc/markup/inline_parser'
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
class RDoc::Markup::Formatter
|
|
20
16
|
|
|
21
17
|
##
|
|
22
18
|
# Converts a target url to one that is relative to a given path
|
|
23
19
|
|
|
24
|
-
def self.gen_relative_url
|
|
20
|
+
def self.gen_relative_url(path, target)
|
|
25
21
|
from = File.dirname path
|
|
26
22
|
to, to_file = File.split target
|
|
27
23
|
|
|
@@ -45,28 +41,16 @@ class RDoc::Markup::Formatter
|
|
|
45
41
|
##
|
|
46
42
|
# Creates a new Formatter
|
|
47
43
|
|
|
48
|
-
def initialize
|
|
49
|
-
@
|
|
50
|
-
|
|
51
|
-
@markup = markup || RDoc::Markup.new
|
|
52
|
-
@am = @markup.attribute_manager
|
|
53
|
-
@am.add_regexp_handling(/<br>/, :HARD_BREAK)
|
|
44
|
+
def initialize
|
|
45
|
+
@markup = RDoc::Markup.new
|
|
54
46
|
|
|
55
|
-
@attributes = @am.attributes
|
|
56
|
-
|
|
57
|
-
@attr_tags = []
|
|
58
|
-
|
|
59
|
-
@in_tt = 0
|
|
60
|
-
@tt_bit = @attributes.bitmap_for :TT
|
|
61
|
-
|
|
62
|
-
@hard_break = ''
|
|
63
47
|
@from_path = '.'
|
|
64
48
|
end
|
|
65
49
|
|
|
66
50
|
##
|
|
67
51
|
# Adds +document+ to the output
|
|
68
52
|
|
|
69
|
-
def accept_document
|
|
53
|
+
def accept_document(document)
|
|
70
54
|
document.parts.each do |item|
|
|
71
55
|
case item
|
|
72
56
|
when RDoc::Markup::Document then # HACK
|
|
@@ -85,150 +69,186 @@ class RDoc::Markup::Formatter
|
|
|
85
69
|
end
|
|
86
70
|
|
|
87
71
|
##
|
|
88
|
-
#
|
|
89
|
-
# <word>[<url>]
|
|
90
|
-
|
|
91
|
-
def add_regexp_handling_TIDYLINK
|
|
92
|
-
@markup.add_regexp_handling(/(?:
|
|
93
|
-
\{.*?\} | # multi-word label
|
|
94
|
-
\b[^\s{}]+? # single-word label
|
|
95
|
-
)
|
|
72
|
+
# Allows +tag+ to be decorated with additional information.
|
|
96
73
|
|
|
97
|
-
|
|
98
|
-
|
|
74
|
+
def annotate(tag)
|
|
75
|
+
tag
|
|
99
76
|
end
|
|
100
77
|
|
|
101
78
|
##
|
|
102
|
-
#
|
|
103
|
-
# tags for flexibility
|
|
79
|
+
# Marks up +content+
|
|
104
80
|
|
|
105
|
-
def
|
|
106
|
-
|
|
107
|
-
@attr_tags << InlineTag.new(attr, start, stop)
|
|
81
|
+
def convert(content)
|
|
82
|
+
@markup.convert content, self
|
|
108
83
|
end
|
|
109
84
|
|
|
110
|
-
|
|
111
|
-
# Allows +tag+ to be decorated with additional information.
|
|
85
|
+
# Applies regexp handling to +text+ and returns an array of [text, converted?] pairs.
|
|
112
86
|
|
|
113
|
-
def
|
|
114
|
-
|
|
87
|
+
def apply_regexp_handling(text)
|
|
88
|
+
matched = []
|
|
89
|
+
@markup.regexp_handlings.each_with_index do |(pattern, name), priority|
|
|
90
|
+
text.scan(pattern) do
|
|
91
|
+
m = Regexp.last_match
|
|
92
|
+
idx = m[1] ? 1 : 0
|
|
93
|
+
matched << [m.begin(idx), m.end(idx), m[idx], name, priority]
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
# If the start positions are the same, prefer the earlier-registered one
|
|
97
|
+
# (lower numeric priority from each_with_index).
|
|
98
|
+
matched.sort_by! {|beg_pos, _, _, _, priority| [beg_pos, priority] }
|
|
99
|
+
|
|
100
|
+
pos = 0
|
|
101
|
+
output = []
|
|
102
|
+
matched.each do |beg_pos, end_pos, s, name|
|
|
103
|
+
next if beg_pos < pos
|
|
104
|
+
|
|
105
|
+
output << [text[pos...beg_pos], false] if beg_pos != pos
|
|
106
|
+
handled = public_send(:"handle_regexp_#{name}", s)
|
|
107
|
+
output << [handled, true]
|
|
108
|
+
pos = end_pos
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
output << [text[pos..], false] if pos < text.size
|
|
112
|
+
output
|
|
115
113
|
end
|
|
116
114
|
|
|
117
|
-
|
|
118
|
-
#
|
|
115
|
+
# Called when processing plain text while traversing inline nodes from handle_inline.
|
|
116
|
+
# +text+ may need proper escaping.
|
|
119
117
|
|
|
120
|
-
def
|
|
121
|
-
@markup.convert content, self
|
|
118
|
+
def handle_PLAIN_TEXT(text)
|
|
122
119
|
end
|
|
123
120
|
|
|
124
|
-
|
|
125
|
-
#
|
|
121
|
+
# Called when processing regexp-handling-processed text while traversing inline nodes from handle_inline.
|
|
122
|
+
# +text+ may contain markup tags.
|
|
123
|
+
|
|
124
|
+
def handle_REGEXP_HANDLING_TEXT(text)
|
|
125
|
+
end
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
# Called when processing text node while traversing inline nodes from handle_inline.
|
|
128
|
+
# Apply regexp handling and dispatch to the appropriate handler: handle_REGEXP_HANDLING_TEXT or handle_PLAIN_TEXT.
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
when RDoc::Markup::AttrChanger then
|
|
135
|
-
off_tags res, item
|
|
136
|
-
on_tags res, item
|
|
137
|
-
when RDoc::Markup::RegexpHandling then
|
|
138
|
-
res << convert_regexp_handling(item)
|
|
130
|
+
def handle_TEXT(text)
|
|
131
|
+
apply_regexp_handling(text).each do |part, converted|
|
|
132
|
+
if converted
|
|
133
|
+
handle_REGEXP_HANDLING_TEXT(part)
|
|
139
134
|
else
|
|
140
|
-
|
|
135
|
+
handle_PLAIN_TEXT(part)
|
|
141
136
|
end
|
|
142
137
|
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Called when processing a hard break while traversing inline nodes from handle_inline.
|
|
143
141
|
|
|
144
|
-
|
|
142
|
+
def handle_HARD_BREAK
|
|
145
143
|
end
|
|
146
144
|
|
|
147
|
-
|
|
148
|
-
#
|
|
145
|
+
# Called when processing bold nodes while traversing inline nodes from handle_inline.
|
|
146
|
+
# Traverse the children nodes and dispatch to the appropriate handlers.
|
|
149
147
|
|
|
150
|
-
def
|
|
151
|
-
|
|
148
|
+
def handle_BOLD(nodes)
|
|
149
|
+
traverse_inline_nodes(nodes)
|
|
150
|
+
end
|
|
152
151
|
|
|
153
|
-
|
|
152
|
+
# Called when processing emphasis nodes while traversing inline nodes from handle_inline.
|
|
153
|
+
# Traverse the children nodes and dispatch to the appropriate handlers.
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
def handle_EM(nodes)
|
|
156
|
+
traverse_inline_nodes(nodes)
|
|
157
|
+
end
|
|
157
158
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
handled = true
|
|
161
|
-
end
|
|
162
|
-
end
|
|
159
|
+
# Called when processing bold word nodes while traversing inline nodes from handle_inline.
|
|
160
|
+
# +word+ may need proper escaping.
|
|
163
161
|
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
def handle_BOLD_WORD(word)
|
|
163
|
+
handle_PLAIN_TEXT(word)
|
|
164
|
+
end
|
|
166
165
|
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
# Called when processing emphasis word nodes while traversing inline nodes from handle_inline.
|
|
167
|
+
# +word+ may need proper escaping.
|
|
169
168
|
|
|
170
|
-
|
|
169
|
+
def handle_EM_WORD(word)
|
|
170
|
+
handle_PLAIN_TEXT(word)
|
|
171
171
|
end
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
#
|
|
173
|
+
# Called when processing tt nodes while traversing inline nodes from handle_inline.
|
|
174
|
+
# +code+ may need proper escaping.
|
|
175
175
|
|
|
176
|
-
def
|
|
177
|
-
|
|
176
|
+
def handle_TT(code)
|
|
177
|
+
handle_PLAIN_TEXT(code)
|
|
178
178
|
end
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
#
|
|
182
|
-
#
|
|
183
|
-
# ##
|
|
184
|
-
# # We don't support raw nodes in ToNoRaw
|
|
185
|
-
#
|
|
186
|
-
# alias accept_raw ignore
|
|
180
|
+
# Called when processing strike nodes while traversing inline nodes from handle_inline.
|
|
181
|
+
# Traverse the children nodes and dispatch to the appropriate handlers.
|
|
187
182
|
|
|
188
|
-
def
|
|
183
|
+
def handle_STRIKE(nodes)
|
|
184
|
+
traverse_inline_nodes(nodes)
|
|
189
185
|
end
|
|
190
186
|
|
|
191
|
-
|
|
192
|
-
#
|
|
187
|
+
# Called when processing tidylink nodes while traversing inline nodes from handle_inline.
|
|
188
|
+
# +label_part+ is an array of strings or nodes representing the link label.
|
|
189
|
+
# +url+ is the link URL.
|
|
190
|
+
# Traverse the label_part nodes and dispatch to the appropriate handlers.
|
|
193
191
|
|
|
194
|
-
def
|
|
195
|
-
|
|
192
|
+
def handle_TIDYLINK(label_part, url)
|
|
193
|
+
traverse_inline_nodes(label_part)
|
|
196
194
|
end
|
|
197
195
|
|
|
198
|
-
|
|
199
|
-
# Turns on tags for +item+ on +res+
|
|
196
|
+
# Parses inline +text+, traverse the resulting nodes, and calls the appropriate handler methods.
|
|
200
197
|
|
|
201
|
-
def
|
|
202
|
-
|
|
203
|
-
|
|
198
|
+
def handle_inline(text)
|
|
199
|
+
nodes = RDoc::Markup::InlineParser.new(text).parse
|
|
200
|
+
traverse_inline_nodes(nodes)
|
|
201
|
+
end
|
|
204
202
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
203
|
+
# Traverses +nodes+ and calls the appropriate handler methods
|
|
204
|
+
# Nodes formats are described in RDoc::Markup::InlineParser#parse
|
|
205
|
+
|
|
206
|
+
def traverse_inline_nodes(nodes)
|
|
207
|
+
nodes.each do |node|
|
|
208
|
+
next handle_TEXT(node) if String === node
|
|
209
|
+
case node[:type]
|
|
210
|
+
when :TIDYLINK
|
|
211
|
+
handle_TIDYLINK(node[:children], node[:url])
|
|
212
|
+
when :HARD_BREAK
|
|
213
|
+
handle_HARD_BREAK
|
|
214
|
+
when :BOLD
|
|
215
|
+
handle_BOLD(node[:children])
|
|
216
|
+
when :BOLD_WORD
|
|
217
|
+
handle_BOLD_WORD(node[:children][0] || '')
|
|
218
|
+
when :EM
|
|
219
|
+
handle_EM(node[:children])
|
|
220
|
+
when :EM_WORD
|
|
221
|
+
handle_EM_WORD(node[:children][0] || '')
|
|
222
|
+
when :TT
|
|
223
|
+
handle_TT(node[:children][0] || '')
|
|
224
|
+
when :STRIKE
|
|
225
|
+
handle_STRIKE(node[:children])
|
|
209
226
|
end
|
|
210
227
|
end
|
|
211
228
|
end
|
|
212
229
|
|
|
213
230
|
##
|
|
214
|
-
#
|
|
231
|
+
# Converts a string to be fancier if desired
|
|
215
232
|
|
|
216
|
-
def
|
|
217
|
-
|
|
218
|
-
|
|
233
|
+
def convert_string(string)
|
|
234
|
+
string
|
|
235
|
+
end
|
|
219
236
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
237
|
+
##
|
|
238
|
+
# Use ignore in your subclass to ignore the content of a node.
|
|
239
|
+
#
|
|
240
|
+
# ##
|
|
241
|
+
# # We don't support raw nodes in ToNoRaw
|
|
242
|
+
#
|
|
243
|
+
# alias accept_raw ignore
|
|
244
|
+
|
|
245
|
+
def ignore(*node)
|
|
226
246
|
end
|
|
227
247
|
|
|
228
248
|
##
|
|
229
249
|
# Extracts and a scheme, url and an anchor id from +url+ and returns them.
|
|
230
250
|
|
|
231
|
-
def parse_url
|
|
251
|
+
def parse_url(url)
|
|
232
252
|
case url
|
|
233
253
|
when /^rdoc-label:([^:]*)(?::(.*))?/ then
|
|
234
254
|
scheme = 'link'
|
|
@@ -258,9 +278,8 @@ class RDoc::Markup::Formatter
|
|
|
258
278
|
##
|
|
259
279
|
# Is +tag+ a tt tag?
|
|
260
280
|
|
|
261
|
-
def tt?
|
|
281
|
+
def tt?(tag)
|
|
262
282
|
tag.bit == @tt_bit
|
|
263
283
|
end
|
|
264
284
|
|
|
265
285
|
end
|
|
266
|
-
|
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
##
|
|
3
|
-
# A hard-break in the middle of a paragraph.
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# A hard-break in the middle of a paragraph.
|
|
6
|
+
class HardBreak < Element
|
|
7
|
+
@instance = new
|
|
8
|
+
|
|
9
|
+
# RDoc::Markup::HardBreak is a singleton
|
|
10
|
+
#: () -> HardBreak
|
|
11
|
+
def self.new
|
|
12
|
+
@instance
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Calls #accept_hard_break on +visitor+
|
|
16
|
+
# @override
|
|
17
|
+
#: (untyped) -> void
|
|
18
|
+
def accept(visitor)
|
|
19
|
+
visitor.accept_hard_break(self)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#: (top) -> bool
|
|
23
|
+
def ==(other) # :nodoc:
|
|
24
|
+
self.class === other
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @override
|
|
28
|
+
#: (PP) -> void
|
|
29
|
+
def pretty_print(q) # :nodoc:
|
|
30
|
+
q.text("[break]")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
21
33
|
end
|
|
22
|
-
|
|
23
|
-
def == other # :nodoc:
|
|
24
|
-
self.class === other
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def pretty_print q # :nodoc:
|
|
28
|
-
q.text "[break]"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
34
|
end
|
|
32
|
-
|