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,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# -*- mode: ruby; ruby-indent-level: 2; tab-width: 2 -*-
|
2
3
|
|
3
|
-
require '
|
4
|
+
require 'erb'
|
4
5
|
require 'fileutils'
|
5
|
-
require '
|
6
|
-
|
7
|
-
require 'rdoc/generator/markup'
|
6
|
+
require 'pathname'
|
7
|
+
require_relative 'markup'
|
8
8
|
|
9
9
|
##
|
10
10
|
# Darkfish RDoc HTML Generator
|
@@ -47,12 +47,33 @@ require 'rdoc/generator/markup'
|
|
47
47
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
48
48
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
49
49
|
#
|
50
|
+
# == Attributions
|
51
|
+
#
|
52
|
+
# Darkfish uses the {Silk Icons}[http://www.famfamfam.com/lab/icons/silk/] set
|
53
|
+
# by Mark James.
|
54
|
+
|
50
55
|
class RDoc::Generator::Darkfish
|
51
56
|
|
52
57
|
RDoc::RDoc.add_generator self
|
53
58
|
|
54
59
|
include ERB::Util
|
55
60
|
|
61
|
+
##
|
62
|
+
# Stylesheets, fonts, etc. that are included in RDoc.
|
63
|
+
|
64
|
+
BUILTIN_STYLE_ITEMS = # :nodoc:
|
65
|
+
%w[
|
66
|
+
css/fonts.css
|
67
|
+
fonts/Lato-Light.ttf
|
68
|
+
fonts/Lato-LightItalic.ttf
|
69
|
+
fonts/Lato-Regular.ttf
|
70
|
+
fonts/Lato-RegularItalic.ttf
|
71
|
+
fonts/SourceCodePro-Bold.ttf
|
72
|
+
fonts/SourceCodePro-Regular.ttf
|
73
|
+
css/rdoc.css
|
74
|
+
]
|
75
|
+
|
76
|
+
##
|
56
77
|
# Path to this file's parent directory. Used to find templates and other
|
57
78
|
# resources.
|
58
79
|
|
@@ -61,7 +82,7 @@ class RDoc::Generator::Darkfish
|
|
61
82
|
##
|
62
83
|
# Release Version
|
63
84
|
|
64
|
-
VERSION = '
|
85
|
+
VERSION = '3'
|
65
86
|
|
66
87
|
##
|
67
88
|
# Description of this generator
|
@@ -69,25 +90,92 @@ class RDoc::Generator::Darkfish
|
|
69
90
|
DESCRIPTION = 'HTML generator, written by Michael Granger'
|
70
91
|
|
71
92
|
##
|
72
|
-
#
|
93
|
+
# The relative path to style sheets and javascript. By default this is set
|
94
|
+
# the same as the rel_prefix.
|
73
95
|
|
74
|
-
|
75
|
-
@options = options
|
96
|
+
attr_accessor :asset_rel_path
|
76
97
|
|
77
|
-
|
78
|
-
|
98
|
+
##
|
99
|
+
# The path to generate files into, combined with <tt>--op</tt> from the
|
100
|
+
# options for a full path.
|
79
101
|
|
80
|
-
|
81
|
-
@classes = nil
|
102
|
+
attr_reader :base_dir
|
82
103
|
|
83
|
-
|
84
|
-
|
104
|
+
##
|
105
|
+
# Classes and modules to be used by this generator, not necessarily
|
106
|
+
# displayed. See also #modsort
|
107
|
+
|
108
|
+
attr_reader :classes
|
109
|
+
|
110
|
+
##
|
111
|
+
# No files will be written when dry_run is true.
|
112
|
+
|
113
|
+
attr_accessor :dry_run
|
114
|
+
|
115
|
+
##
|
116
|
+
# When false the generate methods return a String instead of writing to a
|
117
|
+
# file. The default is true.
|
118
|
+
|
119
|
+
attr_accessor :file_output
|
120
|
+
|
121
|
+
##
|
122
|
+
# Files to be displayed by this generator
|
123
|
+
|
124
|
+
attr_reader :files
|
125
|
+
|
126
|
+
##
|
127
|
+
# The JSON index generator for this Darkfish generator
|
128
|
+
|
129
|
+
attr_reader :json_index
|
130
|
+
|
131
|
+
##
|
132
|
+
# Methods to be displayed by this generator
|
133
|
+
|
134
|
+
attr_reader :methods
|
135
|
+
|
136
|
+
##
|
137
|
+
# Sorted list of classes and modules to be displayed by this generator
|
138
|
+
|
139
|
+
attr_reader :modsort
|
140
|
+
|
141
|
+
##
|
142
|
+
# The RDoc::Store that is the source of the generated content
|
143
|
+
|
144
|
+
attr_reader :store
|
145
|
+
|
146
|
+
##
|
147
|
+
# The directory where the template files live
|
148
|
+
|
149
|
+
attr_reader :template_dir # :nodoc:
|
85
150
|
|
86
151
|
##
|
87
152
|
# The output directory
|
88
153
|
|
89
154
|
attr_reader :outputdir
|
90
155
|
|
156
|
+
##
|
157
|
+
# Initialize a few instance variables before we start
|
158
|
+
|
159
|
+
def initialize store, options
|
160
|
+
@store = store
|
161
|
+
@options = options
|
162
|
+
|
163
|
+
@asset_rel_path = ''
|
164
|
+
@base_dir = Pathname.pwd.expand_path
|
165
|
+
@dry_run = @options.dry_run
|
166
|
+
@file_output = true
|
167
|
+
@template_dir = Pathname.new options.template_dir
|
168
|
+
@template_cache = {}
|
169
|
+
|
170
|
+
@classes = nil
|
171
|
+
@context = nil
|
172
|
+
@files = nil
|
173
|
+
@methods = nil
|
174
|
+
@modsort = nil
|
175
|
+
|
176
|
+
@json_index = RDoc::Generator::JsonIndex.new self, options
|
177
|
+
end
|
178
|
+
|
91
179
|
##
|
92
180
|
# Output progress information if debugging is enabled
|
93
181
|
|
@@ -126,21 +214,23 @@ class RDoc::Generator::Darkfish
|
|
126
214
|
|
127
215
|
def write_style_sheet
|
128
216
|
debug_msg "Copying static files"
|
129
|
-
options = { :verbose => $DEBUG_RDOC, :noop => @
|
217
|
+
options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }
|
130
218
|
|
131
|
-
|
219
|
+
BUILTIN_STYLE_ITEMS.each do |item|
|
220
|
+
install_rdoc_static_file @template_dir + item, "./#{item}", options
|
221
|
+
end
|
222
|
+
|
223
|
+
@options.template_stylesheets.each do |stylesheet|
|
224
|
+
FileUtils.cp stylesheet, '.', options
|
225
|
+
end
|
132
226
|
|
133
227
|
Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
|
134
228
|
next if File.directory? path
|
135
229
|
next if File.basename(path) =~ /^\./
|
136
230
|
|
137
|
-
|
138
|
-
|
139
|
-
# I suck at glob
|
140
|
-
dst_dir = dst.dirname
|
141
|
-
FileUtils.mkdir_p dst_dir, options unless File.exist? dst_dir
|
231
|
+
dst = Pathname.new(path).relative_path_from @template_dir
|
142
232
|
|
143
|
-
|
233
|
+
install_rdoc_static_file @template_dir + path, dst, options
|
144
234
|
end
|
145
235
|
end
|
146
236
|
|
@@ -148,107 +238,382 @@ class RDoc::Generator::Darkfish
|
|
148
238
|
# Build the initial indices and output objects based on an array of TopLevel
|
149
239
|
# objects containing the extracted information.
|
150
240
|
|
151
|
-
def generate
|
152
|
-
|
241
|
+
def generate
|
242
|
+
setup
|
153
243
|
|
154
|
-
@files = top_levels.sort
|
155
|
-
@classes = RDoc::TopLevel.all_classes_and_modules.sort
|
156
|
-
@methods = @classes.map { |m| m.method_list }.flatten.sort
|
157
|
-
@modsort = get_sorted_module_list(@classes)
|
158
|
-
|
159
|
-
# Now actually write the output
|
160
244
|
write_style_sheet
|
161
245
|
generate_index
|
162
246
|
generate_class_files
|
163
247
|
generate_file_files
|
248
|
+
generate_table_of_contents
|
249
|
+
@json_index.generate
|
250
|
+
@json_index.generate_gzipped
|
251
|
+
|
252
|
+
copy_static
|
164
253
|
|
165
|
-
rescue
|
254
|
+
rescue => e
|
166
255
|
debug_msg "%s: %s\n %s" % [
|
167
|
-
|
256
|
+
e.class.name, e.message, e.backtrace.join("\n ")
|
168
257
|
]
|
169
258
|
|
170
259
|
raise
|
171
260
|
end
|
172
261
|
|
173
|
-
protected
|
174
|
-
|
175
262
|
##
|
176
|
-
#
|
177
|
-
# by name.
|
263
|
+
# Copies static files from the static_path into the output directory
|
178
264
|
|
179
|
-
def
|
180
|
-
|
181
|
-
top_level = klass.full_name.gsub(/::.*/, '')
|
182
|
-
counthash[top_level] ||= 0
|
183
|
-
counthash[top_level] += 1
|
265
|
+
def copy_static
|
266
|
+
return if @options.static_path.empty?
|
184
267
|
|
185
|
-
|
186
|
-
|
268
|
+
fu_options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }
|
269
|
+
|
270
|
+
@options.static_path.each do |path|
|
271
|
+
unless File.directory? path then
|
272
|
+
FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644)
|
273
|
+
next
|
274
|
+
end
|
187
275
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
276
|
+
Dir.chdir path do
|
277
|
+
Dir[File.join('**', '*')].each do |entry|
|
278
|
+
dest_file = @outputdir + entry
|
279
|
+
|
280
|
+
if File.directory? entry then
|
281
|
+
FileUtils.mkdir_p entry, **fu_options
|
282
|
+
else
|
283
|
+
FileUtils.install entry, dest_file, **fu_options.merge(:mode => 0644)
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
196
287
|
end
|
197
288
|
end
|
198
289
|
|
290
|
+
##
|
291
|
+
# Return a list of the documented modules sorted by salience first, then
|
292
|
+
# by name.
|
293
|
+
|
294
|
+
def get_sorted_module_list classes
|
295
|
+
classes.select do |klass|
|
296
|
+
klass.display?
|
297
|
+
end.sort
|
298
|
+
end
|
299
|
+
|
199
300
|
##
|
200
301
|
# Generate an index page which lists all the classes which are documented.
|
201
302
|
|
202
303
|
def generate_index
|
304
|
+
setup
|
305
|
+
|
203
306
|
template_file = @template_dir + 'index.rhtml'
|
204
307
|
return unless template_file.exist?
|
205
308
|
|
206
309
|
debug_msg "Rendering the index page..."
|
207
310
|
|
208
|
-
out_file = @
|
311
|
+
out_file = @base_dir + @options.op_dir + 'index.html'
|
312
|
+
rel_prefix = @outputdir.relative_path_from out_file.dirname
|
313
|
+
search_index_rel_prefix = rel_prefix
|
314
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
209
315
|
|
210
|
-
|
316
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
317
|
+
|
318
|
+
@title = @options.title
|
319
|
+
|
320
|
+
render_template template_file, out_file do |io|
|
321
|
+
here = binding
|
322
|
+
# suppress 1.9.3 warning
|
323
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
324
|
+
here
|
325
|
+
end
|
326
|
+
rescue => e
|
327
|
+
error = RDoc::Error.new \
|
328
|
+
"error generating index.html: #{e.message} (#{e.class})"
|
329
|
+
error.set_backtrace e.backtrace
|
330
|
+
|
331
|
+
raise error
|
332
|
+
end
|
333
|
+
|
334
|
+
##
|
335
|
+
# Generates a class file for +klass+
|
336
|
+
|
337
|
+
def generate_class klass, template_file = nil
|
338
|
+
setup
|
339
|
+
|
340
|
+
current = klass
|
341
|
+
|
342
|
+
template_file ||= @template_dir + 'class.rhtml'
|
343
|
+
|
344
|
+
debug_msg " working on %s (%s)" % [klass.full_name, klass.path]
|
345
|
+
out_file = @outputdir + klass.path
|
346
|
+
rel_prefix = @outputdir.relative_path_from out_file.dirname
|
347
|
+
search_index_rel_prefix = rel_prefix
|
348
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
349
|
+
|
350
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
351
|
+
svninfo = get_svninfo(current)
|
352
|
+
|
353
|
+
@title = "#{klass.type} #{klass.full_name} - #{@options.title}"
|
354
|
+
|
355
|
+
debug_msg " rendering #{out_file}"
|
356
|
+
render_template template_file, out_file do |io|
|
357
|
+
here = binding
|
358
|
+
# suppress 1.9.3 warning
|
359
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
360
|
+
here.local_variable_set(:svninfo, svninfo)
|
361
|
+
here
|
362
|
+
end
|
211
363
|
end
|
212
364
|
|
213
365
|
##
|
214
|
-
# Generate a documentation file for each class
|
366
|
+
# Generate a documentation file for each class and module
|
215
367
|
|
216
368
|
def generate_class_files
|
217
|
-
|
369
|
+
setup
|
370
|
+
|
371
|
+
template_file = @template_dir + 'class.rhtml'
|
372
|
+
template_file = @template_dir + 'classpage.rhtml' unless
|
373
|
+
template_file.exist?
|
218
374
|
return unless template_file.exist?
|
219
|
-
debug_msg "Generating class documentation in
|
375
|
+
debug_msg "Generating class documentation in #{@outputdir}"
|
376
|
+
|
377
|
+
current = nil
|
220
378
|
|
221
379
|
@classes.each do |klass|
|
222
|
-
|
223
|
-
out_file = @outputdir + klass.path
|
224
|
-
# suppress 1.9.3 warning
|
225
|
-
rel_prefix = rel_prefix = @outputdir.relative_path_from(out_file.dirname)
|
226
|
-
svninfo = svninfo = self.get_svninfo(klass)
|
380
|
+
current = klass
|
227
381
|
|
228
|
-
|
229
|
-
render_template template_file, out_file do |io| binding end
|
382
|
+
generate_class klass, template_file
|
230
383
|
end
|
384
|
+
rescue => e
|
385
|
+
error = RDoc::Error.new \
|
386
|
+
"error generating #{current.path}: #{e.message} (#{e.class})"
|
387
|
+
error.set_backtrace e.backtrace
|
388
|
+
|
389
|
+
raise error
|
231
390
|
end
|
232
391
|
|
233
392
|
##
|
234
393
|
# Generate a documentation file for each file
|
235
394
|
|
236
395
|
def generate_file_files
|
237
|
-
|
238
|
-
|
239
|
-
|
396
|
+
setup
|
397
|
+
|
398
|
+
page_file = @template_dir + 'page.rhtml'
|
399
|
+
fileinfo_file = @template_dir + 'fileinfo.rhtml'
|
400
|
+
|
401
|
+
# for legacy templates
|
402
|
+
filepage_file = @template_dir + 'filepage.rhtml' unless
|
403
|
+
page_file.exist? or fileinfo_file.exist?
|
404
|
+
|
405
|
+
return unless
|
406
|
+
page_file.exist? or fileinfo_file.exist? or filepage_file.exist?
|
407
|
+
|
408
|
+
debug_msg "Generating file documentation in #{@outputdir}"
|
409
|
+
|
410
|
+
out_file = nil
|
411
|
+
current = nil
|
240
412
|
|
241
413
|
@files.each do |file|
|
242
|
-
|
243
|
-
|
414
|
+
current = file
|
415
|
+
|
416
|
+
if file.text? and page_file.exist? then
|
417
|
+
generate_page file
|
418
|
+
next
|
419
|
+
end
|
420
|
+
|
421
|
+
template_file = nil
|
422
|
+
out_file = @outputdir + file.path
|
423
|
+
debug_msg " working on %s (%s)" % [file.full_name, out_file]
|
424
|
+
rel_prefix = @outputdir.relative_path_from out_file.dirname
|
425
|
+
search_index_rel_prefix = rel_prefix
|
426
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
427
|
+
|
428
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
429
|
+
|
430
|
+
unless filepage_file then
|
431
|
+
if file.text? then
|
432
|
+
next unless page_file.exist?
|
433
|
+
template_file = page_file
|
434
|
+
@title = file.page_name
|
435
|
+
else
|
436
|
+
next unless fileinfo_file.exist?
|
437
|
+
template_file = fileinfo_file
|
438
|
+
@title = "File: #{file.base_name}"
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
@title += " - #{@options.title}"
|
443
|
+
template_file ||= filepage_file
|
444
|
+
|
445
|
+
render_template template_file, out_file do |io|
|
446
|
+
here = binding
|
447
|
+
# suppress 1.9.3 warning
|
448
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
449
|
+
here.local_variable_set(:current, current)
|
450
|
+
here
|
451
|
+
end
|
452
|
+
end
|
453
|
+
rescue => e
|
454
|
+
error =
|
455
|
+
RDoc::Error.new "error generating #{out_file}: #{e.message} (#{e.class})"
|
456
|
+
error.set_backtrace e.backtrace
|
457
|
+
|
458
|
+
raise error
|
459
|
+
end
|
460
|
+
|
461
|
+
##
|
462
|
+
# Generate a page file for +file+
|
463
|
+
|
464
|
+
def generate_page file
|
465
|
+
setup
|
466
|
+
|
467
|
+
template_file = @template_dir + 'page.rhtml'
|
468
|
+
|
469
|
+
out_file = @outputdir + file.path
|
470
|
+
debug_msg " working on %s (%s)" % [file.full_name, out_file]
|
471
|
+
rel_prefix = @outputdir.relative_path_from out_file.dirname
|
472
|
+
search_index_rel_prefix = rel_prefix
|
473
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
474
|
+
|
475
|
+
current = file
|
476
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
477
|
+
|
478
|
+
@title = "#{file.page_name} - #{@options.title}"
|
479
|
+
|
480
|
+
debug_msg " rendering #{out_file}"
|
481
|
+
render_template template_file, out_file do |io|
|
482
|
+
here = binding
|
483
|
+
# suppress 1.9.3 warning
|
484
|
+
here.local_variable_set(:current, current)
|
485
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
486
|
+
here
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
##
|
491
|
+
# Generates the 404 page for the RDoc servlet
|
492
|
+
|
493
|
+
def generate_servlet_not_found message
|
494
|
+
setup
|
495
|
+
|
496
|
+
template_file = @template_dir + 'servlet_not_found.rhtml'
|
497
|
+
return unless template_file.exist?
|
498
|
+
|
499
|
+
debug_msg "Rendering the servlet 404 Not Found page..."
|
500
|
+
|
501
|
+
rel_prefix = rel_prefix = ''
|
502
|
+
search_index_rel_prefix = rel_prefix
|
503
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
504
|
+
|
505
|
+
asset_rel_prefix = ''
|
506
|
+
|
507
|
+
@title = 'Not Found'
|
508
|
+
|
509
|
+
render_template template_file do |io|
|
510
|
+
here = binding
|
511
|
+
# suppress 1.9.3 warning
|
512
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
513
|
+
here
|
514
|
+
end
|
515
|
+
rescue => e
|
516
|
+
error = RDoc::Error.new \
|
517
|
+
"error generating servlet_not_found: #{e.message} (#{e.class})"
|
518
|
+
error.set_backtrace e.backtrace
|
519
|
+
|
520
|
+
raise error
|
521
|
+
end
|
522
|
+
|
523
|
+
##
|
524
|
+
# Generates the servlet root page for the RDoc servlet
|
525
|
+
|
526
|
+
def generate_servlet_root installed
|
527
|
+
setup
|
528
|
+
|
529
|
+
template_file = @template_dir + 'servlet_root.rhtml'
|
530
|
+
return unless template_file.exist?
|
531
|
+
|
532
|
+
debug_msg 'Rendering the servlet root page...'
|
533
|
+
|
534
|
+
rel_prefix = '.'
|
535
|
+
asset_rel_prefix = rel_prefix
|
536
|
+
search_index_rel_prefix = asset_rel_prefix
|
537
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
538
|
+
|
539
|
+
@title = 'Local RDoc Documentation'
|
540
|
+
|
541
|
+
render_template template_file do |io| binding end
|
542
|
+
rescue => e
|
543
|
+
error = RDoc::Error.new \
|
544
|
+
"error generating servlet_root: #{e.message} (#{e.class})"
|
545
|
+
error.set_backtrace e.backtrace
|
546
|
+
|
547
|
+
raise error
|
548
|
+
end
|
549
|
+
|
550
|
+
##
|
551
|
+
# Generate an index page which lists all the classes which are documented.
|
552
|
+
|
553
|
+
def generate_table_of_contents
|
554
|
+
setup
|
555
|
+
|
556
|
+
template_file = @template_dir + 'table_of_contents.rhtml'
|
557
|
+
return unless template_file.exist?
|
558
|
+
|
559
|
+
debug_msg "Rendering the Table of Contents..."
|
560
|
+
|
561
|
+
out_file = @outputdir + 'table_of_contents.html'
|
562
|
+
rel_prefix = @outputdir.relative_path_from out_file.dirname
|
563
|
+
search_index_rel_prefix = rel_prefix
|
564
|
+
search_index_rel_prefix += @asset_rel_path if @file_output
|
565
|
+
|
566
|
+
asset_rel_prefix = rel_prefix + @asset_rel_path
|
567
|
+
|
568
|
+
@title = "Table of Contents - #{@options.title}"
|
569
|
+
|
570
|
+
render_template template_file, out_file do |io|
|
571
|
+
here = binding
|
244
572
|
# suppress 1.9.3 warning
|
245
|
-
|
573
|
+
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
|
574
|
+
here
|
575
|
+
end
|
576
|
+
rescue => e
|
577
|
+
error = RDoc::Error.new \
|
578
|
+
"error generating table_of_contents.html: #{e.message} (#{e.class})"
|
579
|
+
error.set_backtrace e.backtrace
|
580
|
+
|
581
|
+
raise error
|
582
|
+
end
|
583
|
+
|
584
|
+
def install_rdoc_static_file source, destination, options # :nodoc:
|
585
|
+
return unless source.exist?
|
586
|
+
|
587
|
+
begin
|
588
|
+
FileUtils.mkdir_p File.dirname(destination), **options
|
246
589
|
|
247
|
-
|
248
|
-
|
590
|
+
begin
|
591
|
+
FileUtils.ln source, destination, **options
|
592
|
+
rescue Errno::EEXIST
|
593
|
+
FileUtils.rm destination
|
594
|
+
retry
|
595
|
+
end
|
596
|
+
rescue
|
597
|
+
FileUtils.cp source, destination, **options
|
249
598
|
end
|
250
599
|
end
|
251
600
|
|
601
|
+
##
|
602
|
+
# Prepares for generation of output from the current directory
|
603
|
+
|
604
|
+
def setup
|
605
|
+
return if instance_variable_defined? :@outputdir
|
606
|
+
|
607
|
+
@outputdir = Pathname.new(@options.op_dir).expand_path @base_dir
|
608
|
+
|
609
|
+
return unless @store
|
610
|
+
|
611
|
+
@classes = @store.all_classes_and_modules.sort
|
612
|
+
@files = @store.all_files.sort
|
613
|
+
@methods = @classes.map { |m| m.method_list }.flatten.sort
|
614
|
+
@modsort = get_sorted_module_list @classes
|
615
|
+
end
|
616
|
+
|
252
617
|
##
|
253
618
|
# Return a string describing the amount of time in the given number of
|
254
619
|
# seconds in terms a human can understand easily.
|
@@ -301,6 +666,46 @@ class RDoc::Generator::Darkfish
|
|
301
666
|
}
|
302
667
|
end
|
303
668
|
|
669
|
+
##
|
670
|
+
# Creates a template from its components and the +body_file+.
|
671
|
+
#
|
672
|
+
# For backwards compatibility, if +body_file+ contains "<html" the body is
|
673
|
+
# used directly.
|
674
|
+
|
675
|
+
def assemble_template body_file
|
676
|
+
body = body_file.read
|
677
|
+
return body if body =~ /<html/
|
678
|
+
|
679
|
+
head_file = @template_dir + '_head.rhtml'
|
680
|
+
footer_file = @template_dir + '_footer.rhtml'
|
681
|
+
|
682
|
+
<<-TEMPLATE
|
683
|
+
<!DOCTYPE html>
|
684
|
+
|
685
|
+
<html>
|
686
|
+
<head>
|
687
|
+
#{head_file.read}
|
688
|
+
|
689
|
+
#{body}
|
690
|
+
|
691
|
+
#{footer_file.read}
|
692
|
+
TEMPLATE
|
693
|
+
end
|
694
|
+
|
695
|
+
##
|
696
|
+
# Renders the ERb contained in +file_name+ relative to the template
|
697
|
+
# directory and returns the result based on the current context.
|
698
|
+
|
699
|
+
def render file_name
|
700
|
+
template_file = @template_dir + file_name
|
701
|
+
|
702
|
+
template = template_for template_file, false, RDoc::ERBPartial
|
703
|
+
|
704
|
+
template.filename = template_file.to_s
|
705
|
+
|
706
|
+
template.result @context
|
707
|
+
end
|
708
|
+
|
304
709
|
##
|
305
710
|
# Load and render the erb template in the given +template_file+ and write
|
306
711
|
# it out to +out_file+.
|
@@ -309,28 +714,33 @@ class RDoc::Generator::Darkfish
|
|
309
714
|
#
|
310
715
|
# An io will be yielded which must be captured by binding in the caller.
|
311
716
|
|
312
|
-
def render_template template_file, out_file # :yield: io
|
313
|
-
|
717
|
+
def render_template template_file, out_file = nil # :yield: io
|
718
|
+
io_output = out_file && !@dry_run && @file_output
|
719
|
+
erb_klass = io_output ? RDoc::ERBIO : ERB
|
314
720
|
|
315
|
-
|
721
|
+
template = template_for template_file, true, erb_klass
|
722
|
+
|
723
|
+
if io_output then
|
316
724
|
debug_msg "Outputting to %s" % [out_file.expand_path]
|
317
725
|
|
318
726
|
out_file.dirname.mkpath
|
319
727
|
out_file.open 'w', 0644 do |io|
|
320
|
-
io.set_encoding @options.encoding
|
728
|
+
io.set_encoding @options.encoding
|
321
729
|
|
322
|
-
context = yield io
|
730
|
+
@context = yield io
|
323
731
|
|
324
|
-
template_result template, context, template_file
|
732
|
+
template_result template, @context, template_file
|
325
733
|
end
|
326
734
|
else
|
327
|
-
context = yield nil
|
735
|
+
@context = yield nil
|
328
736
|
|
329
|
-
output = template_result template, context, template_file
|
737
|
+
output = template_result template, @context, template_file
|
330
738
|
|
331
739
|
debug_msg " would have written %d characters to %s" % [
|
332
740
|
output.length, out_file.expand_path
|
333
|
-
]
|
741
|
+
] if @dry_run
|
742
|
+
|
743
|
+
output
|
334
744
|
end
|
335
745
|
end
|
336
746
|
|
@@ -351,17 +761,30 @@ class RDoc::Generator::Darkfish
|
|
351
761
|
##
|
352
762
|
# Retrieves a cache template for +file+, if present, or fills the cache.
|
353
763
|
|
354
|
-
def template_for file
|
764
|
+
def template_for file, page = true, klass = ERB
|
355
765
|
template = @template_cache[file]
|
356
766
|
|
357
767
|
return template if template
|
358
768
|
|
359
|
-
|
769
|
+
if page then
|
770
|
+
template = assemble_template file
|
771
|
+
erbout = 'io'
|
772
|
+
else
|
773
|
+
template = file.read
|
774
|
+
template = template.encode @options.encoding
|
775
|
+
|
776
|
+
file_var = File.basename(file).sub(/\..*/, '')
|
777
|
+
|
778
|
+
erbout = "_erbout_#{file_var}"
|
779
|
+
end
|
360
780
|
|
361
|
-
|
781
|
+
if RUBY_VERSION >= '2.6'
|
782
|
+
template = klass.new template, trim_mode: '-', eoutvar: erbout
|
783
|
+
else
|
784
|
+
template = klass.new template, nil, '-', erbout
|
785
|
+
end
|
362
786
|
@template_cache[file] = template
|
363
787
|
template
|
364
788
|
end
|
365
789
|
|
366
790
|
end
|
367
|
-
|