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
|
@@ -6,813 +6,829 @@ require 'fileutils'
|
|
|
6
6
|
require 'pathname'
|
|
7
7
|
require_relative 'markup'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
9
|
+
module RDoc
|
|
10
|
+
module Generator
|
|
11
|
+
##
|
|
12
|
+
# Darkfish RDoc HTML Generator
|
|
13
|
+
#
|
|
14
|
+
# $Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $
|
|
15
|
+
#
|
|
16
|
+
# == Author/s
|
|
17
|
+
# * Michael Granger (ged@FaerieMUD.org)
|
|
18
|
+
#
|
|
19
|
+
# == Contributors
|
|
20
|
+
# * Mahlon E. Smith (mahlon@martini.nu)
|
|
21
|
+
# * Eric Hodel (drbrain@segment7.net)
|
|
22
|
+
#
|
|
23
|
+
# == License
|
|
24
|
+
#
|
|
25
|
+
# Copyright (c) 2007, 2008, Michael Granger. All rights reserved.
|
|
26
|
+
#
|
|
27
|
+
# Redistribution and use in source and binary forms, with or without
|
|
28
|
+
# modification, are permitted provided that the following conditions are met:
|
|
29
|
+
#
|
|
30
|
+
# * Redistributions of source code must retain the above copyright notice,
|
|
31
|
+
# this list of conditions and the following disclaimer.
|
|
32
|
+
#
|
|
33
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
34
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
35
|
+
# and/or other materials provided with the distribution.
|
|
36
|
+
#
|
|
37
|
+
# * Neither the name of the author/s, nor the names of the project's
|
|
38
|
+
# contributors may be used to endorse or promote products derived from this
|
|
39
|
+
# software without specific prior written permission.
|
|
40
|
+
#
|
|
41
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
42
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
43
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
44
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
45
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
46
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
47
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
48
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
49
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
50
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
51
|
+
#
|
|
52
|
+
# == Attributions
|
|
53
|
+
#
|
|
54
|
+
# Darkfish uses the {Silk Icons}[http://www.famfamfam.com/lab/icons/silk/] set
|
|
55
|
+
# by Mark James.
|
|
56
|
+
|
|
57
|
+
class Darkfish
|
|
58
|
+
|
|
59
|
+
RDoc.add_generator self
|
|
60
|
+
|
|
61
|
+
include ERB::Util
|
|
62
|
+
|
|
63
|
+
##
|
|
64
|
+
# Stylesheets, fonts, etc. that are included in RDoc.
|
|
65
|
+
|
|
66
|
+
BUILTIN_STYLE_ITEMS = # :nodoc:
|
|
67
|
+
%w[
|
|
68
|
+
css/fonts.css
|
|
69
|
+
fonts/Lato-Light.ttf
|
|
70
|
+
fonts/Lato-LightItalic.ttf
|
|
71
|
+
fonts/Lato-Regular.ttf
|
|
72
|
+
fonts/Lato-RegularItalic.ttf
|
|
73
|
+
fonts/SourceCodePro-Bold.ttf
|
|
74
|
+
fonts/SourceCodePro-Regular.ttf
|
|
75
|
+
css/rdoc.css
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
##
|
|
79
|
+
# Description of this generator
|
|
80
|
+
|
|
81
|
+
DESCRIPTION = 'HTML generator, written by Michael Granger'
|
|
82
|
+
|
|
83
|
+
##
|
|
84
|
+
# The relative path to style sheets and javascript. By default this is set
|
|
85
|
+
# the same as the rel_prefix.
|
|
86
|
+
|
|
87
|
+
attr_accessor :asset_rel_path
|
|
88
|
+
|
|
89
|
+
##
|
|
90
|
+
# The path to generate files into, combined with <tt>--op</tt> from the
|
|
91
|
+
# options for a full path.
|
|
92
|
+
|
|
93
|
+
attr_reader :base_dir
|
|
94
|
+
|
|
95
|
+
##
|
|
96
|
+
# Classes and modules to be used by this generator, not necessarily
|
|
97
|
+
# displayed. See also #modsort
|
|
98
|
+
|
|
99
|
+
attr_reader :classes
|
|
100
|
+
|
|
101
|
+
##
|
|
102
|
+
# No files will be written when dry_run is true.
|
|
103
|
+
|
|
104
|
+
attr_accessor :dry_run
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# When false the generate methods return a String instead of writing to a
|
|
108
|
+
# file. The default is true.
|
|
109
|
+
|
|
110
|
+
attr_accessor :file_output
|
|
111
|
+
|
|
112
|
+
##
|
|
113
|
+
# Files to be displayed by this generator
|
|
114
|
+
|
|
115
|
+
attr_reader :files
|
|
116
|
+
|
|
117
|
+
##
|
|
118
|
+
# The JSON index generator for this Darkfish generator
|
|
119
|
+
|
|
120
|
+
attr_reader :json_index
|
|
117
121
|
|
|
118
|
-
|
|
122
|
+
##
|
|
123
|
+
# Methods to be displayed by this generator
|
|
119
124
|
|
|
120
|
-
|
|
121
|
-
# The JSON index generator for this Darkfish generator
|
|
125
|
+
attr_reader :methods
|
|
122
126
|
|
|
123
|
-
|
|
127
|
+
##
|
|
128
|
+
# Sorted list of classes and modules to be displayed by this generator
|
|
124
129
|
|
|
125
|
-
|
|
126
|
-
# Methods to be displayed by this generator
|
|
130
|
+
attr_reader :modsort
|
|
127
131
|
|
|
128
|
-
|
|
132
|
+
##
|
|
133
|
+
# The RDoc::Store that is the source of the generated content
|
|
129
134
|
|
|
130
|
-
|
|
131
|
-
# Sorted list of classes and modules to be displayed by this generator
|
|
135
|
+
attr_reader :store
|
|
132
136
|
|
|
133
|
-
|
|
137
|
+
##
|
|
138
|
+
# The directory where the template files live
|
|
134
139
|
|
|
135
|
-
|
|
136
|
-
# The RDoc::Store that is the source of the generated content
|
|
140
|
+
attr_reader :template_dir # :nodoc:
|
|
137
141
|
|
|
138
|
-
|
|
142
|
+
##
|
|
143
|
+
# The output directory
|
|
139
144
|
|
|
140
|
-
|
|
141
|
-
# The directory where the template files live
|
|
145
|
+
attr_reader :outputdir
|
|
142
146
|
|
|
143
|
-
|
|
147
|
+
##
|
|
148
|
+
# Initialize a few instance variables before we start
|
|
144
149
|
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
def initialize(store, options)
|
|
151
|
+
@store = store
|
|
152
|
+
@options = options
|
|
147
153
|
|
|
148
|
-
|
|
154
|
+
@asset_rel_path = ''
|
|
155
|
+
@base_dir = Pathname.pwd.expand_path
|
|
156
|
+
@dry_run = @options.dry_run
|
|
157
|
+
@file_output = true
|
|
158
|
+
@template_dir = Pathname.new options.template_dir
|
|
159
|
+
@template_cache = {}
|
|
149
160
|
|
|
150
|
-
|
|
151
|
-
|
|
161
|
+
@classes = nil
|
|
162
|
+
@context = nil
|
|
163
|
+
@files = nil
|
|
164
|
+
@methods = nil
|
|
165
|
+
@modsort = nil
|
|
152
166
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
@options = options
|
|
156
|
-
|
|
157
|
-
@asset_rel_path = ''
|
|
158
|
-
@base_dir = Pathname.pwd.expand_path
|
|
159
|
-
@dry_run = @options.dry_run
|
|
160
|
-
@file_output = true
|
|
161
|
-
@template_dir = Pathname.new options.template_dir
|
|
162
|
-
@template_cache = {}
|
|
163
|
-
|
|
164
|
-
@classes = nil
|
|
165
|
-
@context = nil
|
|
166
|
-
@files = nil
|
|
167
|
-
@methods = nil
|
|
168
|
-
@modsort = nil
|
|
167
|
+
@json_index = Generator::JsonIndex.new self, options
|
|
168
|
+
end
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
##
|
|
171
|
+
# Output progress information if debugging is enabled
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
def debug_msg(*msg)
|
|
174
|
+
return unless $DEBUG_RDOC
|
|
175
|
+
$stderr.puts(*msg)
|
|
176
|
+
end
|
|
175
177
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
end
|
|
178
|
+
##
|
|
179
|
+
# Create the directories the generated docs will live in if they don't
|
|
180
|
+
# already exist.
|
|
180
181
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
def gen_sub_directories
|
|
183
|
+
@outputdir.mkpath
|
|
184
|
+
end
|
|
184
185
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
##
|
|
187
|
+
# Copy over the stylesheet into the appropriate place in the output
|
|
188
|
+
# directory.
|
|
188
189
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
def write_style_sheet
|
|
191
|
+
debug_msg "Copying static files"
|
|
192
|
+
options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }
|
|
192
193
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
BUILTIN_STYLE_ITEMS.each do |item|
|
|
195
|
+
install_rdoc_static_file @template_dir + item, "./#{item}", options
|
|
196
|
+
end
|
|
196
197
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
unless @options.template_stylesheets.empty?
|
|
199
|
+
FileUtils.cp @options.template_stylesheets, '.', **options
|
|
200
|
+
end
|
|
200
201
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
|
|
203
|
+
next if File.directory? path
|
|
204
|
+
next if File.basename(path) =~ /^\./
|
|
204
205
|
|
|
205
|
-
|
|
206
|
-
next if File.directory? path
|
|
207
|
-
next if File.basename(path) =~ /^\./
|
|
206
|
+
dst = Pathname.new(path).relative_path_from @template_dir
|
|
208
207
|
|
|
209
|
-
|
|
208
|
+
install_rdoc_static_file @template_dir + path, dst, options
|
|
209
|
+
end
|
|
210
|
+
end
|
|
210
211
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
##
|
|
213
|
+
# Build the initial indices and output objects based on an array of TopLevel
|
|
214
|
+
# objects containing the extracted information.
|
|
214
215
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
# objects containing the extracted information.
|
|
216
|
+
def generate
|
|
217
|
+
warn "The Darkfish template is deprecated and will be removed in version 9.0."
|
|
218
218
|
|
|
219
|
-
|
|
220
|
-
setup
|
|
219
|
+
setup
|
|
221
220
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
221
|
+
write_style_sheet
|
|
222
|
+
generate_index
|
|
223
|
+
generate_class_files
|
|
224
|
+
generate_file_files
|
|
225
|
+
generate_table_of_contents
|
|
226
|
+
@json_index.generate
|
|
227
|
+
@json_index.generate_gzipped
|
|
229
228
|
|
|
230
|
-
|
|
229
|
+
copy_static
|
|
231
230
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
231
|
+
rescue => e
|
|
232
|
+
debug_msg "%s: %s\n %s" % [
|
|
233
|
+
e.class.name, e.message, e.backtrace.join("\n ")
|
|
234
|
+
]
|
|
236
235
|
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
raise
|
|
237
|
+
end
|
|
239
238
|
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
##
|
|
240
|
+
# Copies static files from the static_path into the output directory
|
|
242
241
|
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
def copy_static
|
|
243
|
+
return if @options.static_path.empty?
|
|
245
244
|
|
|
246
|
-
|
|
245
|
+
fu_options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }
|
|
247
246
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
247
|
+
@options.static_path.each do |path|
|
|
248
|
+
unless File.directory? path
|
|
249
|
+
FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644)
|
|
250
|
+
next
|
|
251
|
+
end
|
|
253
252
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
Dir.chdir path do
|
|
254
|
+
Dir[File.join('**', '*')].each do |entry|
|
|
255
|
+
dest_file = @outputdir + entry
|
|
257
256
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
257
|
+
if File.directory? entry
|
|
258
|
+
FileUtils.mkdir_p entry, **fu_options
|
|
259
|
+
else
|
|
260
|
+
FileUtils.install entry, dest_file, **fu_options.merge(:mode => 0644)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
262
263
|
end
|
|
263
264
|
end
|
|
264
265
|
end
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
266
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
267
|
+
##
|
|
268
|
+
# Return a list of the documented modules sorted by salience first, then
|
|
269
|
+
# by name.
|
|
271
270
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
271
|
+
def get_sorted_module_list(classes)
|
|
272
|
+
classes.select do |klass|
|
|
273
|
+
klass.display?
|
|
274
|
+
end.sort
|
|
275
|
+
end
|
|
277
276
|
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
##
|
|
278
|
+
# Generate an index page which lists all the classes which are documented.
|
|
280
279
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
280
|
+
def generate_index
|
|
281
|
+
template_file = @template_dir + 'index.rhtml'
|
|
282
|
+
return unless template_file.exist?
|
|
284
283
|
|
|
285
|
-
|
|
284
|
+
debug_msg "Rendering the index page..."
|
|
286
285
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
286
|
+
out_file = @base_dir + @options.op_dir + 'index.html'
|
|
287
|
+
rel_prefix = @outputdir.relative_path_from out_file.dirname
|
|
288
|
+
search_index_rel_prefix = rel_prefix
|
|
289
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
|
291
290
|
|
|
292
|
-
|
|
291
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
|
293
292
|
|
|
294
|
-
|
|
295
|
-
|
|
293
|
+
@title = @options.title
|
|
294
|
+
@main_page = @files.find { |f| f.full_name == @options.main_page }
|
|
296
295
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
296
|
+
render_template template_file, out_file do |io|
|
|
297
|
+
here = binding
|
|
298
|
+
# suppress 1.9.3 warning
|
|
299
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
|
300
|
+
# some partials rely on the presence of current variable to render
|
|
301
|
+
here.local_variable_set(:current, @main_page) if @main_page
|
|
302
|
+
here
|
|
303
|
+
end
|
|
304
|
+
rescue => e
|
|
305
|
+
error = Error.new \
|
|
306
|
+
"error generating index.html: #{e.message} (#{e.class})"
|
|
307
|
+
error.set_backtrace e.backtrace
|
|
309
308
|
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
raise error
|
|
310
|
+
end
|
|
312
311
|
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
##
|
|
313
|
+
# Generates a class file for +klass+
|
|
315
314
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
315
|
+
def generate_class(klass, template_file = nil)
|
|
316
|
+
# This is used to auto-collapse Pages section on class/module pages
|
|
317
|
+
@inside_class_file = true
|
|
318
|
+
current = klass
|
|
320
319
|
|
|
321
|
-
|
|
320
|
+
template_file ||= @template_dir + 'class.rhtml'
|
|
322
321
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
322
|
+
debug_msg " working on %s (%s)" % [klass.full_name, klass.path]
|
|
323
|
+
out_file = @outputdir + klass.path
|
|
324
|
+
rel_prefix = @outputdir.relative_path_from out_file.dirname
|
|
325
|
+
search_index_rel_prefix = rel_prefix
|
|
326
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
|
328
327
|
|
|
329
|
-
|
|
328
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
|
330
329
|
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
breadcrumb = # used in templates
|
|
331
|
+
breadcrumb = generate_nesting_namespaces_breadcrumb(current, rel_prefix)
|
|
333
332
|
|
|
334
|
-
|
|
333
|
+
@title = "#{klass.type} #{klass.full_name} - #{@options.title}"
|
|
335
334
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
335
|
+
debug_msg " rendering #{out_file}"
|
|
336
|
+
render_template template_file, out_file do |io|
|
|
337
|
+
here = binding
|
|
338
|
+
# suppress 1.9.3 warning
|
|
339
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
|
340
|
+
here
|
|
341
|
+
end
|
|
342
|
+
ensure
|
|
343
|
+
@inside_class_file = false
|
|
344
|
+
end
|
|
346
345
|
|
|
347
|
-
|
|
348
|
-
|
|
346
|
+
##
|
|
347
|
+
# Generate a documentation file for each class and module
|
|
349
348
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
349
|
+
def generate_class_files
|
|
350
|
+
template_file = @template_dir + 'class.rhtml'
|
|
351
|
+
template_file = @template_dir + 'classpage.rhtml' unless
|
|
352
|
+
template_file.exist?
|
|
353
|
+
return unless template_file.exist?
|
|
354
|
+
debug_msg "Generating class documentation in #{@outputdir}"
|
|
356
355
|
|
|
357
|
-
|
|
356
|
+
current = nil
|
|
358
357
|
|
|
359
|
-
|
|
360
|
-
|
|
358
|
+
# Document files are generated only for non-alias classes/modules
|
|
359
|
+
@classes.reject(&:is_alias_for).each do |klass|
|
|
361
360
|
|
|
362
|
-
|
|
361
|
+
current = klass
|
|
363
362
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
363
|
+
generate_class klass, template_file
|
|
364
|
+
end
|
|
365
|
+
rescue => e
|
|
366
|
+
error = Error.new \
|
|
367
|
+
"error generating #{current.path}: #{e.message} (#{e.class})"
|
|
368
|
+
error.set_backtrace e.backtrace
|
|
370
369
|
|
|
371
|
-
|
|
372
|
-
|
|
370
|
+
raise error
|
|
371
|
+
end
|
|
373
372
|
|
|
374
|
-
|
|
375
|
-
|
|
373
|
+
##
|
|
374
|
+
# Generate a documentation file for each file
|
|
376
375
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
376
|
+
def generate_file_files
|
|
377
|
+
page_file = @template_dir + 'page.rhtml'
|
|
378
|
+
fileinfo_file = @template_dir + 'fileinfo.rhtml'
|
|
380
379
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
380
|
+
# for legacy templates
|
|
381
|
+
filepage_file = @template_dir + 'filepage.rhtml' unless
|
|
382
|
+
page_file.exist? or fileinfo_file.exist?
|
|
384
383
|
|
|
385
|
-
|
|
386
|
-
|
|
384
|
+
return unless
|
|
385
|
+
page_file.exist? or fileinfo_file.exist? or filepage_file.exist?
|
|
387
386
|
|
|
388
|
-
|
|
387
|
+
debug_msg "Generating file documentation in #{@outputdir}"
|
|
389
388
|
|
|
390
|
-
|
|
391
|
-
|
|
389
|
+
out_file = nil
|
|
390
|
+
current = nil
|
|
392
391
|
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
@files.each do |file|
|
|
393
|
+
current = file
|
|
395
394
|
|
|
396
|
-
|
|
397
|
-
generate_page file
|
|
398
|
-
next
|
|
399
|
-
end
|
|
395
|
+
next if file.text? && file.full_name == @options.main_page
|
|
400
396
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
search_index_rel_prefix = rel_prefix
|
|
406
|
-
search_index_rel_prefix += @asset_rel_path if @file_output
|
|
397
|
+
if file.text? and page_file.exist?
|
|
398
|
+
generate_page file
|
|
399
|
+
next
|
|
400
|
+
end
|
|
407
401
|
|
|
408
|
-
|
|
402
|
+
template_file = nil
|
|
403
|
+
out_file = @outputdir + file.path
|
|
404
|
+
debug_msg " working on %s (%s)" % [file.full_name, out_file]
|
|
405
|
+
rel_prefix = @outputdir.relative_path_from out_file.dirname
|
|
406
|
+
search_index_rel_prefix = rel_prefix
|
|
407
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
|
408
|
+
|
|
409
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
|
410
|
+
|
|
411
|
+
unless filepage_file
|
|
412
|
+
if file.text?
|
|
413
|
+
next unless page_file.exist?
|
|
414
|
+
template_file = page_file
|
|
415
|
+
@title = file.page_name
|
|
416
|
+
else
|
|
417
|
+
next unless fileinfo_file.exist?
|
|
418
|
+
template_file = fileinfo_file
|
|
419
|
+
@title = "File: #{file.base_name}"
|
|
420
|
+
end
|
|
421
|
+
end
|
|
409
422
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
next unless page_file.exist?
|
|
413
|
-
template_file = page_file
|
|
414
|
-
@title = file.page_name
|
|
415
|
-
else
|
|
416
|
-
next unless fileinfo_file.exist?
|
|
417
|
-
template_file = fileinfo_file
|
|
418
|
-
@title = "File: #{file.base_name}"
|
|
419
|
-
end
|
|
420
|
-
end
|
|
423
|
+
@title += " - #{@options.title}"
|
|
424
|
+
template_file ||= filepage_file
|
|
421
425
|
|
|
422
|
-
|
|
423
|
-
|
|
426
|
+
render_template template_file, out_file do |io|
|
|
427
|
+
here = binding
|
|
428
|
+
# suppress 1.9.3 warning
|
|
429
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
|
430
|
+
here.local_variable_set(:current, current)
|
|
431
|
+
here
|
|
432
|
+
end
|
|
433
|
+
end
|
|
434
|
+
rescue => e
|
|
435
|
+
error =
|
|
436
|
+
Error.new "error generating #{out_file}: #{e.message} (#{e.class})"
|
|
437
|
+
error.set_backtrace e.backtrace
|
|
424
438
|
|
|
425
|
-
|
|
426
|
-
here = binding
|
|
427
|
-
# suppress 1.9.3 warning
|
|
428
|
-
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
|
429
|
-
here.local_variable_set(:current, current)
|
|
430
|
-
here
|
|
439
|
+
raise error
|
|
431
440
|
end
|
|
432
|
-
end
|
|
433
|
-
rescue => e
|
|
434
|
-
error =
|
|
435
|
-
RDoc::Error.new "error generating #{out_file}: #{e.message} (#{e.class})"
|
|
436
|
-
error.set_backtrace e.backtrace
|
|
437
|
-
|
|
438
|
-
raise error
|
|
439
|
-
end
|
|
440
441
|
|
|
441
|
-
|
|
442
|
-
|
|
442
|
+
##
|
|
443
|
+
# Generate a page file for +file+
|
|
443
444
|
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
def generate_page(file)
|
|
446
|
+
template_file = @template_dir + 'page.rhtml'
|
|
446
447
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
448
|
+
out_file = @outputdir + file.path
|
|
449
|
+
debug_msg " working on %s (%s)" % [file.full_name, out_file]
|
|
450
|
+
rel_prefix = @outputdir.relative_path_from out_file.dirname
|
|
451
|
+
search_index_rel_prefix = rel_prefix
|
|
452
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
|
452
453
|
|
|
453
|
-
|
|
454
|
-
|
|
454
|
+
current = file
|
|
455
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
|
455
456
|
|
|
456
|
-
|
|
457
|
+
@title = "#{file.page_name} - #{@options.title}"
|
|
457
458
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
459
|
+
debug_msg " rendering #{out_file}"
|
|
460
|
+
render_template template_file, out_file do |io|
|
|
461
|
+
here = binding
|
|
462
|
+
# suppress 1.9.3 warning
|
|
463
|
+
here.local_variable_set(:current, current)
|
|
464
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
|
465
|
+
here
|
|
466
|
+
end
|
|
467
|
+
end
|
|
467
468
|
|
|
468
|
-
|
|
469
|
-
|
|
469
|
+
##
|
|
470
|
+
# Generates the 404 page for the RDoc servlet
|
|
470
471
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
472
|
+
def generate_servlet_not_found(message)
|
|
473
|
+
template_file = @template_dir + 'servlet_not_found.rhtml'
|
|
474
|
+
return unless template_file.exist?
|
|
474
475
|
|
|
475
|
-
|
|
476
|
+
debug_msg "Rendering the servlet 404 Not Found page..."
|
|
476
477
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
478
|
+
rel_prefix = rel_prefix = ''
|
|
479
|
+
search_index_rel_prefix = rel_prefix
|
|
480
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
|
480
481
|
|
|
481
|
-
|
|
482
|
+
asset_rel_prefix = ''
|
|
482
483
|
|
|
483
|
-
|
|
484
|
+
@title = 'Not Found'
|
|
484
485
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
486
|
+
render_template template_file do |io|
|
|
487
|
+
here = binding
|
|
488
|
+
# suppress 1.9.3 warning
|
|
489
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
|
490
|
+
here
|
|
491
|
+
end
|
|
492
|
+
rescue => e
|
|
493
|
+
error = Error.new \
|
|
494
|
+
"error generating servlet_not_found: #{e.message} (#{e.class})"
|
|
495
|
+
error.set_backtrace e.backtrace
|
|
495
496
|
|
|
496
|
-
|
|
497
|
-
|
|
497
|
+
raise error
|
|
498
|
+
end
|
|
498
499
|
|
|
499
|
-
|
|
500
|
-
|
|
500
|
+
##
|
|
501
|
+
# Generates the servlet root page for the RDoc servlet
|
|
501
502
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
503
|
+
def generate_servlet_root(installed)
|
|
504
|
+
template_file = @template_dir + 'servlet_root.rhtml'
|
|
505
|
+
return unless template_file.exist?
|
|
505
506
|
|
|
506
|
-
|
|
507
|
+
debug_msg 'Rendering the servlet root page...'
|
|
507
508
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
509
|
+
rel_prefix = '.'
|
|
510
|
+
asset_rel_prefix = rel_prefix
|
|
511
|
+
search_index_rel_prefix = asset_rel_prefix
|
|
512
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
|
512
513
|
|
|
513
|
-
|
|
514
|
+
@title = 'Local RDoc Documentation'
|
|
514
515
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
516
|
+
render_template template_file do |io| binding end
|
|
517
|
+
rescue => e
|
|
518
|
+
error = Error.new \
|
|
519
|
+
"error generating servlet_root: #{e.message} (#{e.class})"
|
|
520
|
+
error.set_backtrace e.backtrace
|
|
520
521
|
|
|
521
|
-
|
|
522
|
-
|
|
522
|
+
raise error
|
|
523
|
+
end
|
|
523
524
|
|
|
524
|
-
|
|
525
|
-
|
|
525
|
+
##
|
|
526
|
+
# Generate an index page which lists all the classes which are documented.
|
|
526
527
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
528
|
+
def generate_table_of_contents
|
|
529
|
+
template_file = @template_dir + 'table_of_contents.rhtml'
|
|
530
|
+
return unless template_file.exist?
|
|
530
531
|
|
|
531
|
-
|
|
532
|
+
debug_msg "Rendering the Table of Contents..."
|
|
532
533
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
534
|
+
out_file = @outputdir + 'table_of_contents.html'
|
|
535
|
+
rel_prefix = @outputdir.relative_path_from out_file.dirname
|
|
536
|
+
search_index_rel_prefix = rel_prefix
|
|
537
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
|
537
538
|
|
|
538
|
-
|
|
539
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
|
539
540
|
|
|
540
|
-
|
|
541
|
+
@title = "Table of Contents - #{@options.title}"
|
|
541
542
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
543
|
+
render_template template_file, out_file do |io|
|
|
544
|
+
here = binding
|
|
545
|
+
# suppress 1.9.3 warning
|
|
546
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
|
547
|
+
here
|
|
548
|
+
end
|
|
549
|
+
rescue => e
|
|
550
|
+
error = Error.new \
|
|
551
|
+
"error generating table_of_contents.html: #{e.message} (#{e.class})"
|
|
552
|
+
error.set_backtrace e.backtrace
|
|
552
553
|
|
|
553
|
-
|
|
554
|
-
|
|
554
|
+
raise error
|
|
555
|
+
end
|
|
555
556
|
|
|
556
|
-
|
|
557
|
-
|
|
557
|
+
def install_rdoc_static_file(source, destination, options) # :nodoc:
|
|
558
|
+
return unless source.exist?
|
|
558
559
|
|
|
559
|
-
|
|
560
|
-
|
|
560
|
+
begin
|
|
561
|
+
FileUtils.mkdir_p File.dirname(destination), **options
|
|
561
562
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
563
|
+
begin
|
|
564
|
+
FileUtils.ln source, destination, **options
|
|
565
|
+
rescue Errno::EEXIST
|
|
566
|
+
FileUtils.rm destination
|
|
567
|
+
retry
|
|
568
|
+
end
|
|
569
|
+
rescue
|
|
570
|
+
FileUtils.cp source, destination, **options
|
|
571
|
+
end
|
|
567
572
|
end
|
|
568
|
-
rescue
|
|
569
|
-
FileUtils.cp source, destination, **options
|
|
570
|
-
end
|
|
571
|
-
end
|
|
572
573
|
|
|
573
|
-
|
|
574
|
-
|
|
574
|
+
##
|
|
575
|
+
# Prepares for generation of output from the current directory
|
|
575
576
|
|
|
576
|
-
|
|
577
|
-
|
|
577
|
+
def setup
|
|
578
|
+
return if instance_variable_defined? :@outputdir
|
|
578
579
|
|
|
579
|
-
|
|
580
|
+
@outputdir = Pathname.new(@options.op_dir).expand_path @base_dir
|
|
580
581
|
|
|
581
|
-
|
|
582
|
+
return unless @store
|
|
582
583
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
584
|
+
refresh_store_data
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
##
|
|
588
|
+
# Refreshes the generator's data from the store. Called by #setup and
|
|
589
|
+
# can be called again after the store has been updated (e.g. in server
|
|
590
|
+
# mode after re-parsing changed files).
|
|
591
|
+
|
|
592
|
+
def refresh_store_data
|
|
593
|
+
@classes = @store.all_classes_and_modules.sort
|
|
594
|
+
@files = @store.all_files.sort
|
|
595
|
+
@methods = @classes.flat_map { |m| m.method_list }.sort
|
|
596
|
+
@modsort = get_sorted_module_list @classes
|
|
597
|
+
end
|
|
588
598
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
599
|
+
##
|
|
600
|
+
# Creates a template from its components and the +body_file+.
|
|
601
|
+
#
|
|
602
|
+
# For backwards compatibility, if +body_file+ contains "<html" the body is
|
|
603
|
+
# used directly.
|
|
594
604
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
605
|
+
def assemble_template(body_file)
|
|
606
|
+
body = body_file.read(encoding: template_encoding)
|
|
607
|
+
return body if body =~ /<html/
|
|
598
608
|
|
|
599
|
-
|
|
609
|
+
head_file = @template_dir + '_head.rhtml'
|
|
600
610
|
|
|
601
|
-
|
|
611
|
+
<<-TEMPLATE
|
|
602
612
|
<!DOCTYPE html>
|
|
603
613
|
|
|
604
614
|
<html lang="#{@options.locale&.name || 'en'}">
|
|
605
615
|
<head>
|
|
606
|
-
#{head_file.read}
|
|
616
|
+
#{head_file.read(encoding: template_encoding)}
|
|
607
617
|
|
|
608
618
|
#{body}
|
|
609
619
|
TEMPLATE
|
|
610
|
-
|
|
620
|
+
end
|
|
611
621
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
622
|
+
##
|
|
623
|
+
# Renders the ERb contained in +file_name+ relative to the template
|
|
624
|
+
# directory and returns the result based on the current context.
|
|
615
625
|
|
|
616
|
-
|
|
617
|
-
|
|
626
|
+
def render(file_name)
|
|
627
|
+
template_file = @template_dir + file_name
|
|
618
628
|
|
|
619
|
-
|
|
629
|
+
template = template_for template_file, false, ERBPartial
|
|
620
630
|
|
|
621
|
-
|
|
631
|
+
template.filename = template_file.to_s
|
|
622
632
|
|
|
623
|
-
|
|
624
|
-
|
|
633
|
+
template.result @context
|
|
634
|
+
end
|
|
625
635
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
636
|
+
##
|
|
637
|
+
# Load and render the erb template in the given +template_file+ and write
|
|
638
|
+
# it out to +out_file+.
|
|
639
|
+
#
|
|
640
|
+
# Both +template_file+ and +out_file+ should be Pathname-like objects.
|
|
641
|
+
#
|
|
642
|
+
# An io will be yielded which must be captured by binding in the caller.
|
|
633
643
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
644
|
+
def render_template(template_file, out_file = nil) # :yield: io
|
|
645
|
+
io_output = out_file && !@dry_run && @file_output
|
|
646
|
+
erb_klass = io_output ? ERBIO : ERB
|
|
637
647
|
|
|
638
|
-
|
|
648
|
+
template = template_for template_file, true, erb_klass
|
|
639
649
|
|
|
640
|
-
|
|
641
|
-
|
|
650
|
+
if io_output
|
|
651
|
+
debug_msg "Outputting to %s" % [out_file.expand_path]
|
|
642
652
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
653
|
+
out_file.dirname.mkpath
|
|
654
|
+
out_file.open 'w', 0644 do |io|
|
|
655
|
+
io.set_encoding @options.encoding
|
|
646
656
|
|
|
647
|
-
|
|
657
|
+
@context = yield io
|
|
648
658
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
659
|
+
template_result template, @context, template_file
|
|
660
|
+
end
|
|
661
|
+
else
|
|
662
|
+
@context = yield nil
|
|
653
663
|
|
|
654
|
-
|
|
664
|
+
output = template_result template, @context, template_file
|
|
655
665
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
666
|
+
debug_msg " would have written %d characters to %s" % [
|
|
667
|
+
output.length, out_file.expand_path
|
|
668
|
+
] if @dry_run
|
|
659
669
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
670
|
+
output
|
|
671
|
+
end
|
|
672
|
+
end
|
|
663
673
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
674
|
+
##
|
|
675
|
+
# Creates the result for +template+ with +context+. If an error is raised a
|
|
676
|
+
# Pathname +template_file+ will indicate the file where the error occurred.
|
|
677
|
+
|
|
678
|
+
def template_result(template, context, template_file)
|
|
679
|
+
template.filename = template_file.to_s
|
|
680
|
+
template.result context
|
|
681
|
+
rescue NoMethodError => e
|
|
682
|
+
raise Error, "Error while evaluating %s: %s" % [
|
|
683
|
+
template_file.expand_path,
|
|
684
|
+
e.message,
|
|
685
|
+
], e.backtrace
|
|
686
|
+
end
|
|
677
687
|
|
|
678
|
-
|
|
679
|
-
|
|
688
|
+
##
|
|
689
|
+
# Retrieves a cache template for +file+, if present, or fills the cache.
|
|
680
690
|
|
|
681
|
-
|
|
682
|
-
|
|
691
|
+
def template_for(file, page = true, klass = ERB)
|
|
692
|
+
template = @template_cache[file]
|
|
683
693
|
|
|
684
|
-
|
|
694
|
+
return template if template
|
|
685
695
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
696
|
+
if page
|
|
697
|
+
template = assemble_template file
|
|
698
|
+
erbout = 'io'
|
|
699
|
+
else
|
|
700
|
+
template = file.read(encoding: template_encoding)
|
|
701
|
+
template = template.encode @options.encoding
|
|
692
702
|
|
|
693
|
-
|
|
703
|
+
file_var = File.basename(file).sub(/\..*/, '')
|
|
694
704
|
|
|
695
|
-
|
|
696
|
-
|
|
705
|
+
erbout = "_erbout_#{file_var}"
|
|
706
|
+
end
|
|
697
707
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
708
|
+
template = klass.new template, trim_mode: '-', eoutvar: erbout
|
|
709
|
+
@template_cache[file] = template
|
|
710
|
+
template
|
|
711
|
+
end
|
|
702
712
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
713
|
+
# :stopdoc:
|
|
714
|
+
ParagraphExcerptRegexpOther = %r[\b\w[^./:]++\.]
|
|
715
|
+
# use \p/\P{letter} instead of \w/\W in Unicode
|
|
716
|
+
ParagraphExcerptRegexpUnicode = %r[\b\p{letter}[^./:]++\.]
|
|
717
|
+
# :startdoc:
|
|
718
|
+
|
|
719
|
+
# Returns an excerpt of the comment for usage in meta description tags
|
|
720
|
+
def excerpt(comment)
|
|
721
|
+
text = case comment
|
|
722
|
+
when Comment
|
|
723
|
+
comment.text
|
|
724
|
+
else
|
|
725
|
+
comment
|
|
726
|
+
end
|
|
717
727
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
728
|
+
# Match from a capital letter to the first period, discarding any links, so
|
|
729
|
+
# that we don't end up matching badges in the README
|
|
730
|
+
pattern = ParagraphExcerptRegexpUnicode
|
|
731
|
+
begin
|
|
732
|
+
first_paragraph_match = text.match(pattern)
|
|
733
|
+
rescue ::Encoding::CompatibilityError
|
|
734
|
+
# The doc is non-ASCII text and encoded in other than Unicode base encodings.
|
|
735
|
+
raise if pattern == ParagraphExcerptRegexpOther
|
|
736
|
+
pattern = ParagraphExcerptRegexpOther
|
|
737
|
+
retry
|
|
738
|
+
end
|
|
739
|
+
return text[0...150].tr_s("\n", " ").squeeze(" ") unless first_paragraph_match
|
|
730
740
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
741
|
+
extracted_text = first_paragraph_match[0]
|
|
742
|
+
second_paragraph = text.match(pattern, first_paragraph_match.end(0))
|
|
743
|
+
extracted_text << " " << second_paragraph[0] if second_paragraph
|
|
734
744
|
|
|
735
|
-
|
|
736
|
-
|
|
745
|
+
extracted_text[0...150].tr_s("\n", " ").squeeze(" ")
|
|
746
|
+
end
|
|
737
747
|
|
|
738
|
-
|
|
739
|
-
|
|
748
|
+
def generate_ancestor_list(ancestors, klass)
|
|
749
|
+
return '' if ancestors.empty?
|
|
740
750
|
|
|
741
|
-
|
|
742
|
-
|
|
751
|
+
ancestor = ancestors.shift
|
|
752
|
+
content = +'<ul><li>'
|
|
743
753
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
754
|
+
if ancestor.is_a?(NormalClass)
|
|
755
|
+
content << "<a href=\"#{klass.aref_to ancestor.path}\">#{ancestor.full_name}</a>"
|
|
756
|
+
else
|
|
757
|
+
content << ancestor.to_s
|
|
758
|
+
end
|
|
749
759
|
|
|
750
|
-
|
|
751
|
-
|
|
760
|
+
# Recursively call the method for the remaining ancestors
|
|
761
|
+
content << generate_ancestor_list(ancestors, klass)
|
|
752
762
|
|
|
753
|
-
|
|
754
|
-
|
|
763
|
+
content << '</li></ul>'
|
|
764
|
+
end
|
|
755
765
|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
766
|
+
def generate_class_link(klass, rel_prefix)
|
|
767
|
+
if klass.display?
|
|
768
|
+
%(<code><a href="#{rel_prefix}/#{klass.path}">#{klass.name}</a></code>)
|
|
769
|
+
else
|
|
770
|
+
%(<code>#{klass.name}</code>)
|
|
771
|
+
end
|
|
772
|
+
end
|
|
763
773
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
774
|
+
def generate_class_index_content(classes, rel_prefix)
|
|
775
|
+
grouped_classes = group_classes_by_namespace_for_sidebar(classes)
|
|
776
|
+
return '' unless top = grouped_classes[nil]
|
|
767
777
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
778
|
+
solo = top.one? { |klass| klass.display? }
|
|
779
|
+
traverse_classes(top, grouped_classes, rel_prefix, solo)
|
|
780
|
+
end
|
|
771
781
|
|
|
772
|
-
|
|
773
|
-
|
|
782
|
+
def traverse_classes(klasses, grouped_classes, rel_prefix, solo = false)
|
|
783
|
+
content = +'<ul class="link-list nav-list">'
|
|
784
|
+
|
|
785
|
+
klasses.each do |index_klass|
|
|
786
|
+
if children = grouped_classes[index_klass.full_name]
|
|
787
|
+
content << %(<li><details#{solo ? ' open' : ''}><summary>#{generate_class_link(index_klass, rel_prefix)}</summary>)
|
|
788
|
+
content << traverse_classes(children, grouped_classes, rel_prefix)
|
|
789
|
+
content << '</details></li>'
|
|
790
|
+
solo = false
|
|
791
|
+
elsif index_klass.display?
|
|
792
|
+
content << %(<li>#{generate_class_link(index_klass, rel_prefix)}</li>)
|
|
793
|
+
end
|
|
794
|
+
end
|
|
774
795
|
|
|
775
|
-
|
|
776
|
-
if children = grouped_classes[index_klass.full_name]
|
|
777
|
-
content << %(<li><details#{solo ? ' open' : ''}><summary>#{generate_class_link(index_klass, rel_prefix)}</summary>)
|
|
778
|
-
content << traverse_classes(children, grouped_classes, rel_prefix)
|
|
779
|
-
content << '</details></li>'
|
|
780
|
-
solo = false
|
|
781
|
-
elsif index_klass.display?
|
|
782
|
-
content << %(<li>#{generate_class_link(index_klass, rel_prefix)}</li>)
|
|
796
|
+
"#{content}</ul>"
|
|
783
797
|
end
|
|
784
|
-
end
|
|
785
798
|
|
|
786
|
-
|
|
787
|
-
|
|
799
|
+
def group_classes_by_namespace_for_sidebar(classes)
|
|
800
|
+
grouped_classes = classes.group_by do |klass|
|
|
801
|
+
klass.full_name[/\A[^:]++(?:::[^:]++(?=::))*+(?=::[^:]*+\z)/]
|
|
802
|
+
end.select do |_, klasses|
|
|
803
|
+
klasses.any?(&:display?)
|
|
804
|
+
end
|
|
788
805
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
end.select do |_, klasses|
|
|
793
|
-
klasses.any?(&:display?)
|
|
794
|
-
end
|
|
806
|
+
grouped_classes.values.each(&:uniq!)
|
|
807
|
+
grouped_classes
|
|
808
|
+
end
|
|
795
809
|
|
|
796
|
-
|
|
797
|
-
grouped_classes
|
|
798
|
-
end
|
|
810
|
+
private
|
|
799
811
|
|
|
800
|
-
|
|
812
|
+
def template_encoding
|
|
813
|
+
nil
|
|
814
|
+
end
|
|
801
815
|
|
|
802
|
-
|
|
803
|
-
|
|
816
|
+
def nesting_namespaces_to_class_modules(klass)
|
|
817
|
+
tree = {}
|
|
804
818
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
819
|
+
klass.nesting_namespaces.zip(klass.fully_qualified_nesting_namespaces) do |ns, fqns|
|
|
820
|
+
tree[ns] = @store.classes_hash[fqns] || @store.modules_hash[fqns]
|
|
821
|
+
end
|
|
808
822
|
|
|
809
|
-
|
|
810
|
-
|
|
823
|
+
tree
|
|
824
|
+
end
|
|
811
825
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
826
|
+
def generate_nesting_namespaces_breadcrumb(klass, rel_prefix)
|
|
827
|
+
nesting_namespaces_to_class_modules(klass).map do |namespace, class_module|
|
|
828
|
+
path = class_module ? (rel_prefix + class_module.path).to_s : ""
|
|
829
|
+
{ name: namespace, path: path, self: klass.full_name == class_module&.full_name }
|
|
830
|
+
end
|
|
831
|
+
end
|
|
816
832
|
end
|
|
817
833
|
end
|
|
818
834
|
end
|