gitlab-rdoc 6.3.2
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 +7 -0
- data/CONTRIBUTING.rdoc +220 -0
- data/CVE-2013-0256.rdoc +49 -0
- data/ExampleMarkdown.md +37 -0
- data/ExampleRDoc.rdoc +208 -0
- data/Gemfile +12 -0
- data/History.rdoc +1666 -0
- data/LEGAL.rdoc +50 -0
- data/LICENSE.rdoc +57 -0
- data/README.rdoc +133 -0
- data/RI.rdoc +57 -0
- data/Rakefile +101 -0
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/exe/rdoc +44 -0
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +112 -0
- data/lib/rdoc/anon_class.rb +11 -0
- data/lib/rdoc/any_method.rb +361 -0
- data/lib/rdoc/attr.rb +176 -0
- data/lib/rdoc/class_module.rb +802 -0
- data/lib/rdoc/code_object.rb +421 -0
- data/lib/rdoc/code_objects.rb +6 -0
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +187 -0
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +1266 -0
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +136 -0
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +42 -0
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +790 -0
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +160 -0
- data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
- data/lib/rdoc/generator/pot/po.rb +84 -0
- data/lib/rdoc/generator/pot/po_entry.rb +141 -0
- data/lib/rdoc/generator/pot.rb +98 -0
- data/lib/rdoc/generator/ri.rb +31 -0
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
- data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- 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/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
- data/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +84 -0
- data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
- data/lib/rdoc/generator/template/json_index/.document +1 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
- data/lib/rdoc/generator.rb +51 -0
- data/lib/rdoc/ghost_method.rb +7 -0
- data/lib/rdoc/i18n/locale.rb +102 -0
- data/lib/rdoc/i18n/text.rb +126 -0
- data/lib/rdoc/i18n.rb +10 -0
- data/lib/rdoc/include.rb +10 -0
- data/lib/rdoc/known_classes.rb +73 -0
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +417 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16685 -0
- data/lib/rdoc/markup/attr_changer.rb +23 -0
- data/lib/rdoc/markup/attr_span.rb +36 -0
- data/lib/rdoc/markup/attribute_manager.rb +409 -0
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +28 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +165 -0
- data/lib/rdoc/markup/formatter.rb +266 -0
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +79 -0
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +102 -0
- data/lib/rdoc/markup/list_item.rb +100 -0
- data/lib/rdoc/markup/paragraph.rb +29 -0
- data/lib/rdoc/markup/parser.rb +575 -0
- data/lib/rdoc/markup/pre_process.rb +296 -0
- data/lib/rdoc/markup/raw.rb +70 -0
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +21 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +94 -0
- data/lib/rdoc/markup/to_bs.rb +77 -0
- data/lib/rdoc/markup/to_html.rb +444 -0
- data/lib/rdoc/markup/to_html_crossref.rb +176 -0
- data/lib/rdoc/markup/to_html_snippet.rb +285 -0
- data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
- data/lib/rdoc/markup/to_label.rb +75 -0
- data/lib/rdoc/markup/to_markdown.rb +192 -0
- data/lib/rdoc/markup/to_rdoc.rb +362 -0
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +70 -0
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +84 -0
- data/lib/rdoc/markup.rb +867 -0
- data/lib/rdoc/meta_method.rb +7 -0
- data/lib/rdoc/method_attr.rb +419 -0
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +93 -0
- data/lib/rdoc/normal_module.rb +74 -0
- data/lib/rdoc/options.rb +1285 -0
- data/lib/rdoc/parser/c.rb +1225 -0
- data/lib/rdoc/parser/changelog.rb +335 -0
- data/lib/rdoc/parser/markdown.rb +24 -0
- data/lib/rdoc/parser/rd.rb +23 -0
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +2327 -0
- data/lib/rdoc/parser/ruby_tools.rb +167 -0
- data/lib/rdoc/parser/simple.rb +61 -0
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +277 -0
- data/lib/rdoc/rd/block_parser.rb +1056 -0
- data/lib/rdoc/rd/block_parser.ry +639 -0
- data/lib/rdoc/rd/inline.rb +72 -0
- data/lib/rdoc/rd/inline_parser.rb +1208 -0
- data/lib/rdoc/rd/inline_parser.ry +593 -0
- data/lib/rdoc/rd.rb +100 -0
- data/lib/rdoc/rdoc.rb +579 -0
- data/lib/rdoc/require.rb +52 -0
- data/lib/rdoc/ri/driver.rb +1572 -0
- data/lib/rdoc/ri/formatter.rb +6 -0
- data/lib/rdoc/ri/paths.rb +171 -0
- data/lib/rdoc/ri/store.rb +7 -0
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +21 -0
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +26 -0
- data/lib/rdoc/stats/normal.rb +58 -0
- data/lib/rdoc/stats/quiet.rb +60 -0
- data/lib/rdoc/stats/verbose.rb +46 -0
- data/lib/rdoc/stats.rb +462 -0
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +329 -0
- data/lib/rdoc/text.rb +304 -0
- data/lib/rdoc/token_stream.rb +119 -0
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +289 -0
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +201 -0
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +279 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# We manage a set of attributes. Each attribute has a symbol name and a bit
|
|
4
|
+
# value.
|
|
5
|
+
|
|
6
|
+
class RDoc::Markup::Attributes
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
# The regexp handling attribute type. See RDoc::Markup#add_regexp_handling
|
|
10
|
+
|
|
11
|
+
attr_reader :regexp_handling
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
# Creates a new attributes set.
|
|
15
|
+
|
|
16
|
+
def initialize
|
|
17
|
+
@regexp_handling = 1
|
|
18
|
+
|
|
19
|
+
@name_to_bitmap = [
|
|
20
|
+
[:_REGEXP_HANDLING_, @regexp_handling],
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
@next_bitmap = @regexp_handling << 1
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
##
|
|
27
|
+
# Returns a unique bit for +name+
|
|
28
|
+
|
|
29
|
+
def bitmap_for name
|
|
30
|
+
bitmap = @name_to_bitmap.assoc name
|
|
31
|
+
|
|
32
|
+
unless bitmap then
|
|
33
|
+
bitmap = @next_bitmap
|
|
34
|
+
@next_bitmap <<= 1
|
|
35
|
+
@name_to_bitmap << [name, bitmap]
|
|
36
|
+
else
|
|
37
|
+
bitmap = bitmap.last
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
bitmap
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
##
|
|
44
|
+
# Returns a string representation of +bitmap+
|
|
45
|
+
|
|
46
|
+
def as_string bitmap
|
|
47
|
+
return 'none' if bitmap.zero?
|
|
48
|
+
res = []
|
|
49
|
+
|
|
50
|
+
@name_to_bitmap.each do |name, bit|
|
|
51
|
+
res << name if (bitmap & bit) != 0
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
res.join ','
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
##
|
|
58
|
+
# yields each attribute name in +bitmap+
|
|
59
|
+
|
|
60
|
+
def each_name_of bitmap
|
|
61
|
+
return enum_for __method__, bitmap unless block_given?
|
|
62
|
+
|
|
63
|
+
@name_to_bitmap.each do |name, bit|
|
|
64
|
+
next if bit == @regexp_handling
|
|
65
|
+
|
|
66
|
+
yield name.to_s if (bitmap & bit) != 0
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# An empty line. This class is a singleton.
|
|
4
|
+
|
|
5
|
+
class RDoc::Markup::BlankLine
|
|
6
|
+
|
|
7
|
+
@instance = new
|
|
8
|
+
|
|
9
|
+
##
|
|
10
|
+
# RDoc::Markup::BlankLine is a singleton
|
|
11
|
+
|
|
12
|
+
def self.new
|
|
13
|
+
@instance
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# Calls #accept_blank_line on +visitor+
|
|
18
|
+
|
|
19
|
+
def accept visitor
|
|
20
|
+
visitor.accept_blank_line self
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def pretty_print q # :nodoc:
|
|
24
|
+
q.text 'blankline'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# A quoted section which contains markup items.
|
|
4
|
+
|
|
5
|
+
class RDoc::Markup::BlockQuote < RDoc::Markup::Raw
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Calls #accept_block_quote on +visitor+
|
|
9
|
+
|
|
10
|
+
def accept visitor
|
|
11
|
+
visitor.accept_block_quote self
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# A Document containing lists, headings, paragraphs, etc.
|
|
4
|
+
|
|
5
|
+
class RDoc::Markup::Document
|
|
6
|
+
|
|
7
|
+
include Enumerable
|
|
8
|
+
|
|
9
|
+
##
|
|
10
|
+
# The file this document was created from. See also
|
|
11
|
+
# RDoc::ClassModule#add_comment
|
|
12
|
+
|
|
13
|
+
attr_reader :file
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# If a heading is below the given level it will be omitted from the
|
|
17
|
+
# table_of_contents
|
|
18
|
+
|
|
19
|
+
attr_accessor :omit_headings_below
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# The parts of the Document
|
|
23
|
+
|
|
24
|
+
attr_reader :parts
|
|
25
|
+
|
|
26
|
+
##
|
|
27
|
+
# Creates a new Document with +parts+
|
|
28
|
+
|
|
29
|
+
def initialize *parts
|
|
30
|
+
@parts = []
|
|
31
|
+
@parts.concat parts
|
|
32
|
+
|
|
33
|
+
@file = nil
|
|
34
|
+
@omit_headings_from_table_of_contents_below = nil
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# Appends +part+ to the document
|
|
39
|
+
|
|
40
|
+
def << part
|
|
41
|
+
case part
|
|
42
|
+
when RDoc::Markup::Document then
|
|
43
|
+
unless part.empty? then
|
|
44
|
+
parts.concat part.parts
|
|
45
|
+
parts << RDoc::Markup::BlankLine.new
|
|
46
|
+
end
|
|
47
|
+
when String then
|
|
48
|
+
raise ArgumentError,
|
|
49
|
+
"expected RDoc::Markup::Document and friends, got String" unless
|
|
50
|
+
part.empty?
|
|
51
|
+
else
|
|
52
|
+
parts << part
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def == other # :nodoc:
|
|
57
|
+
self.class == other.class and
|
|
58
|
+
@file == other.file and
|
|
59
|
+
@parts == other.parts
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
##
|
|
63
|
+
# Runs this document and all its #items through +visitor+
|
|
64
|
+
|
|
65
|
+
def accept visitor
|
|
66
|
+
visitor.start_accepting
|
|
67
|
+
|
|
68
|
+
visitor.accept_document self
|
|
69
|
+
|
|
70
|
+
visitor.end_accepting
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
##
|
|
74
|
+
# Concatenates the given +parts+ onto the document
|
|
75
|
+
|
|
76
|
+
def concat parts
|
|
77
|
+
self.parts.concat parts
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
##
|
|
81
|
+
# Enumerator for the parts of this document
|
|
82
|
+
|
|
83
|
+
def each &block
|
|
84
|
+
@parts.each(&block)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
##
|
|
88
|
+
# Does this document have no parts?
|
|
89
|
+
|
|
90
|
+
def empty?
|
|
91
|
+
@parts.empty? or (@parts.length == 1 and merged? and @parts.first.empty?)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
##
|
|
95
|
+
# The file this Document was created from.
|
|
96
|
+
|
|
97
|
+
def file= location
|
|
98
|
+
@file = case location
|
|
99
|
+
when RDoc::TopLevel then
|
|
100
|
+
location.relative_name
|
|
101
|
+
else
|
|
102
|
+
location
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# When this is a collection of documents (#file is not set and this document
|
|
108
|
+
# contains only other documents as its direct children) #merge replaces
|
|
109
|
+
# documents in this class with documents from +other+ when the file matches
|
|
110
|
+
# and adds documents from +other+ when the files do not.
|
|
111
|
+
#
|
|
112
|
+
# The information in +other+ is preferred over the receiver
|
|
113
|
+
|
|
114
|
+
def merge other
|
|
115
|
+
if empty? then
|
|
116
|
+
@parts = other.parts
|
|
117
|
+
return self
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
other.parts.each do |other_part|
|
|
121
|
+
self.parts.delete_if do |self_part|
|
|
122
|
+
self_part.file and self_part.file == other_part.file
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
self.parts << other_part
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
self
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
##
|
|
132
|
+
# Does this Document contain other Documents?
|
|
133
|
+
|
|
134
|
+
def merged?
|
|
135
|
+
RDoc::Markup::Document === @parts.first
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def pretty_print q # :nodoc:
|
|
139
|
+
start = @file ? "[doc (#{@file}): " : '[doc: '
|
|
140
|
+
|
|
141
|
+
q.group 2, start, ']' do
|
|
142
|
+
q.seplist @parts do |part|
|
|
143
|
+
q.pp part
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
##
|
|
149
|
+
# Appends +parts+ to the document
|
|
150
|
+
|
|
151
|
+
def push *parts
|
|
152
|
+
self.parts.concat parts
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
##
|
|
156
|
+
# Returns an Array of headings in the document.
|
|
157
|
+
#
|
|
158
|
+
# Require 'rdoc/markup/formatter' before calling this method.
|
|
159
|
+
|
|
160
|
+
def table_of_contents
|
|
161
|
+
accept RDoc::Markup::ToTableOfContents.to_toc
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
end
|
|
165
|
+
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# Base class for RDoc markup formatters
|
|
4
|
+
#
|
|
5
|
+
# Formatters are a visitor that converts an RDoc::Markup tree (from a comment)
|
|
6
|
+
# into some kind of output. RDoc ships with formatters for converting back to
|
|
7
|
+
# rdoc, ANSI text, HTML, a Table of Contents and other formats.
|
|
8
|
+
#
|
|
9
|
+
# If you'd like to write your own Formatter use
|
|
10
|
+
# RDoc::Markup::FormatterTestCase. If you're writing a text-output formatter
|
|
11
|
+
# use RDoc::Markup::TextFormatterTestCase which provides extra test cases.
|
|
12
|
+
|
|
13
|
+
class RDoc::Markup::Formatter
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# Tag for inline markup containing a +bit+ for the bitmask and the +on+ and
|
|
17
|
+
# +off+ triggers.
|
|
18
|
+
|
|
19
|
+
InlineTag = Struct.new(:bit, :on, :off)
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# Converts a target url to one that is relative to a given path
|
|
23
|
+
|
|
24
|
+
def self.gen_relative_url path, target
|
|
25
|
+
from = File.dirname path
|
|
26
|
+
to, to_file = File.split target
|
|
27
|
+
|
|
28
|
+
from = from.split "/"
|
|
29
|
+
to = to.split "/"
|
|
30
|
+
|
|
31
|
+
from.delete '.'
|
|
32
|
+
to.delete '.'
|
|
33
|
+
|
|
34
|
+
while from.size > 0 and to.size > 0 and from[0] == to[0] do
|
|
35
|
+
from.shift
|
|
36
|
+
to.shift
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
from.fill ".."
|
|
40
|
+
from.concat to
|
|
41
|
+
from << to_file
|
|
42
|
+
File.join(*from)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Creates a new Formatter
|
|
47
|
+
|
|
48
|
+
def initialize options, markup = nil
|
|
49
|
+
@options = options
|
|
50
|
+
|
|
51
|
+
@markup = markup || RDoc::Markup.new
|
|
52
|
+
@am = @markup.attribute_manager
|
|
53
|
+
@am.add_regexp_handling(/<br>/, :HARD_BREAK)
|
|
54
|
+
|
|
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
|
+
@from_path = '.'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
##
|
|
67
|
+
# Adds +document+ to the output
|
|
68
|
+
|
|
69
|
+
def accept_document document
|
|
70
|
+
document.parts.each do |item|
|
|
71
|
+
case item
|
|
72
|
+
when RDoc::Markup::Document then # HACK
|
|
73
|
+
accept_document item
|
|
74
|
+
else
|
|
75
|
+
item.accept self
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
##
|
|
81
|
+
# Adds a regexp handling for links of the form rdoc-...:
|
|
82
|
+
|
|
83
|
+
def add_regexp_handling_RDOCLINK
|
|
84
|
+
@markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
##
|
|
88
|
+
# Adds a regexp handling for links of the form {<text>}[<url>] and
|
|
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
|
+
)
|
|
96
|
+
|
|
97
|
+
\[\S+?\] # link target
|
|
98
|
+
/x, :TIDYLINK)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
##
|
|
102
|
+
# Add a new set of tags for an attribute. We allow separate start and end
|
|
103
|
+
# tags for flexibility
|
|
104
|
+
|
|
105
|
+
def add_tag(name, start, stop)
|
|
106
|
+
attr = @attributes.bitmap_for name
|
|
107
|
+
@attr_tags << InlineTag.new(attr, start, stop)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
##
|
|
111
|
+
# Allows +tag+ to be decorated with additional information.
|
|
112
|
+
|
|
113
|
+
def annotate(tag)
|
|
114
|
+
tag
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
##
|
|
118
|
+
# Marks up +content+
|
|
119
|
+
|
|
120
|
+
def convert content
|
|
121
|
+
@markup.convert content, self
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
##
|
|
125
|
+
# Converts flow items +flow+
|
|
126
|
+
|
|
127
|
+
def convert_flow(flow)
|
|
128
|
+
res = []
|
|
129
|
+
|
|
130
|
+
flow.each do |item|
|
|
131
|
+
case item
|
|
132
|
+
when String then
|
|
133
|
+
res << convert_string(item)
|
|
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)
|
|
139
|
+
else
|
|
140
|
+
raise "Unknown flow element: #{item.inspect}"
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
res.join
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
##
|
|
148
|
+
# Converts added regexp handlings. See RDoc::Markup#add_regexp_handling
|
|
149
|
+
|
|
150
|
+
def convert_regexp_handling target
|
|
151
|
+
return target.text if in_tt?
|
|
152
|
+
|
|
153
|
+
handled = false
|
|
154
|
+
|
|
155
|
+
@attributes.each_name_of target.type do |name|
|
|
156
|
+
method_name = "handle_regexp_#{name}"
|
|
157
|
+
|
|
158
|
+
if respond_to? method_name then
|
|
159
|
+
target.text = public_send method_name, target
|
|
160
|
+
handled = true
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
unless handled then
|
|
165
|
+
target_name = @attributes.as_string target.type
|
|
166
|
+
|
|
167
|
+
raise RDoc::Error, "Unhandled regexp handling #{target_name}: #{target}"
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
target.text
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
##
|
|
174
|
+
# Converts a string to be fancier if desired
|
|
175
|
+
|
|
176
|
+
def convert_string string
|
|
177
|
+
string
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
##
|
|
181
|
+
# Use ignore in your subclass to ignore the content of a node.
|
|
182
|
+
#
|
|
183
|
+
# ##
|
|
184
|
+
# # We don't support raw nodes in ToNoRaw
|
|
185
|
+
#
|
|
186
|
+
# alias accept_raw ignore
|
|
187
|
+
|
|
188
|
+
def ignore *node
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
##
|
|
192
|
+
# Are we currently inside tt tags?
|
|
193
|
+
|
|
194
|
+
def in_tt?
|
|
195
|
+
@in_tt > 0
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
##
|
|
199
|
+
# Turns on tags for +item+ on +res+
|
|
200
|
+
|
|
201
|
+
def on_tags res, item
|
|
202
|
+
attr_mask = item.turn_on
|
|
203
|
+
return if attr_mask.zero?
|
|
204
|
+
|
|
205
|
+
@attr_tags.each do |tag|
|
|
206
|
+
if attr_mask & tag.bit != 0 then
|
|
207
|
+
res << annotate(tag.on)
|
|
208
|
+
@in_tt += 1 if tt? tag
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
##
|
|
214
|
+
# Turns off tags for +item+ on +res+
|
|
215
|
+
|
|
216
|
+
def off_tags res, item
|
|
217
|
+
attr_mask = item.turn_off
|
|
218
|
+
return if attr_mask.zero?
|
|
219
|
+
|
|
220
|
+
@attr_tags.reverse_each do |tag|
|
|
221
|
+
if attr_mask & tag.bit != 0 then
|
|
222
|
+
@in_tt -= 1 if tt? tag
|
|
223
|
+
res << annotate(tag.off)
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
##
|
|
229
|
+
# Extracts and a scheme, url and an anchor id from +url+ and returns them.
|
|
230
|
+
|
|
231
|
+
def parse_url url
|
|
232
|
+
case url
|
|
233
|
+
when /^rdoc-label:([^:]*)(?::(.*))?/ then
|
|
234
|
+
scheme = 'link'
|
|
235
|
+
path = "##{$1}"
|
|
236
|
+
id = " id=\"#{$2}\"" if $2
|
|
237
|
+
when /([A-Za-z]+):(.*)/ then
|
|
238
|
+
scheme = $1.downcase
|
|
239
|
+
path = $2
|
|
240
|
+
when /^#/ then
|
|
241
|
+
else
|
|
242
|
+
scheme = 'http'
|
|
243
|
+
path = url
|
|
244
|
+
url = url
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
if scheme == 'link' then
|
|
248
|
+
url = if path[0, 1] == '#' then # is this meaningful?
|
|
249
|
+
path
|
|
250
|
+
else
|
|
251
|
+
self.class.gen_relative_url @from_path, path
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
[scheme, url, id]
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
##
|
|
259
|
+
# Is +tag+ a tt tag?
|
|
260
|
+
|
|
261
|
+
def tt? tag
|
|
262
|
+
tag.bit == @tt_bit
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
end
|
|
266
|
+
|