rdoc 7.2.0 → 8.1.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 +4 -7
- data/LICENSE.rdoc +4 -0
- data/README.md +43 -2
- data/RI.md +75 -75
- data/doc/markup_reference/markdown.md +104 -3
- data/exe/rdoc +2 -2
- data/lib/rdoc/code_object/alias.rb +70 -74
- data/lib/rdoc/code_object/any_method.rb +305 -298
- data/lib/rdoc/code_object/attr.rb +150 -143
- data/lib/rdoc/code_object/class_module.rb +801 -765
- data/lib/rdoc/code_object/constant.rb +178 -150
- data/lib/rdoc/code_object/context/section.rb +133 -160
- data/lib/rdoc/code_object/context.rb +925 -952
- data/lib/rdoc/code_object/extend.rb +7 -5
- data/lib/rdoc/code_object/include.rb +7 -5
- data/lib/rdoc/code_object/method_attr.rb +325 -324
- data/lib/rdoc/code_object/mixin.rb +97 -95
- data/lib/rdoc/code_object/normal_class.rb +77 -78
- data/lib/rdoc/code_object/normal_module.rb +61 -59
- data/lib/rdoc/code_object/require.rb +23 -39
- data/lib/rdoc/code_object/single_class.rb +21 -19
- data/lib/rdoc/code_object/top_level.rb +212 -213
- data/lib/rdoc/code_object.rb +305 -305
- data/lib/rdoc/comment.rb +274 -337
- data/lib/rdoc/cross_reference.rb +194 -212
- data/lib/rdoc/encoding.rb +105 -103
- data/lib/rdoc/erb_partial.rb +13 -11
- data/lib/rdoc/erbio.rb +29 -27
- data/lib/rdoc/generator/aliki.rb +165 -140
- data/lib/rdoc/generator/darkfish.rb +647 -631
- data/lib/rdoc/generator/json_index.rb +233 -229
- data/lib/rdoc/generator/markup.rb +165 -122
- data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
- data/lib/rdoc/generator/pot/po.rb +52 -51
- data/lib/rdoc/generator/pot/po_entry.rb +138 -132
- data/lib/rdoc/generator/pot.rb +85 -81
- data/lib/rdoc/generator/ri.rb +23 -19
- data/lib/rdoc/generator/template/aliki/DESIGN.md +538 -0
- data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_head.rhtml +11 -11
- data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +2 -2
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/class.rhtml +56 -46
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +538 -283
- data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/js/aliki.js +80 -102
- data/lib/rdoc/generator/template/aliki/page.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/class.rhtml +18 -21
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +0 -1
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/generator.rb +48 -46
- data/lib/rdoc/i18n/locale.rb +99 -95
- data/lib/rdoc/i18n/text.rb +109 -105
- data/lib/rdoc/i18n.rb +7 -5
- data/lib/rdoc/markdown/byte_runtime.rb +80 -0
- data/lib/rdoc/markdown.kpeg +30 -21
- data/lib/rdoc/markdown.rb +329 -151
- data/lib/rdoc/markup/block_quote.rb +12 -8
- data/lib/rdoc/markup/document.rb +127 -123
- data/lib/rdoc/markup/formatter.rb +215 -221
- data/lib/rdoc/markup/heading.rb +1 -4
- data/lib/rdoc/markup/include.rb +33 -29
- data/lib/rdoc/markup/indented_paragraph.rb +37 -33
- data/lib/rdoc/markup/inline_parser.rb +281 -277
- data/lib/rdoc/markup/list.rb +80 -88
- data/lib/rdoc/markup/list_item.rb +73 -85
- data/lib/rdoc/markup/paragraph.rb +23 -19
- data/lib/rdoc/markup/parser.rb +501 -497
- data/lib/rdoc/markup/pre_process.rb +284 -305
- data/lib/rdoc/markup/raw.rb +2 -2
- data/lib/rdoc/markup/rule.rb +16 -12
- data/lib/rdoc/markup/to_ansi.rb +143 -139
- data/lib/rdoc/markup/to_bs.rb +72 -68
- data/lib/rdoc/markup/to_html.rb +600 -493
- data/lib/rdoc/markup/to_html_crossref.rb +221 -191
- data/lib/rdoc/markup/to_html_snippet.rb +232 -227
- data/lib/rdoc/markup/to_joined_paragraph.rb +40 -41
- data/lib/rdoc/markup/to_label.rb +63 -59
- data/lib/rdoc/markup/to_markdown.rb +212 -208
- data/lib/rdoc/markup/to_rdoc.rb +336 -332
- data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
- data/lib/rdoc/markup/to_test.rb +60 -56
- data/lib/rdoc/markup/to_tt_only.rb +83 -86
- data/lib/rdoc/markup/verbatim.rb +62 -58
- data/lib/rdoc/markup.rb +198 -196
- data/lib/rdoc/options.rb +1063 -1076
- data/lib/rdoc/parser/c.rb +1039 -1036
- data/lib/rdoc/parser/changelog.rb +319 -315
- data/lib/rdoc/parser/markdown.rb +17 -13
- data/lib/rdoc/parser/rbs.rb +279 -0
- data/lib/rdoc/parser/rd.rb +17 -13
- data/lib/rdoc/parser/ruby.rb +1231 -2222
- data/lib/rdoc/parser/ruby_colorizer.rb +303 -0
- data/lib/rdoc/parser/simple.rb +31 -27
- data/lib/rdoc/parser/text.rb +12 -8
- data/lib/rdoc/parser.rb +230 -221
- data/lib/rdoc/rbs_helper.rb +186 -0
- data/lib/rdoc/rd/inline.rb +57 -53
- data/lib/rdoc/rd.rb +90 -88
- data/lib/rdoc/rdoc.rb +547 -366
- data/lib/rdoc/ri/driver.rb +1141 -1130
- data/lib/rdoc/ri/formatter.rb +7 -3
- data/lib/rdoc/ri/paths.rb +140 -136
- data/lib/rdoc/ri/servlet.rb +456 -0
- data/lib/rdoc/ri/store.rb +4 -2
- data/lib/rdoc/ri/task.rb +55 -51
- data/lib/rdoc/ri.rb +14 -11
- data/lib/rdoc/rubygems_hook.rb +194 -192
- data/lib/rdoc/server.rb +462 -0
- data/lib/rdoc/stats/normal.rb +46 -42
- data/lib/rdoc/stats/quiet.rb +39 -35
- data/lib/rdoc/stats/verbose.rb +35 -31
- data/lib/rdoc/stats.rb +363 -338
- data/lib/rdoc/store.rb +919 -725
- data/lib/rdoc/task.rb +260 -255
- data/lib/rdoc/text.rb +130 -245
- data/lib/rdoc/token_stream.rb +101 -115
- data/lib/rdoc/tom_doc.rb +203 -201
- data/lib/rdoc/version.rb +1 -1
- data/lib/rdoc.rb +35 -7
- data/lib/rubygems_plugin.rb +2 -11
- data/rdoc-logo.svg +43 -0
- data/rdoc.gemspec +6 -4
- metadata +36 -20
- data/lib/rdoc/code_object/anon_class.rb +0 -10
- data/lib/rdoc/code_object/ghost_method.rb +0 -6
- data/lib/rdoc/code_object/meta_method.rb +0 -6
- data/lib/rdoc/markdown/literals.kpeg +0 -21
- data/lib/rdoc/markdown/literals.rb +0 -454
- data/lib/rdoc/parser/prism_ruby.rb +0 -1112
- data/lib/rdoc/parser/ripper_state_lex.rb +0 -302
- data/lib/rdoc/parser/ruby_tools.rb +0 -163
- data/lib/rdoc/servlet.rb +0 -452
|
@@ -1,342 +1,321 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
# is
|
|
15
|
-
#
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
# Registered post-processors
|
|
36
|
-
|
|
37
|
-
def self.post_processors
|
|
38
|
-
@post_processors
|
|
39
|
-
end
|
|
2
|
+
module RDoc
|
|
3
|
+
class Markup
|
|
4
|
+
##
|
|
5
|
+
# Handle common directives that can occur in a block of text:
|
|
6
|
+
#
|
|
7
|
+
# \:include: filename
|
|
8
|
+
#
|
|
9
|
+
# Directives can be escaped by preceding them with a backslash.
|
|
10
|
+
#
|
|
11
|
+
# RDoc plugin authors can register additional directives to be handled by
|
|
12
|
+
# using RDoc::Markup::PreProcess::register.
|
|
13
|
+
#
|
|
14
|
+
# Any directive that is not built-in to RDoc (including those registered via
|
|
15
|
+
# plugins) will be stored in the metadata hash on the CodeObject the comment
|
|
16
|
+
# is attached to. See RDoc::Markup@Directives for the list of built-in
|
|
17
|
+
# directives.
|
|
18
|
+
|
|
19
|
+
class PreProcess
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# An RDoc::Options instance that will be filled in with overrides from
|
|
23
|
+
# directives
|
|
24
|
+
|
|
25
|
+
attr_accessor :options
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# Adds a post-process handler for directives. The handler will be called
|
|
29
|
+
# with the result RDoc::Comment (or text String) and the code object for the
|
|
30
|
+
# comment (if any).
|
|
31
|
+
|
|
32
|
+
def self.post_process(&block)
|
|
33
|
+
@post_processors << block
|
|
34
|
+
end
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
# directive will be replaced by the result of the block, otherwise the
|
|
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
|
|
52
|
-
|
|
53
|
-
def self.register(directive, &block)
|
|
54
|
-
@registered[directive] = block
|
|
55
|
-
end
|
|
36
|
+
##
|
|
37
|
+
# Registered post-processors
|
|
56
38
|
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
def self.post_processors
|
|
40
|
+
@post_processors
|
|
41
|
+
end
|
|
59
42
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
##
|
|
44
|
+
# Registers +directive+ as one handled by RDoc. If a block is given the
|
|
45
|
+
# directive will be replaced by the result of the block, otherwise the
|
|
46
|
+
# directive will be removed from the processed text.
|
|
47
|
+
#
|
|
48
|
+
# The block will be called with the directive name and the directive
|
|
49
|
+
# parameter:
|
|
50
|
+
#
|
|
51
|
+
# RDoc::Markup::PreProcess.register 'my-directive' do |directive, param|
|
|
52
|
+
# # replace text, etc.
|
|
53
|
+
# end
|
|
54
|
+
|
|
55
|
+
def self.register(directive, &block)
|
|
56
|
+
@registered[directive] = block
|
|
57
|
+
end
|
|
63
58
|
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
##
|
|
60
|
+
# Registered directives
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
end
|
|
62
|
+
def self.registered
|
|
63
|
+
@registered
|
|
64
|
+
end
|
|
71
65
|
|
|
72
|
-
|
|
66
|
+
##
|
|
67
|
+
# Clears all registered directives and post-processors
|
|
73
68
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
def self.reset
|
|
70
|
+
@post_processors = []
|
|
71
|
+
@registered = {}
|
|
72
|
+
end
|
|
77
73
|
|
|
78
|
-
|
|
79
|
-
@input_file_name = input_file_name
|
|
80
|
-
@include_path = include_path
|
|
81
|
-
@options = nil
|
|
82
|
-
end
|
|
74
|
+
reset
|
|
83
75
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
# Options that we don't handle are yielded. If the block returns false the
|
|
88
|
-
# directive is restored to the text. If the block returns nil or no block
|
|
89
|
-
# was given the directive is handled according to the registered directives.
|
|
90
|
-
# If a String was returned the directive is replaced with the string.
|
|
91
|
-
#
|
|
92
|
-
# If no matching directive was registered the directive is restored to the
|
|
93
|
-
# text.
|
|
94
|
-
#
|
|
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
|
|
76
|
+
##
|
|
77
|
+
# Creates a new pre-processor for +input_file_name+ that will look for
|
|
78
|
+
# included files in +include_path+
|
|
104
79
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
# skip something like ':toto::'
|
|
110
|
-
next $& if $4.empty? and $5 and $5[0, 1] == ':'
|
|
111
|
-
|
|
112
|
-
# skip if escaped
|
|
113
|
-
next "#$1:#$3:#$4#$5\n" unless $2.empty?
|
|
114
|
-
|
|
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"
|
|
80
|
+
def initialize(input_file_name, include_path)
|
|
81
|
+
@input_file_name = input_file_name
|
|
82
|
+
@include_path = include_path
|
|
83
|
+
@options = nil
|
|
121
84
|
end
|
|
122
|
-
handle_directive $1, $3, $5, code_object, text.encoding, &block
|
|
123
|
-
end
|
|
124
85
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
86
|
+
##
|
|
87
|
+
# Look for directives in the given +text+.
|
|
88
|
+
#
|
|
89
|
+
# Options that we don't handle are yielded. If the block returns false the
|
|
90
|
+
# directive is restored to the text. If the block returns nil or no block
|
|
91
|
+
# was given the directive is handled according to the registered directives.
|
|
92
|
+
# If a String was returned the directive is replaced with the string.
|
|
93
|
+
#
|
|
94
|
+
# If no matching directive was registered the directive is restored to the
|
|
95
|
+
# text.
|
|
96
|
+
#
|
|
97
|
+
# If +code_object+ is given and the directive is unknown then the
|
|
98
|
+
# directive's parameter is set as metadata on the +code_object+. See
|
|
99
|
+
# RDoc::CodeObject#metadata for details.
|
|
100
|
+
|
|
101
|
+
def handle(text, code_object = nil, &block)
|
|
102
|
+
if Comment === text
|
|
103
|
+
comment = text
|
|
104
|
+
text = text.text
|
|
105
|
+
end
|
|
130
106
|
|
|
131
|
-
|
|
107
|
+
# regexp helper (square brackets for optional)
|
|
108
|
+
# $1 $2 $3 $4 $5
|
|
109
|
+
# [prefix][\]:directive:[spaces][param]newline
|
|
110
|
+
text = text.gsub(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):([\w-]+):([ \t]*)(.+)?(\r?\n|$)/) do
|
|
111
|
+
# skip something like ':toto::'
|
|
112
|
+
next $& if $4.empty? and $5 and $5[0, 1] == ':'
|
|
113
|
+
|
|
114
|
+
# skip if escaped
|
|
115
|
+
next "#$1:#$3:#$4#$5\n" unless $2.empty?
|
|
116
|
+
|
|
117
|
+
# This is not in handle_directive because I didn't want to pass another
|
|
118
|
+
# argument into it
|
|
119
|
+
if comment and $3 == 'markup'
|
|
120
|
+
next "#{$1.strip}\n" unless $5
|
|
121
|
+
comment.format = $5.downcase
|
|
122
|
+
next "#{$1.strip}\n"
|
|
123
|
+
end
|
|
124
|
+
handle_directive $1, $3, $5, code_object, text.encoding, &block
|
|
125
|
+
end
|
|
132
126
|
|
|
133
|
-
|
|
134
|
-
|
|
127
|
+
if comment
|
|
128
|
+
comment.text = text
|
|
129
|
+
else
|
|
130
|
+
comment = text
|
|
131
|
+
end
|
|
135
132
|
|
|
136
|
-
|
|
133
|
+
run_post_processes(comment, code_object)
|
|
137
134
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
directives.each do |directive, (param, line_no)|
|
|
141
|
-
handle_directive('', directive, param, code_object)
|
|
142
|
-
end
|
|
143
|
-
if code_object.is_a?(RDoc::AnyMethod) && (call_seq, = directives['call-seq']) && call_seq
|
|
144
|
-
code_object.call_seq = call_seq.lines.map(&:chomp).reject(&:empty?).join("\n")
|
|
145
|
-
end
|
|
146
|
-
format, = directives['markup']
|
|
147
|
-
[comment_text, format]
|
|
148
|
-
end
|
|
135
|
+
text
|
|
136
|
+
end
|
|
149
137
|
|
|
150
|
-
|
|
138
|
+
# Apply directives to a code object
|
|
151
139
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
140
|
+
def run_pre_processes(comment_text, code_object, start_line_no, type)
|
|
141
|
+
comment_text, directives = parse_comment(comment_text, start_line_no, type)
|
|
142
|
+
directives.each do |directive, (param, line_no)|
|
|
143
|
+
handle_directive('', directive, param, code_object)
|
|
144
|
+
end
|
|
145
|
+
if code_object.is_a?(AnyMethod) && (call_seq, = directives['call-seq']) && call_seq
|
|
146
|
+
code_object.call_seq = call_seq.lines.map(&:chomp).reject(&:empty?).join("\n")
|
|
147
|
+
end
|
|
148
|
+
format, = directives['markup']
|
|
149
|
+
[comment_text, format]
|
|
150
|
+
end
|
|
157
151
|
|
|
158
|
-
|
|
152
|
+
# Perform post preocesses to a code object
|
|
159
153
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
154
|
+
def run_post_processes(comment, code_object)
|
|
155
|
+
self.class.post_processors.each do |handler|
|
|
156
|
+
handler.call comment, code_object
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Parse comment and return [normalized_comment_text, directives_hash]
|
|
165
161
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
# +prefix+ is used to ensure the replacement for handled directives is
|
|
171
|
-
# correct. +encoding+ is used for the <tt>include</tt> directive.
|
|
172
|
-
#
|
|
173
|
-
# For a list of directives in RDoc see RDoc::Markup.
|
|
174
|
-
#--
|
|
175
|
-
# When 1.8.7 support is ditched prefix can be defaulted to ''
|
|
176
|
-
|
|
177
|
-
def handle_directive(prefix, directive, param, code_object = nil,
|
|
178
|
-
encoding = nil)
|
|
179
|
-
blankline = "#{prefix.strip}\n"
|
|
180
|
-
directive = directive.downcase
|
|
181
|
-
|
|
182
|
-
case directive
|
|
183
|
-
when 'arg', 'args' then
|
|
184
|
-
return "#{prefix}:#{directive}: #{param}\n" unless code_object && code_object.kind_of?(RDoc::AnyMethod)
|
|
185
|
-
|
|
186
|
-
code_object.params = param
|
|
187
|
-
|
|
188
|
-
blankline
|
|
189
|
-
when 'category' then
|
|
190
|
-
if RDoc::Context === code_object then
|
|
191
|
-
section = code_object.add_section param
|
|
192
|
-
code_object.temporary_section = section
|
|
193
|
-
elsif RDoc::AnyMethod === code_object then
|
|
194
|
-
code_object.section_title = param
|
|
162
|
+
def parse_comment(text, line_no, type)
|
|
163
|
+
Comment.parse(text, @input_file_name, line_no, type) do |filename, prefix_indent|
|
|
164
|
+
include_file(filename, prefix_indent, text.encoding)
|
|
165
|
+
end
|
|
195
166
|
end
|
|
196
167
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
code_object
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if RDoc::Markup::PreProcess.registered.include? directive then
|
|
278
|
-
handler = RDoc::Markup::PreProcess.registered[directive]
|
|
279
|
-
result = handler.call directive, param if handler
|
|
168
|
+
##
|
|
169
|
+
# Performs the actions described by +directive+ and its parameter +param+.
|
|
170
|
+
#
|
|
171
|
+
# +code_object+ is used for directives that operate on a class or module.
|
|
172
|
+
# +prefix+ is used to ensure the replacement for handled directives is
|
|
173
|
+
# correct. +encoding+ is used for the <tt>include</tt> directive.
|
|
174
|
+
#
|
|
175
|
+
# For a list of directives in RDoc see RDoc::Markup.
|
|
176
|
+
#--
|
|
177
|
+
# When 1.8.7 support is ditched prefix can be defaulted to ''
|
|
178
|
+
|
|
179
|
+
def handle_directive(prefix, directive, param, code_object = nil,
|
|
180
|
+
encoding = nil)
|
|
181
|
+
blankline = "#{prefix.strip}\n"
|
|
182
|
+
directive = directive.downcase
|
|
183
|
+
|
|
184
|
+
case directive
|
|
185
|
+
when 'arg', 'args'
|
|
186
|
+
return "#{prefix}:#{directive}: #{param}\n" unless code_object && code_object.kind_of?(AnyMethod)
|
|
187
|
+
|
|
188
|
+
code_object.params = param
|
|
189
|
+
|
|
190
|
+
blankline
|
|
191
|
+
when 'category'
|
|
192
|
+
if Context === code_object
|
|
193
|
+
section = code_object.add_section param
|
|
194
|
+
code_object.temporary_section = section
|
|
195
|
+
elsif AnyMethod === code_object
|
|
196
|
+
code_object.section_title = param
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
blankline # ignore category if we're not on an RDoc::Context
|
|
200
|
+
when 'doc'
|
|
201
|
+
return blankline unless code_object
|
|
202
|
+
code_object.document_self = true
|
|
203
|
+
code_object.force_documentation = true
|
|
204
|
+
|
|
205
|
+
blankline
|
|
206
|
+
when 'enddoc'
|
|
207
|
+
return blankline unless code_object
|
|
208
|
+
code_object.done_documenting = true
|
|
209
|
+
|
|
210
|
+
blankline
|
|
211
|
+
when 'include'
|
|
212
|
+
filename = param.split(' ', 2).first
|
|
213
|
+
include_file filename, prefix, encoding
|
|
214
|
+
when 'nodoc'
|
|
215
|
+
return blankline unless code_object
|
|
216
|
+
code_object.document_self = nil # notify nodoc
|
|
217
|
+
code_object.document_children = param !~ /all/i
|
|
218
|
+
|
|
219
|
+
blankline
|
|
220
|
+
when 'notnew', 'not_new', 'not-new'
|
|
221
|
+
return blankline unless AnyMethod === code_object
|
|
222
|
+
|
|
223
|
+
code_object.dont_rename_initialize = true
|
|
224
|
+
|
|
225
|
+
blankline
|
|
226
|
+
when 'startdoc'
|
|
227
|
+
return blankline unless code_object
|
|
228
|
+
|
|
229
|
+
code_object.start_doc
|
|
230
|
+
code_object.force_documentation = true
|
|
231
|
+
|
|
232
|
+
blankline
|
|
233
|
+
when 'stopdoc'
|
|
234
|
+
return blankline unless code_object
|
|
235
|
+
|
|
236
|
+
code_object.stop_doc
|
|
237
|
+
|
|
238
|
+
blankline
|
|
239
|
+
when 'yield', 'yields'
|
|
240
|
+
return blankline unless code_object
|
|
241
|
+
# remove parameter &block
|
|
242
|
+
code_object.params = code_object.params.sub(/,?\s*&\w+/, '') if code_object.params
|
|
243
|
+
|
|
244
|
+
code_object.block_params = param || ''
|
|
245
|
+
|
|
246
|
+
blankline
|
|
280
247
|
else
|
|
281
|
-
result =
|
|
248
|
+
result = yield directive, param if block_given?
|
|
249
|
+
|
|
250
|
+
case result
|
|
251
|
+
when nil
|
|
252
|
+
code_object.metadata[directive] = param if code_object
|
|
253
|
+
|
|
254
|
+
if Markup::PreProcess.registered.include? directive
|
|
255
|
+
handler = Markup::PreProcess.registered[directive]
|
|
256
|
+
result = handler.call directive, param if handler
|
|
257
|
+
else
|
|
258
|
+
result = "#{prefix}:#{directive}: #{param}\n"
|
|
259
|
+
end
|
|
260
|
+
when false
|
|
261
|
+
result = "#{prefix}:#{directive}: #{param}\n"
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
result
|
|
282
265
|
end
|
|
283
|
-
when false then
|
|
284
|
-
result = "#{prefix}:#{directive}: #{param}\n"
|
|
285
266
|
end
|
|
286
267
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
268
|
+
##
|
|
269
|
+
# Handles the <tt>:include: _filename_</tt> directive.
|
|
270
|
+
#
|
|
271
|
+
# If the first line of the included file starts with '#', and contains
|
|
272
|
+
# an encoding information in the form 'coding:' or 'coding=', it is
|
|
273
|
+
# removed.
|
|
274
|
+
#
|
|
275
|
+
# If all lines in the included file start with a '#', this leading '#'
|
|
276
|
+
# is removed before inclusion. The included content is indented like
|
|
277
|
+
# the <tt>:include:</tt> directive.
|
|
278
|
+
#--
|
|
279
|
+
# so all content will be verbatim because of the likely space after '#'?
|
|
280
|
+
# TODO shift left the whole file content in that case
|
|
281
|
+
# TODO comment stop/start #-- and #++ in included file must be processed here
|
|
282
|
+
|
|
283
|
+
def include_file(name, indent, encoding)
|
|
284
|
+
full_name = find_include_file name
|
|
285
|
+
|
|
286
|
+
unless full_name
|
|
287
|
+
warn "Couldn't find file to include '#{name}' from #{@input_file_name}"
|
|
288
|
+
return ''
|
|
289
|
+
end
|
|
290
290
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
#
|
|
294
|
-
# If the first line of the included file starts with '#', and contains
|
|
295
|
-
# an encoding information in the form 'coding:' or 'coding=', it is
|
|
296
|
-
# removed.
|
|
297
|
-
#
|
|
298
|
-
# If all lines in the included file start with a '#', this leading '#'
|
|
299
|
-
# is removed before inclusion. The included content is indented like
|
|
300
|
-
# the <tt>:include:</tt> directive.
|
|
301
|
-
#--
|
|
302
|
-
# so all content will be verbatim because of the likely space after '#'?
|
|
303
|
-
# TODO shift left the whole file content in that case
|
|
304
|
-
# TODO comment stop/start #-- and #++ in included file must be processed here
|
|
305
|
-
|
|
306
|
-
def include_file(name, indent, encoding)
|
|
307
|
-
full_name = find_include_file name
|
|
308
|
-
|
|
309
|
-
unless full_name then
|
|
310
|
-
warn "Couldn't find file to include '#{name}' from #{@input_file_name}"
|
|
311
|
-
return ''
|
|
312
|
-
end
|
|
291
|
+
content = Encoding.read_file full_name, encoding, true
|
|
292
|
+
content = Encoding.remove_magic_comment content
|
|
313
293
|
|
|
314
|
-
|
|
315
|
-
|
|
294
|
+
# strip magic comment
|
|
295
|
+
content = content.sub(/\A# .*coding[=:].*$/, '').lstrip
|
|
316
296
|
|
|
317
|
-
|
|
318
|
-
|
|
297
|
+
# strip leading '#'s, but only if all lines start with them
|
|
298
|
+
if content =~ /^[^#]/
|
|
299
|
+
content.gsub(/^/, indent)
|
|
300
|
+
else
|
|
301
|
+
content.gsub(/^#?/, indent)
|
|
302
|
+
end
|
|
303
|
+
end
|
|
319
304
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
else
|
|
324
|
-
content.gsub(/^#?/, indent)
|
|
325
|
-
end
|
|
326
|
-
end
|
|
305
|
+
##
|
|
306
|
+
# Look for the given file in the directory containing the current file,
|
|
307
|
+
# and then in each of the directories specified in the RDOC_INCLUDE path
|
|
327
308
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
309
|
+
def find_include_file(name)
|
|
310
|
+
to_search = [File.dirname(@input_file_name)].concat @include_path
|
|
311
|
+
to_search.each do |dir|
|
|
312
|
+
full_name = File.join(dir, name)
|
|
313
|
+
stat = File.stat(full_name) rescue next
|
|
314
|
+
return full_name if stat.readable?
|
|
315
|
+
end
|
|
316
|
+
nil
|
|
317
|
+
end
|
|
331
318
|
|
|
332
|
-
def find_include_file(name)
|
|
333
|
-
to_search = [File.dirname(@input_file_name)].concat @include_path
|
|
334
|
-
to_search.each do |dir|
|
|
335
|
-
full_name = File.join(dir, name)
|
|
336
|
-
stat = File.stat(full_name) rescue next
|
|
337
|
-
return full_name if stat.readable?
|
|
338
319
|
end
|
|
339
|
-
nil
|
|
340
320
|
end
|
|
341
|
-
|
|
342
321
|
end
|
data/lib/rdoc/markup/raw.rb
CHANGED