rdoc 3.1 → 6.3.3
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 +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 +129 -0
- data/RI.rdoc +57 -0
- data/Rakefile +84 -81
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/{bin → exe}/rdoc +11 -2
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +1 -2
- data/lib/rdoc/anon_class.rb +3 -2
- data/lib/rdoc/any_method.rb +234 -40
- data/lib/rdoc/attr.rb +79 -11
- data/lib/rdoc/class_module.rb +443 -71
- data/lib/rdoc/code_object.rb +216 -20
- data/lib/rdoc/code_objects.rb +4 -21
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +110 -9
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +392 -172
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +83 -28
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +8 -3
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +507 -84
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +27 -74
- 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 +8 -62
- 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/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +18 -60
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -83
- 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 +24 -13
- data/lib/rdoc/ghost_method.rb +1 -2
- 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 +5 -95
- data/lib/rdoc/known_classes.rb +5 -2
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +416 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16684 -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 +135 -62
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +1 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +96 -9
- data/lib/rdoc/markup/formatter.rb +138 -25
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +61 -2
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +25 -4
- data/lib/rdoc/markup/list_item.rb +18 -4
- data/lib/rdoc/markup/paragraph.rb +15 -0
- data/lib/rdoc/markup/parser.rb +180 -88
- data/lib/rdoc/markup/pre_process.rb +183 -38
- data/lib/rdoc/markup/raw.rb +6 -5
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +1 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +17 -7
- data/lib/rdoc/markup/to_bs.rb +5 -8
- data/lib/rdoc/markup/to_html.rb +238 -137
- data/lib/rdoc/markup/to_html_crossref.rb +125 -152
- 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 +85 -15
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +2 -4
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +39 -0
- data/lib/rdoc/markup.rb +388 -110
- data/lib/rdoc/meta_method.rb +1 -2
- data/lib/rdoc/method_attr.rb +87 -21
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +39 -10
- data/lib/rdoc/normal_module.rb +22 -7
- data/lib/rdoc/options.rb +613 -73
- data/lib/rdoc/parser/c.rb +621 -287
- 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 +1368 -762
- data/lib/rdoc/parser/ruby_tools.rb +42 -35
- data/lib/rdoc/parser/simple.rb +23 -11
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +162 -89
- 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 +208 -115
- data/lib/rdoc/require.rb +1 -2
- data/lib/rdoc/ri/driver.rb +734 -239
- data/lib/rdoc/ri/formatter.rb +1 -0
- data/lib/rdoc/ri/paths.rb +91 -48
- data/lib/rdoc/ri/store.rb +3 -261
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +5 -2
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +14 -2
- data/lib/rdoc/stats/normal.rb +19 -12
- data/lib/rdoc/stats/quiet.rb +1 -0
- data/lib/rdoc/stats/verbose.rb +1 -0
- data/lib/rdoc/stats.rb +262 -104
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +84 -44
- data/lib/rdoc/text.rb +117 -72
- data/lib/rdoc/token_stream.rb +73 -4
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +111 -261
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +127 -64
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +171 -291
- data/.autotest +0 -16
- data/.document +0 -5
- data/History.txt +0 -594
- data/LICENSE.txt +0 -57
- data/Manifest.txt +0 -158
- data/README.txt +0 -45
- data/RI.txt +0 -58
- data/bin/ri +0 -5
- data/lib/rdoc/gauntlet.rb +0 -52
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -296
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -32
- data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
- data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
- data/lib/rdoc/generator/template/darkfish/rdoc.css +0 -706
- data/lib/rdoc/markup/formatter_test_case.rb +0 -689
- data/lib/rdoc/markup/inline.rb +0 -137
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -116
- data/lib/rdoc/ruby_lex.rb +0 -1291
- data/lib/rdoc/ruby_token.rb +0 -416
- data/test/README +0 -1
- data/test/binary.dat +0 -0
- data/test/hidden.zip.txt +0 -1
- data/test/test.ja.rdoc +0 -10
- data/test/test.ja.txt +0 -8
- data/test/test.txt +0 -1
- data/test/test_attribute_manager.rb +0 -120
- data/test/test_rdoc_alias.rb +0 -13
- data/test/test_rdoc_any_method.rb +0 -126
- data/test/test_rdoc_attr.rb +0 -61
- data/test/test_rdoc_class_module.rb +0 -233
- data/test/test_rdoc_code_object.rb +0 -165
- data/test/test_rdoc_constant.rb +0 -15
- data/test/test_rdoc_context.rb +0 -370
- data/test/test_rdoc_encoding.rb +0 -166
- data/test/test_rdoc_generator_darkfish.rb +0 -119
- data/test/test_rdoc_generator_ri.rb +0 -76
- data/test/test_rdoc_include.rb +0 -96
- data/test/test_rdoc_markup.rb +0 -37
- data/test/test_rdoc_markup_attribute_manager.rb +0 -240
- data/test/test_rdoc_markup_document.rb +0 -51
- data/test/test_rdoc_markup_paragraph.rb +0 -9
- data/test/test_rdoc_markup_parser.rb +0 -1395
- data/test/test_rdoc_markup_pre_process.rb +0 -185
- data/test/test_rdoc_markup_raw.rb +0 -27
- data/test/test_rdoc_markup_to_ansi.rb +0 -328
- data/test/test_rdoc_markup_to_bs.rb +0 -341
- data/test/test_rdoc_markup_to_html.rb +0 -335
- data/test/test_rdoc_markup_to_html_crossref.rb +0 -169
- data/test/test_rdoc_markup_to_rdoc.rb +0 -327
- data/test/test_rdoc_method_attr.rb +0 -122
- data/test/test_rdoc_normal_class.rb +0 -17
- data/test/test_rdoc_normal_module.rb +0 -31
- data/test/test_rdoc_options.rb +0 -342
- data/test/test_rdoc_parser.rb +0 -83
- data/test/test_rdoc_parser_c.rb +0 -912
- data/test/test_rdoc_parser_ruby.rb +0 -1754
- data/test/test_rdoc_parser_simple.rb +0 -99
- data/test/test_rdoc_rdoc.rb +0 -164
- data/test/test_rdoc_require.rb +0 -25
- data/test/test_rdoc_ri_driver.rb +0 -846
- data/test/test_rdoc_ri_paths.rb +0 -43
- data/test/test_rdoc_ri_store.rb +0 -352
- data/test/test_rdoc_ruby_lex.rb +0 -23
- data/test/test_rdoc_stats.rb +0 -38
- data/test/test_rdoc_task.rb +0 -92
- data/test/test_rdoc_text.rb +0 -251
- data/test/test_rdoc_top_level.rb +0 -120
- data/test/xref_data.rb +0 -62
- data/test/xref_test_case.rb +0 -61
- data.tar.gz.sig +0 -3
- metadata.gz.sig +0 -0
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'rdoc/encoding'
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
4
2
|
##
|
5
3
|
# Handle common directives that can occur in a block of text:
|
6
4
|
#
|
@@ -9,16 +7,48 @@ require 'rdoc/encoding'
|
|
9
7
|
# Directives can be escaped by preceding them with a backslash.
|
10
8
|
#
|
11
9
|
# RDoc plugin authors can register additional directives to be handled by
|
12
|
-
# using RDoc::Markup::PreProcess::register
|
10
|
+
# using RDoc::Markup::PreProcess::register.
|
11
|
+
#
|
12
|
+
# Any directive that is not built-in to RDoc (including those registered via
|
13
|
+
# plugins) will be stored in the metadata hash on the CodeObject the comment
|
14
|
+
# is attached to. See RDoc::Markup@Directives for the list of built-in
|
15
|
+
# directives.
|
13
16
|
|
14
17
|
class RDoc::Markup::PreProcess
|
15
18
|
|
16
|
-
|
19
|
+
##
|
20
|
+
# An RDoc::Options instance that will be filled in with overrides from
|
21
|
+
# directives
|
22
|
+
|
23
|
+
attr_accessor :options
|
24
|
+
|
25
|
+
##
|
26
|
+
# Adds a post-process handler for directives. The handler will be called
|
27
|
+
# with the result RDoc::Comment (or text String) and the code object for the
|
28
|
+
# comment (if any).
|
29
|
+
|
30
|
+
def self.post_process &block
|
31
|
+
@post_processors << block
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Registered post-processors
|
36
|
+
|
37
|
+
def self.post_processors
|
38
|
+
@post_processors
|
39
|
+
end
|
17
40
|
|
18
41
|
##
|
19
42
|
# Registers +directive+ as one handled by RDoc. If a block is given the
|
20
43
|
# directive will be replaced by the result of the block, otherwise the
|
21
44
|
# directive will be removed from the processed text.
|
45
|
+
#
|
46
|
+
# The block will be called with the directive name and the directive
|
47
|
+
# parameter:
|
48
|
+
#
|
49
|
+
# RDoc::Markup::PreProcess.register 'my-directive' do |directive, param|
|
50
|
+
# # replace text, etc.
|
51
|
+
# end
|
22
52
|
|
23
53
|
def self.register directive, &block
|
24
54
|
@registered[directive] = block
|
@@ -31,6 +61,16 @@ class RDoc::Markup::PreProcess
|
|
31
61
|
@registered
|
32
62
|
end
|
33
63
|
|
64
|
+
##
|
65
|
+
# Clears all registered directives and post-processors
|
66
|
+
|
67
|
+
def self.reset
|
68
|
+
@post_processors = []
|
69
|
+
@registered = {}
|
70
|
+
end
|
71
|
+
|
72
|
+
reset
|
73
|
+
|
34
74
|
##
|
35
75
|
# Creates a new pre-processor for +input_file_name+ that will look for
|
36
76
|
# included files in +include_path+
|
@@ -38,10 +78,11 @@ class RDoc::Markup::PreProcess
|
|
38
78
|
def initialize(input_file_name, include_path)
|
39
79
|
@input_file_name = input_file_name
|
40
80
|
@include_path = include_path
|
81
|
+
@options = nil
|
41
82
|
end
|
42
83
|
|
43
84
|
##
|
44
|
-
# Look for directives in
|
85
|
+
# Look for directives in the given +text+.
|
45
86
|
#
|
46
87
|
# Options that we don't handle are yielded. If the block returns false the
|
47
88
|
# directive is restored to the text. If the block returns nil or no block
|
@@ -51,52 +92,156 @@ class RDoc::Markup::PreProcess
|
|
51
92
|
# If no matching directive was registered the directive is restored to the
|
52
93
|
# text.
|
53
94
|
#
|
54
|
-
# If +code_object+ is given and the
|
55
|
-
# +code_object+. See
|
95
|
+
# If +code_object+ is given and the directive is unknown then the
|
96
|
+
# directive's parameter is set as metadata on the +code_object+. See
|
97
|
+
# RDoc::CodeObject#metadata for details.
|
98
|
+
|
99
|
+
def handle text, code_object = nil, &block
|
100
|
+
if RDoc::Comment === text then
|
101
|
+
comment = text
|
102
|
+
text = text.text
|
103
|
+
end
|
56
104
|
|
57
|
-
def handle text, code_object = nil
|
58
105
|
# regexp helper (square brackets for optional)
|
59
106
|
# $1 $2 $3 $4 $5
|
60
107
|
# [prefix][\]:directive:[spaces][param]newline
|
61
|
-
text.gsub
|
108
|
+
text = text.gsub(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):(\w+):([ \t]*)(.+)?(\r?\n|$)/) do
|
62
109
|
# skip something like ':toto::'
|
63
110
|
next $& if $4.empty? and $5 and $5[0, 1] == ':'
|
64
111
|
|
65
112
|
# skip if escaped
|
66
113
|
next "#$1:#$3:#$4#$5\n" unless $2.empty?
|
67
114
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
filename = param.split[0]
|
75
|
-
encoding = if defined?(Encoding) then text.encoding else nil end
|
76
|
-
include_file filename, prefix, encoding
|
77
|
-
else
|
78
|
-
result = yield directive, param if block_given?
|
79
|
-
|
80
|
-
case result
|
81
|
-
when nil then
|
82
|
-
code_object.metadata[directive] = param if code_object
|
83
|
-
if RDoc::Markup::PreProcess.registered.include? directive then
|
84
|
-
handler = RDoc::Markup::PreProcess.registered[directive]
|
85
|
-
result = handler.call directive, param if handler
|
86
|
-
else
|
87
|
-
result = "#{prefix}:#{directive}: #{param}\n"
|
88
|
-
end
|
89
|
-
when false then
|
90
|
-
result = "#{prefix}:#{directive}: #{param}\n"
|
91
|
-
end
|
92
|
-
|
93
|
-
result
|
115
|
+
# This is not in handle_directive because I didn't want to pass another
|
116
|
+
# argument into it
|
117
|
+
if comment and $3 == 'markup' then
|
118
|
+
next "#{$1.strip}\n" unless $5
|
119
|
+
comment.format = $5.downcase
|
120
|
+
next "#{$1.strip}\n"
|
94
121
|
end
|
122
|
+
|
123
|
+
handle_directive $1, $3, $5, code_object, text.encoding, &block
|
124
|
+
end
|
125
|
+
|
126
|
+
if comment then
|
127
|
+
comment.text = text
|
128
|
+
else
|
129
|
+
comment = text
|
130
|
+
end
|
131
|
+
|
132
|
+
self.class.post_processors.each do |handler|
|
133
|
+
handler.call comment, code_object
|
95
134
|
end
|
96
135
|
|
97
136
|
text
|
98
137
|
end
|
99
138
|
|
139
|
+
##
|
140
|
+
# Performs the actions described by +directive+ and its parameter +param+.
|
141
|
+
#
|
142
|
+
# +code_object+ is used for directives that operate on a class or module.
|
143
|
+
# +prefix+ is used to ensure the replacement for handled directives is
|
144
|
+
# correct. +encoding+ is used for the <tt>include</tt> directive.
|
145
|
+
#
|
146
|
+
# For a list of directives in RDoc see RDoc::Markup.
|
147
|
+
#--
|
148
|
+
# When 1.8.7 support is ditched prefix can be defaulted to ''
|
149
|
+
|
150
|
+
def handle_directive prefix, directive, param, code_object = nil,
|
151
|
+
encoding = nil
|
152
|
+
blankline = "#{prefix.strip}\n"
|
153
|
+
directive = directive.downcase
|
154
|
+
|
155
|
+
case directive
|
156
|
+
when 'arg', 'args' then
|
157
|
+
return "#{prefix}:#{directive}: #{param}\n" unless code_object && code_object.kind_of?(RDoc::AnyMethod)
|
158
|
+
|
159
|
+
code_object.params = param
|
160
|
+
|
161
|
+
blankline
|
162
|
+
when 'category' then
|
163
|
+
if RDoc::Context === code_object then
|
164
|
+
section = code_object.add_section param
|
165
|
+
code_object.temporary_section = section
|
166
|
+
end
|
167
|
+
|
168
|
+
blankline # ignore category if we're not on an RDoc::Context
|
169
|
+
when 'doc' then
|
170
|
+
return blankline unless code_object
|
171
|
+
code_object.document_self = true
|
172
|
+
code_object.force_documentation = true
|
173
|
+
|
174
|
+
blankline
|
175
|
+
when 'enddoc' then
|
176
|
+
return blankline unless code_object
|
177
|
+
code_object.done_documenting = true
|
178
|
+
|
179
|
+
blankline
|
180
|
+
when 'include' then
|
181
|
+
filename = param.split(' ', 2).first
|
182
|
+
include_file filename, prefix, encoding
|
183
|
+
when 'main' then
|
184
|
+
@options.main_page = param if @options.respond_to? :main_page
|
185
|
+
|
186
|
+
blankline
|
187
|
+
when 'nodoc' then
|
188
|
+
return blankline unless code_object
|
189
|
+
code_object.document_self = nil # notify nodoc
|
190
|
+
code_object.document_children = param !~ /all/i
|
191
|
+
|
192
|
+
blankline
|
193
|
+
when 'notnew', 'not_new', 'not-new' then
|
194
|
+
return blankline unless RDoc::AnyMethod === code_object
|
195
|
+
|
196
|
+
code_object.dont_rename_initialize = true
|
197
|
+
|
198
|
+
blankline
|
199
|
+
when 'startdoc' then
|
200
|
+
return blankline unless code_object
|
201
|
+
|
202
|
+
code_object.start_doc
|
203
|
+
code_object.force_documentation = true
|
204
|
+
|
205
|
+
blankline
|
206
|
+
when 'stopdoc' then
|
207
|
+
return blankline unless code_object
|
208
|
+
|
209
|
+
code_object.stop_doc
|
210
|
+
|
211
|
+
blankline
|
212
|
+
when 'title' then
|
213
|
+
@options.default_title = param if @options.respond_to? :default_title=
|
214
|
+
|
215
|
+
blankline
|
216
|
+
when 'yield', 'yields' then
|
217
|
+
return blankline unless code_object
|
218
|
+
# remove parameter &block
|
219
|
+
code_object.params = code_object.params.sub(/,?\s*&\w+/, '') if code_object.params
|
220
|
+
|
221
|
+
code_object.block_params = param
|
222
|
+
|
223
|
+
blankline
|
224
|
+
else
|
225
|
+
result = yield directive, param if block_given?
|
226
|
+
|
227
|
+
case result
|
228
|
+
when nil then
|
229
|
+
code_object.metadata[directive] = param if code_object
|
230
|
+
|
231
|
+
if RDoc::Markup::PreProcess.registered.include? directive then
|
232
|
+
handler = RDoc::Markup::PreProcess.registered[directive]
|
233
|
+
result = handler.call directive, param if handler
|
234
|
+
else
|
235
|
+
result = "#{prefix}:#{directive}: #{param}\n"
|
236
|
+
end
|
237
|
+
when false then
|
238
|
+
result = "#{prefix}:#{directive}: #{param}\n"
|
239
|
+
end
|
240
|
+
|
241
|
+
result
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
100
245
|
##
|
101
246
|
# Handles the <tt>:include: _filename_</tt> directive.
|
102
247
|
#
|
@@ -120,7 +265,8 @@ class RDoc::Markup::PreProcess
|
|
120
265
|
return ''
|
121
266
|
end
|
122
267
|
|
123
|
-
content = RDoc::Encoding.read_file full_name, encoding
|
268
|
+
content = RDoc::Encoding.read_file full_name, encoding, true
|
269
|
+
content = RDoc::Encoding.remove_magic_comment content
|
124
270
|
|
125
271
|
# strip magic comment
|
126
272
|
content = content.sub(/\A# .*coding[=:].*$/, '').lstrip
|
@@ -148,4 +294,3 @@ class RDoc::Markup::PreProcess
|
|
148
294
|
end
|
149
295
|
|
150
296
|
end
|
151
|
-
|
data/lib/rdoc/markup/raw.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
##
|
2
3
|
# A section of text that is added to the output document as-is
|
3
4
|
|
@@ -13,7 +14,7 @@ class RDoc::Markup::Raw
|
|
13
14
|
|
14
15
|
def initialize *parts
|
15
16
|
@parts = []
|
16
|
-
@parts.
|
17
|
+
@parts.concat parts
|
17
18
|
end
|
18
19
|
|
19
20
|
##
|
@@ -24,7 +25,7 @@ class RDoc::Markup::Raw
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def == other # :nodoc:
|
27
|
-
self.class == other.class and
|
28
|
+
self.class == other.class and @parts == other.parts
|
28
29
|
end
|
29
30
|
|
30
31
|
##
|
@@ -38,11 +39,11 @@ class RDoc::Markup::Raw
|
|
38
39
|
# Appends +other+'s parts
|
39
40
|
|
40
41
|
def merge other
|
41
|
-
@parts.
|
42
|
+
@parts.concat other.parts
|
42
43
|
end
|
43
44
|
|
44
45
|
def pretty_print q # :nodoc:
|
45
|
-
self.class.name =~ /.*::(\w{4})/i
|
46
|
+
self.class.name =~ /.*::(\w{1,4})/i
|
46
47
|
|
47
48
|
q.group 2, "[#{$1.downcase}: ", ']' do
|
48
49
|
q.seplist @parts do |part|
|
@@ -55,7 +56,7 @@ class RDoc::Markup::Raw
|
|
55
56
|
# Appends +texts+ onto this Paragraph
|
56
57
|
|
57
58
|
def push *texts
|
58
|
-
self.parts.
|
59
|
+
self.parts.concat texts
|
59
60
|
end
|
60
61
|
|
61
62
|
##
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# Hold details of a regexp handling sequence
|
4
|
+
|
5
|
+
class RDoc::Markup::RegexpHandling
|
6
|
+
|
7
|
+
##
|
8
|
+
# Regexp handling type
|
9
|
+
|
10
|
+
attr_reader :type
|
11
|
+
|
12
|
+
##
|
13
|
+
# Regexp handling text
|
14
|
+
|
15
|
+
attr_accessor :text
|
16
|
+
|
17
|
+
##
|
18
|
+
# Creates a new regexp handling sequence of +type+ with +text+
|
19
|
+
|
20
|
+
def initialize(type, text)
|
21
|
+
@type, @text = type, text
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Regexp handlings are equal when the have the same text and type
|
26
|
+
|
27
|
+
def ==(o)
|
28
|
+
self.text == o.text && self.type == o.type
|
29
|
+
end
|
30
|
+
|
31
|
+
def inspect # :nodoc:
|
32
|
+
"#<RDoc::Markup::RegexpHandling:0x%x @type=%p, @text=%p>" % [
|
33
|
+
object_id, @type, text.dump]
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s # :nodoc:
|
37
|
+
"RegexpHandling: type=#{type} text=#{text.dump}"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
data/lib/rdoc/markup/rule.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# A section of table
|
4
|
+
|
5
|
+
class RDoc::Markup::Table
|
6
|
+
attr_accessor :header, :align, :body
|
7
|
+
|
8
|
+
def initialize header, align, body
|
9
|
+
@header, @align, @body = header, align, body
|
10
|
+
end
|
11
|
+
|
12
|
+
def == other
|
13
|
+
self.class == other.class and
|
14
|
+
@header == other.header and
|
15
|
+
@align == other.align and
|
16
|
+
@body == other.body
|
17
|
+
end
|
18
|
+
|
19
|
+
def accept visitor
|
20
|
+
visitor.accept_table @header, @body, @align
|
21
|
+
end
|
22
|
+
|
23
|
+
def pretty_print q # :nodoc:
|
24
|
+
q.group 2, '[Table: ', ']' do
|
25
|
+
q.group 2, '[Head: ', ']' do
|
26
|
+
q.seplist @header.zip(@align) do |text, align|
|
27
|
+
q.pp text
|
28
|
+
if align
|
29
|
+
q.text ":"
|
30
|
+
q.breakable
|
31
|
+
q.text align.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
q.breakable
|
36
|
+
q.group 2, '[Body: ', ']' do
|
37
|
+
q.seplist @body do |body|
|
38
|
+
q.group 2, '[', ']' do
|
39
|
+
q.seplist body do |text|
|
40
|
+
q.pp text
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/rdoc/markup/to_ansi.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
3
2
|
##
|
4
3
|
# Outputs RDoc markup with vibrant ANSI color!
|
5
4
|
|
@@ -8,13 +7,13 @@ class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
|
|
8
7
|
##
|
9
8
|
# Creates a new ToAnsi visitor that is ready to output vibrant ANSI color!
|
10
9
|
|
11
|
-
def initialize
|
10
|
+
def initialize markup = nil
|
12
11
|
super
|
13
12
|
|
14
13
|
@headings.clear
|
15
|
-
@headings[1] = ["\e[1;32m", "\e[m"]
|
16
|
-
@headings[2] = ["\e[4;32m", "\e[m"]
|
17
|
-
@headings[3] = ["\e[32m", "\e[m"]
|
14
|
+
@headings[1] = ["\e[1;32m", "\e[m"] # bold
|
15
|
+
@headings[2] = ["\e[4;32m", "\e[m"] # underline
|
16
|
+
@headings[3] = ["\e[32m", "\e[m"] # just green
|
18
17
|
end
|
19
18
|
|
20
19
|
##
|
@@ -34,6 +33,11 @@ class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
|
|
34
33
|
when :BULLET then
|
35
34
|
2
|
36
35
|
when :NOTE, :LABEL then
|
36
|
+
if @prefix then
|
37
|
+
@res << @prefix.strip
|
38
|
+
@prefix = nil
|
39
|
+
end
|
40
|
+
|
37
41
|
@res << "\n" unless res.length == 1
|
38
42
|
2
|
39
43
|
else
|
@@ -53,7 +57,13 @@ class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
|
|
53
57
|
when :BULLET then
|
54
58
|
'*'
|
55
59
|
when :NOTE, :LABEL then
|
56
|
-
|
60
|
+
labels = Array(list_item.label).map do |label|
|
61
|
+
attributes(label).strip
|
62
|
+
end.join "\n"
|
63
|
+
|
64
|
+
labels << ":\n" unless labels.empty?
|
65
|
+
|
66
|
+
labels
|
57
67
|
else
|
58
68
|
@list_index.last.to_s + '.'
|
59
69
|
end
|
data/lib/rdoc/markup/to_bs.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
3
2
|
##
|
4
3
|
# Outputs RDoc markup with hot backspace action! You will probably need a
|
5
4
|
# pager to use this output format.
|
@@ -11,7 +10,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
|
|
11
10
|
##
|
12
11
|
# Returns a new ToBs that is ready for hot backspace action!
|
13
12
|
|
14
|
-
def initialize
|
13
|
+
def initialize markup = nil
|
15
14
|
super
|
16
15
|
|
17
16
|
@in_b = false
|
@@ -42,7 +41,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
|
|
42
41
|
end
|
43
42
|
|
44
43
|
##
|
45
|
-
# Turns on or off
|
44
|
+
# Turns on or off regexp handling for +convert_string+
|
46
45
|
|
47
46
|
def annotate tag
|
48
47
|
case tag
|
@@ -55,9 +54,9 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
|
|
55
54
|
end
|
56
55
|
|
57
56
|
##
|
58
|
-
# Calls convert_string on the result of
|
57
|
+
# Calls convert_string on the result of convert_regexp_handling
|
59
58
|
|
60
|
-
def
|
59
|
+
def convert_regexp_handling target
|
61
60
|
convert_string super
|
62
61
|
end
|
63
62
|
|
@@ -65,7 +64,6 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
|
|
65
64
|
# Adds bold or underline mixed with backspaces
|
66
65
|
|
67
66
|
def convert_string string
|
68
|
-
return string unless string.respond_to? :chars # your ruby is lame
|
69
67
|
return string unless @in_b or @in_em
|
70
68
|
chars = if @in_b then
|
71
69
|
string.chars.map do |char| "#{char}\b#{char}" end
|
@@ -77,4 +75,3 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
|
|
77
75
|
end
|
78
76
|
|
79
77
|
end
|
80
|
-
|