super-quick-rb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/rdoc-8.0.0/CONTRIBUTING.md +195 -0
- data/rdoc-8.0.0/CVE-2013-0256.rdoc +49 -0
- data/rdoc-8.0.0/History.rdoc +1668 -0
- data/rdoc-8.0.0/LEGAL.rdoc +56 -0
- data/rdoc-8.0.0/LICENSE.rdoc +63 -0
- data/rdoc-8.0.0/README.md +236 -0
- data/rdoc-8.0.0/RI.md +842 -0
- data/rdoc-8.0.0/TODO.rdoc +60 -0
- data/rdoc-8.0.0/doc/markup_reference/markdown.md +659 -0
- data/rdoc-8.0.0/doc/markup_reference/rdoc.rdoc +1169 -0
- data/rdoc-8.0.0/exe/rdoc +43 -0
- data/rdoc-8.0.0/exe/ri +12 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/alias.rb +98 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/any_method.rb +387 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/attr.rb +178 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/class_module.rb +969 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/constant.rb +221 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/context/section.rb +182 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/context.rb +1238 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/extend.rb +9 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/include.rb +9 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/method_attr.rb +417 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/mixin.rb +123 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/normal_class.rb +92 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/normal_module.rb +73 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/require.rb +51 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/single_class.rb +30 -0
- data/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb +286 -0
- data/rdoc-8.0.0/lib/rdoc/code_object.rb +393 -0
- data/rdoc-8.0.0/lib/rdoc/code_objects.rb +5 -0
- data/rdoc-8.0.0/lib/rdoc/comment.rb +353 -0
- data/rdoc-8.0.0/lib/rdoc/cross_reference.rb +215 -0
- data/rdoc-8.0.0/lib/rdoc/encoding.rb +120 -0
- data/rdoc-8.0.0/lib/rdoc/erb_partial.rb +18 -0
- data/rdoc-8.0.0/lib/rdoc/erbio.rb +37 -0
- data/rdoc-8.0.0/lib/rdoc/generator/aliki.rb +200 -0
- data/rdoc-8.0.0/lib/rdoc/generator/darkfish.rb +824 -0
- data/rdoc-8.0.0/lib/rdoc/generator/json_index.rb +284 -0
- data/rdoc-8.0.0/lib/rdoc/generator/markup.rb +196 -0
- data/rdoc-8.0.0/lib/rdoc/generator/pot/message_extractor.rb +68 -0
- data/rdoc-8.0.0/lib/rdoc/generator/pot/po.rb +84 -0
- data/rdoc-8.0.0/lib/rdoc/generator/pot/po_entry.rb +141 -0
- data/rdoc-8.0.0/lib/rdoc/generator/pot.rb +94 -0
- data/rdoc-8.0.0/lib/rdoc/generator/ri.rb +30 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_head.rhtml +43 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +5 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +17 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +17 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +16 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +21 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +32 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +6 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +15 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +39 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/class.rhtml +220 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/rdoc.css +701 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/index.rhtml +24 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/darkfish.js +140 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/search.js +120 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/page.rhtml +19 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +21 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +65 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +72 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
- data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/searcher.js +271 -0
- data/rdoc-8.0.0/lib/rdoc/generator.rb +52 -0
- data/rdoc-8.0.0/lib/rdoc/i18n/locale.rb +102 -0
- data/rdoc-8.0.0/lib/rdoc/i18n/text.rb +126 -0
- data/rdoc-8.0.0/lib/rdoc/i18n.rb +10 -0
- data/rdoc-8.0.0/lib/rdoc/known_classes.rb +74 -0
- data/rdoc-8.0.0/lib/rdoc/markdown/entities.rb +2131 -0
- data/rdoc-8.0.0/lib/rdoc/markdown/literals.kpeg +21 -0
- data/rdoc-8.0.0/lib/rdoc/markdown/literals.rb +454 -0
- data/rdoc-8.0.0/lib/rdoc/markdown.kpeg +1315 -0
- data/rdoc-8.0.0/lib/rdoc/markdown.rb +16865 -0
- data/rdoc-8.0.0/lib/rdoc/markup/blank_line.rb +29 -0
- data/rdoc-8.0.0/lib/rdoc/markup/block_quote.rb +14 -0
- data/rdoc-8.0.0/lib/rdoc/markup/document.rb +164 -0
- data/rdoc-8.0.0/lib/rdoc/markup/element.rb +21 -0
- data/rdoc-8.0.0/lib/rdoc/markup/formatter.rb +285 -0
- data/rdoc-8.0.0/lib/rdoc/markup/hard_break.rb +34 -0
- data/rdoc-8.0.0/lib/rdoc/markup/heading.rb +170 -0
- data/rdoc-8.0.0/lib/rdoc/markup/include.rb +42 -0
- data/rdoc-8.0.0/lib/rdoc/markup/indented_paragraph.rb +47 -0
- data/rdoc-8.0.0/lib/rdoc/markup/inline_parser.rb +312 -0
- data/rdoc-8.0.0/lib/rdoc/markup/list.rb +101 -0
- data/rdoc-8.0.0/lib/rdoc/markup/list_item.rb +99 -0
- data/rdoc-8.0.0/lib/rdoc/markup/paragraph.rb +28 -0
- data/rdoc-8.0.0/lib/rdoc/markup/parser.rb +585 -0
- data/rdoc-8.0.0/lib/rdoc/markup/pre_process.rb +317 -0
- data/rdoc-8.0.0/lib/rdoc/markup/raw.rb +66 -0
- data/rdoc-8.0.0/lib/rdoc/markup/rule.rb +20 -0
- data/rdoc-8.0.0/lib/rdoc/markup/table.rb +64 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_ansi.rb +144 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_bs.rb +86 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_html.rb +682 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_html_crossref.rb +261 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_html_snippet.rb +287 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_joined_paragraph.rb +41 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_label.rb +84 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_markdown.rb +215 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_rdoc.rb +421 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_table_of_contents.rb +88 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_test.rb +77 -0
- data/rdoc-8.0.0/lib/rdoc/markup/to_tt_only.rb +107 -0
- data/rdoc-8.0.0/lib/rdoc/markup/verbatim.rb +83 -0
- data/rdoc-8.0.0/lib/rdoc/markup.rb +219 -0
- data/rdoc-8.0.0/lib/rdoc/options.rb +1412 -0
- data/rdoc-8.0.0/lib/rdoc/parser/c.rb +1227 -0
- data/rdoc-8.0.0/lib/rdoc/parser/changelog.rb +379 -0
- data/rdoc-8.0.0/lib/rdoc/parser/markdown.rb +22 -0
- data/rdoc-8.0.0/lib/rdoc/parser/rbs.rb +275 -0
- data/rdoc-8.0.0/lib/rdoc/parser/rd.rb +22 -0
- data/rdoc-8.0.0/lib/rdoc/parser/ruby.rb +1266 -0
- data/rdoc-8.0.0/lib/rdoc/parser/ruby_colorizer.rb +253 -0
- data/rdoc-8.0.0/lib/rdoc/parser/simple.rb +44 -0
- data/rdoc-8.0.0/lib/rdoc/parser/text.rb +11 -0
- data/rdoc-8.0.0/lib/rdoc/parser.rb +298 -0
- data/rdoc-8.0.0/lib/rdoc/rbs_helper.rb +186 -0
- data/rdoc-8.0.0/lib/rdoc/rd/block_parser.rb +1706 -0
- data/rdoc-8.0.0/lib/rdoc/rd/block_parser.ry +643 -0
- data/rdoc-8.0.0/lib/rdoc/rd/inline.rb +71 -0
- data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.rb +1854 -0
- data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.ry +593 -0
- data/rdoc-8.0.0/lib/rdoc/rd.rb +99 -0
- data/rdoc-8.0.0/lib/rdoc/rdoc.rb +724 -0
- data/rdoc-8.0.0/lib/rdoc/ri/driver.rb +1572 -0
- data/rdoc-8.0.0/lib/rdoc/ri/formatter.rb +6 -0
- data/rdoc-8.0.0/lib/rdoc/ri/paths.rb +171 -0
- data/rdoc-8.0.0/lib/rdoc/ri/servlet.rb +452 -0
- data/rdoc-8.0.0/lib/rdoc/ri/store.rb +6 -0
- data/rdoc-8.0.0/lib/rdoc/ri/task.rb +71 -0
- data/rdoc-8.0.0/lib/rdoc/ri.rb +21 -0
- data/rdoc-8.0.0/lib/rdoc/rubygems_hook.rb +327 -0
- data/rdoc-8.0.0/lib/rdoc/server.rb +460 -0
- data/rdoc-8.0.0/lib/rdoc/stats/normal.rb +58 -0
- data/rdoc-8.0.0/lib/rdoc/stats/quiet.rb +59 -0
- data/rdoc-8.0.0/lib/rdoc/stats/verbose.rb +44 -0
- data/rdoc-8.0.0/lib/rdoc/stats.rb +484 -0
- data/rdoc-8.0.0/lib/rdoc/store.rb +1205 -0
- data/rdoc-8.0.0/lib/rdoc/task.rb +355 -0
- data/rdoc-8.0.0/lib/rdoc/text.rb +244 -0
- data/rdoc-8.0.0/lib/rdoc/token_stream.rb +104 -0
- data/rdoc-8.0.0/lib/rdoc/tom_doc.rb +257 -0
- data/rdoc-8.0.0/lib/rdoc/version.rb +10 -0
- data/rdoc-8.0.0/lib/rdoc.rb +239 -0
- data/rdoc-8.0.0/lib/rubygems_plugin.rb +14 -0
- data/rdoc-8.0.0/man/ri.1 +249 -0
- data/rdoc-8.0.0/rdoc-logo.svg +43 -0
- data/rdoc-8.0.0/rdoc.gemspec +74 -0
- data/super-quick-rb.gemspec +12 -0
- metadata +257 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# Handle common directives that can occur in a block of text:
|
|
4
|
+
#
|
|
5
|
+
# \:include: filename
|
|
6
|
+
#
|
|
7
|
+
# Directives can be escaped by preceding them with a backslash.
|
|
8
|
+
#
|
|
9
|
+
# RDoc plugin authors can register additional directives to be handled by
|
|
10
|
+
# using RDoc::Markup::PreProcess::register.
|
|
11
|
+
#
|
|
12
|
+
# Any directive that is not built-in to RDoc (including those registered via
|
|
13
|
+
# plugins) will be stored in the metadata hash on the CodeObject the comment
|
|
14
|
+
# is attached to. See RDoc::Markup@Directives for the list of built-in
|
|
15
|
+
# directives.
|
|
16
|
+
|
|
17
|
+
class RDoc::Markup::PreProcess
|
|
18
|
+
|
|
19
|
+
##
|
|
20
|
+
# An RDoc::Options instance that will be filled in with overrides from
|
|
21
|
+
# directives
|
|
22
|
+
|
|
23
|
+
attr_accessor :options
|
|
24
|
+
|
|
25
|
+
##
|
|
26
|
+
# Adds a post-process handler for directives. The handler will be called
|
|
27
|
+
# with the result RDoc::Comment (or text String) and the code object for the
|
|
28
|
+
# comment (if any).
|
|
29
|
+
|
|
30
|
+
def self.post_process(&block)
|
|
31
|
+
@post_processors << block
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# Registered post-processors
|
|
36
|
+
|
|
37
|
+
def self.post_processors
|
|
38
|
+
@post_processors
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
##
|
|
42
|
+
# Registers +directive+ as one handled by RDoc. If a block is given the
|
|
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
|
|
56
|
+
|
|
57
|
+
##
|
|
58
|
+
# Registered directives
|
|
59
|
+
|
|
60
|
+
def self.registered
|
|
61
|
+
@registered
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# Clears all registered directives and post-processors
|
|
66
|
+
|
|
67
|
+
def self.reset
|
|
68
|
+
@post_processors = []
|
|
69
|
+
@registered = {}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
reset
|
|
73
|
+
|
|
74
|
+
##
|
|
75
|
+
# Creates a new pre-processor for +input_file_name+ that will look for
|
|
76
|
+
# included files in +include_path+
|
|
77
|
+
|
|
78
|
+
def initialize(input_file_name, include_path)
|
|
79
|
+
@input_file_name = input_file_name
|
|
80
|
+
@include_path = include_path
|
|
81
|
+
@options = nil
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
##
|
|
85
|
+
# Look for directives in the given +text+.
|
|
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
|
|
104
|
+
|
|
105
|
+
# regexp helper (square brackets for optional)
|
|
106
|
+
# $1 $2 $3 $4 $5
|
|
107
|
+
# [prefix][\]:directive:[spaces][param]newline
|
|
108
|
+
text = text.gsub(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):([\w-]+):([ \t]*)(.+)?(\r?\n|$)/) do
|
|
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"
|
|
121
|
+
end
|
|
122
|
+
handle_directive $1, $3, $5, code_object, text.encoding, &block
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
if comment then
|
|
126
|
+
comment.text = text
|
|
127
|
+
else
|
|
128
|
+
comment = text
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
run_post_processes(comment, code_object)
|
|
132
|
+
|
|
133
|
+
text
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Apply directives to a code object
|
|
137
|
+
|
|
138
|
+
def run_pre_processes(comment_text, code_object, start_line_no, type)
|
|
139
|
+
comment_text, directives = parse_comment(comment_text, start_line_no, type)
|
|
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
|
|
149
|
+
|
|
150
|
+
# Perform post preocesses to a code object
|
|
151
|
+
|
|
152
|
+
def run_post_processes(comment, code_object)
|
|
153
|
+
self.class.post_processors.each do |handler|
|
|
154
|
+
handler.call comment, code_object
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Parse comment and return [normalized_comment_text, directives_hash]
|
|
159
|
+
|
|
160
|
+
def parse_comment(text, line_no, type)
|
|
161
|
+
RDoc::Comment.parse(text, @input_file_name, line_no, type) do |filename, prefix_indent|
|
|
162
|
+
include_file(filename, prefix_indent, text.encoding)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
##
|
|
167
|
+
# Performs the actions described by +directive+ and its parameter +param+.
|
|
168
|
+
#
|
|
169
|
+
# +code_object+ is used for directives that operate on a class or module.
|
|
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
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
blankline # ignore category if we're not on an RDoc::Context
|
|
198
|
+
when 'doc' then
|
|
199
|
+
return blankline unless code_object
|
|
200
|
+
code_object.document_self = true
|
|
201
|
+
code_object.force_documentation = true
|
|
202
|
+
|
|
203
|
+
blankline
|
|
204
|
+
when 'enddoc' then
|
|
205
|
+
return blankline unless code_object
|
|
206
|
+
code_object.done_documenting = true
|
|
207
|
+
|
|
208
|
+
blankline
|
|
209
|
+
when 'include' then
|
|
210
|
+
filename = param.split(' ', 2).first
|
|
211
|
+
include_file filename, prefix, encoding
|
|
212
|
+
when 'nodoc' then
|
|
213
|
+
return blankline unless code_object
|
|
214
|
+
code_object.document_self = nil # notify nodoc
|
|
215
|
+
code_object.document_children = param !~ /all/i
|
|
216
|
+
|
|
217
|
+
blankline
|
|
218
|
+
when 'notnew', 'not_new', 'not-new' then
|
|
219
|
+
return blankline unless RDoc::AnyMethod === code_object
|
|
220
|
+
|
|
221
|
+
code_object.dont_rename_initialize = true
|
|
222
|
+
|
|
223
|
+
blankline
|
|
224
|
+
when 'startdoc' then
|
|
225
|
+
return blankline unless code_object
|
|
226
|
+
|
|
227
|
+
code_object.start_doc
|
|
228
|
+
code_object.force_documentation = true
|
|
229
|
+
|
|
230
|
+
blankline
|
|
231
|
+
when 'stopdoc' then
|
|
232
|
+
return blankline unless code_object
|
|
233
|
+
|
|
234
|
+
code_object.stop_doc
|
|
235
|
+
|
|
236
|
+
blankline
|
|
237
|
+
when 'yield', 'yields' then
|
|
238
|
+
return blankline unless code_object
|
|
239
|
+
# remove parameter &block
|
|
240
|
+
code_object.params = code_object.params.sub(/,?\s*&\w+/, '') if code_object.params
|
|
241
|
+
|
|
242
|
+
code_object.block_params = param || ''
|
|
243
|
+
|
|
244
|
+
blankline
|
|
245
|
+
else
|
|
246
|
+
result = yield directive, param if block_given?
|
|
247
|
+
|
|
248
|
+
case result
|
|
249
|
+
when nil then
|
|
250
|
+
code_object.metadata[directive] = param if code_object
|
|
251
|
+
|
|
252
|
+
if RDoc::Markup::PreProcess.registered.include? directive then
|
|
253
|
+
handler = RDoc::Markup::PreProcess.registered[directive]
|
|
254
|
+
result = handler.call directive, param if handler
|
|
255
|
+
else
|
|
256
|
+
result = "#{prefix}:#{directive}: #{param}\n"
|
|
257
|
+
end
|
|
258
|
+
when false then
|
|
259
|
+
result = "#{prefix}:#{directive}: #{param}\n"
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
result
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
##
|
|
267
|
+
# Handles the <tt>:include: _filename_</tt> directive.
|
|
268
|
+
#
|
|
269
|
+
# If the first line of the included file starts with '#', and contains
|
|
270
|
+
# an encoding information in the form 'coding:' or 'coding=', it is
|
|
271
|
+
# removed.
|
|
272
|
+
#
|
|
273
|
+
# If all lines in the included file start with a '#', this leading '#'
|
|
274
|
+
# is removed before inclusion. The included content is indented like
|
|
275
|
+
# the <tt>:include:</tt> directive.
|
|
276
|
+
#--
|
|
277
|
+
# so all content will be verbatim because of the likely space after '#'?
|
|
278
|
+
# TODO shift left the whole file content in that case
|
|
279
|
+
# TODO comment stop/start #-- and #++ in included file must be processed here
|
|
280
|
+
|
|
281
|
+
def include_file(name, indent, encoding)
|
|
282
|
+
full_name = find_include_file name
|
|
283
|
+
|
|
284
|
+
unless full_name then
|
|
285
|
+
warn "Couldn't find file to include '#{name}' from #{@input_file_name}"
|
|
286
|
+
return ''
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
content = RDoc::Encoding.read_file full_name, encoding, true
|
|
290
|
+
content = RDoc::Encoding.remove_magic_comment content
|
|
291
|
+
|
|
292
|
+
# strip magic comment
|
|
293
|
+
content = content.sub(/\A# .*coding[=:].*$/, '').lstrip
|
|
294
|
+
|
|
295
|
+
# strip leading '#'s, but only if all lines start with them
|
|
296
|
+
if content =~ /^[^#]/ then
|
|
297
|
+
content.gsub(/^/, indent)
|
|
298
|
+
else
|
|
299
|
+
content.gsub(/^#?/, indent)
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
##
|
|
304
|
+
# Look for the given file in the directory containing the current file,
|
|
305
|
+
# and then in each of the directories specified in the RDOC_INCLUDE path
|
|
306
|
+
|
|
307
|
+
def find_include_file(name)
|
|
308
|
+
to_search = [File.dirname(@input_file_name)].concat @include_path
|
|
309
|
+
to_search.each do |dir|
|
|
310
|
+
full_name = File.join(dir, name)
|
|
311
|
+
stat = File.stat(full_name) rescue next
|
|
312
|
+
return full_name if stat.readable?
|
|
313
|
+
end
|
|
314
|
+
nil
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# A section of text that is added to the output document as-is
|
|
6
|
+
class Raw
|
|
7
|
+
# The component parts of the list
|
|
8
|
+
#: Array[String]
|
|
9
|
+
attr_reader :parts
|
|
10
|
+
|
|
11
|
+
# Creates a new Raw containing +parts+
|
|
12
|
+
#: (*String) -> void
|
|
13
|
+
def initialize(*parts)
|
|
14
|
+
@parts = parts
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Appends +text+
|
|
18
|
+
#: (String) -> void
|
|
19
|
+
def <<(text)
|
|
20
|
+
@parts << text
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
#: (top) -> bool
|
|
24
|
+
def ==(other) # :nodoc:
|
|
25
|
+
self.class == other.class && @parts == other.parts
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Calls #accept_raw+ on +visitor+
|
|
29
|
+
# @override
|
|
30
|
+
#: (untyped) -> void
|
|
31
|
+
def accept(visitor)
|
|
32
|
+
visitor.accept_raw(self)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Appends +other+'s parts
|
|
36
|
+
#: (Raw) -> void
|
|
37
|
+
def merge(other)
|
|
38
|
+
@parts.concat(other.parts)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @override
|
|
42
|
+
#: (PP) -> void
|
|
43
|
+
def pretty_print(q) # :nodoc:
|
|
44
|
+
self.class.name =~ /.*::(\w{1,4})/i
|
|
45
|
+
|
|
46
|
+
q.group(2, "[#{$1.downcase}: ", ']') do
|
|
47
|
+
q.seplist(@parts) do |part|
|
|
48
|
+
q.pp(part)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Appends +texts+ onto this Paragraph
|
|
54
|
+
#: (*String) -> void
|
|
55
|
+
def push(*texts)
|
|
56
|
+
self.parts.concat(texts)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# The raw text
|
|
60
|
+
#: () -> String
|
|
61
|
+
def text
|
|
62
|
+
@parts.join(" ")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# A horizontal rule with a weight
|
|
4
|
+
|
|
5
|
+
class RDoc::Markup::Rule < Struct.new :weight
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Calls #accept_rule on +visitor+
|
|
9
|
+
|
|
10
|
+
def accept(visitor)
|
|
11
|
+
visitor.accept_rule self
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def pretty_print(q) # :nodoc:
|
|
15
|
+
q.group 2, '[rule:', ']' do
|
|
16
|
+
q.pp weight
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# A section of table
|
|
6
|
+
class Table < Element
|
|
7
|
+
# Headers of each column
|
|
8
|
+
#: Array[String]
|
|
9
|
+
attr_accessor :header
|
|
10
|
+
|
|
11
|
+
# Alignments of each column
|
|
12
|
+
#: Array[Symbol?]
|
|
13
|
+
attr_accessor :align
|
|
14
|
+
|
|
15
|
+
# Body texts of each column
|
|
16
|
+
#: Array[String]
|
|
17
|
+
attr_accessor :body
|
|
18
|
+
|
|
19
|
+
#: (Array[String], Array[Symbol?], Array[String]) -> void
|
|
20
|
+
def initialize(header, align, body)
|
|
21
|
+
@header, @align, @body = header, align, body
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#: (Object) -> bool
|
|
25
|
+
def ==(other)
|
|
26
|
+
self.class == other.class && @header == other.header &&
|
|
27
|
+
@align == other.align && @body == other.body
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @override
|
|
31
|
+
#: (untyped) -> void
|
|
32
|
+
def accept(visitor)
|
|
33
|
+
visitor.accept_table(@header, @body, @align)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @override
|
|
37
|
+
#: (untyped) -> String
|
|
38
|
+
def pretty_print(q)
|
|
39
|
+
q.group 2, '[Table: ', ']' do
|
|
40
|
+
q.group 2, '[Head: ', ']' do
|
|
41
|
+
q.seplist @header.zip(@align) do |text, align|
|
|
42
|
+
q.pp text
|
|
43
|
+
if align
|
|
44
|
+
q.text ":"
|
|
45
|
+
q.breakable
|
|
46
|
+
q.text align.to_s
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
q.breakable
|
|
51
|
+
q.group 2, '[Body: ', ']' do
|
|
52
|
+
q.seplist @body do |body|
|
|
53
|
+
q.group 2, '[', ']' do
|
|
54
|
+
q.seplist body do |text|
|
|
55
|
+
q.pp text
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# Outputs RDoc markup with vibrant ANSI color!
|
|
4
|
+
|
|
5
|
+
class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Creates a new ToAnsi visitor that is ready to output vibrant ANSI color!
|
|
9
|
+
|
|
10
|
+
def initialize
|
|
11
|
+
super
|
|
12
|
+
|
|
13
|
+
@headings.clear
|
|
14
|
+
@headings[1] = ["\e[1;32m", "\e[m"] # bold
|
|
15
|
+
@headings[2] = ["\e[4;32m", "\e[m"] # underline
|
|
16
|
+
@headings[3] = ["\e[32m", "\e[m"] # just green
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
##
|
|
20
|
+
# Maps attributes to ANSI sequences
|
|
21
|
+
|
|
22
|
+
ANSI_STYLE_CODES_ON = {
|
|
23
|
+
BOLD: 1,
|
|
24
|
+
TT: 7,
|
|
25
|
+
EM: 4,
|
|
26
|
+
STRIKE: 9
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ANSI_STYLE_CODES_OFF = {
|
|
30
|
+
BOLD: 22,
|
|
31
|
+
TT: 27,
|
|
32
|
+
EM: 24,
|
|
33
|
+
STRIKE: 29
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# Apply the given attributes by emitting ANSI sequences.
|
|
37
|
+
# Emitting attribute changes are deferred until new text is added and applied in batch.
|
|
38
|
+
# This method computes the necessary ANSI codes to transition from the
|
|
39
|
+
# current set of applied attributes to the new set of +attributes+.
|
|
40
|
+
|
|
41
|
+
def apply_attributes(attributes)
|
|
42
|
+
before = @applied_attributes
|
|
43
|
+
after = attributes.sort
|
|
44
|
+
return if before == after
|
|
45
|
+
|
|
46
|
+
if after.empty?
|
|
47
|
+
emit_inline("\e[m")
|
|
48
|
+
elsif !before.empty? && before.size > (before & after).size + 1
|
|
49
|
+
codes = after.map {|attr| ANSI_STYLE_CODES_ON[attr] }.compact
|
|
50
|
+
emit_inline("\e[#{[0, *codes].join(';')}m")
|
|
51
|
+
else
|
|
52
|
+
off_codes = (before - after).map {|attr| ANSI_STYLE_CODES_OFF[attr] }.compact
|
|
53
|
+
on_codes = (after - before).map {|attr| ANSI_STYLE_CODES_ON[attr] }.compact
|
|
54
|
+
emit_inline("\e[#{(off_codes + on_codes).join(';')}m")
|
|
55
|
+
end
|
|
56
|
+
@applied_attributes = attributes
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def add_text(text)
|
|
60
|
+
attrs = @attributes.keys
|
|
61
|
+
if @applied_attributes != attrs
|
|
62
|
+
apply_attributes(attrs)
|
|
63
|
+
end
|
|
64
|
+
emit_inline(text)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def handle_inline(text)
|
|
68
|
+
@applied_attributes = []
|
|
69
|
+
res = super
|
|
70
|
+
res << "\e[m" unless @applied_attributes.empty?
|
|
71
|
+
@applied_attributes = []
|
|
72
|
+
res
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
##
|
|
76
|
+
# Overrides indent width to ensure output lines up correctly.
|
|
77
|
+
|
|
78
|
+
def accept_list_item_end(list_item)
|
|
79
|
+
width = case @list_type.last
|
|
80
|
+
when :BULLET then
|
|
81
|
+
2
|
|
82
|
+
when :NOTE, :LABEL then
|
|
83
|
+
if @prefix then
|
|
84
|
+
@res << @prefix.strip
|
|
85
|
+
@prefix = nil
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
@res << "\n" unless res.length == 1
|
|
89
|
+
2
|
|
90
|
+
else
|
|
91
|
+
bullet = @list_index.last.to_s
|
|
92
|
+
@list_index[-1] = @list_index.last.succ
|
|
93
|
+
bullet.length + 2
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
@indent -= width
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
##
|
|
100
|
+
# Adds coloring to note and label list items
|
|
101
|
+
|
|
102
|
+
def accept_list_item_start(list_item)
|
|
103
|
+
bullet = case @list_type.last
|
|
104
|
+
when :BULLET then
|
|
105
|
+
'*'
|
|
106
|
+
when :NOTE, :LABEL then
|
|
107
|
+
labels = Array(list_item.label).map do |label|
|
|
108
|
+
attributes(label).strip
|
|
109
|
+
end.join "\n"
|
|
110
|
+
|
|
111
|
+
labels << ":\n" unless labels.empty?
|
|
112
|
+
|
|
113
|
+
labels
|
|
114
|
+
else
|
|
115
|
+
@list_index.last.to_s + '.'
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
case @list_type.last
|
|
119
|
+
when :NOTE, :LABEL then
|
|
120
|
+
@indent += 2
|
|
121
|
+
@prefix = bullet + (' ' * @indent)
|
|
122
|
+
else
|
|
123
|
+
@prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
|
|
124
|
+
|
|
125
|
+
width = bullet.gsub(/\e\[[\d;]*m/, '').length + 1
|
|
126
|
+
|
|
127
|
+
@indent += width
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def calculate_text_width(text)
|
|
132
|
+
text.gsub(/\e\[[\d;]*m/, '').size
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
##
|
|
136
|
+
# Starts accepting with a reset screen
|
|
137
|
+
|
|
138
|
+
def start_accepting
|
|
139
|
+
super
|
|
140
|
+
|
|
141
|
+
@res = ["\e[0m"]
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# Outputs RDoc markup with hot backspace action! You will probably need a
|
|
4
|
+
# pager to use this output format.
|
|
5
|
+
#
|
|
6
|
+
# This formatter won't work on 1.8.6 because it lacks String#chars.
|
|
7
|
+
|
|
8
|
+
class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
|
|
9
|
+
|
|
10
|
+
##
|
|
11
|
+
# Returns a new ToBs that is ready for hot backspace action!
|
|
12
|
+
|
|
13
|
+
def initialize
|
|
14
|
+
super
|
|
15
|
+
|
|
16
|
+
@in_b = false
|
|
17
|
+
@in_em = false
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def handle_inline(text)
|
|
21
|
+
initial_style = []
|
|
22
|
+
initial_style << :BOLD if @in_b
|
|
23
|
+
initial_style << :EM if @in_em
|
|
24
|
+
super(text, initial_style)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def add_text(text)
|
|
28
|
+
attrs = @attributes.keys
|
|
29
|
+
if attrs.include? :BOLD
|
|
30
|
+
styled = +''
|
|
31
|
+
text.chars.each do |c|
|
|
32
|
+
styled << "#{c}\b#{c}"
|
|
33
|
+
end
|
|
34
|
+
text = styled
|
|
35
|
+
elsif attrs.include? :EM
|
|
36
|
+
styled = +''
|
|
37
|
+
text.chars.each do |c|
|
|
38
|
+
styled << "_\b#{c}"
|
|
39
|
+
end
|
|
40
|
+
text = styled
|
|
41
|
+
end
|
|
42
|
+
emit_inline(text)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Makes heading text bold.
|
|
47
|
+
|
|
48
|
+
def accept_heading(heading)
|
|
49
|
+
use_prefix or @res << ' ' * @indent
|
|
50
|
+
@res << @headings[heading.level][0]
|
|
51
|
+
@in_b = true
|
|
52
|
+
@res << attributes(heading.text)
|
|
53
|
+
@in_b = false
|
|
54
|
+
@res << @headings[heading.level][1]
|
|
55
|
+
@res << "\n"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
##
|
|
59
|
+
# Prepares the visitor for consuming +list_item+
|
|
60
|
+
|
|
61
|
+
def accept_list_item_start(list_item)
|
|
62
|
+
type = @list_type.last
|
|
63
|
+
|
|
64
|
+
case type
|
|
65
|
+
when :NOTE, :LABEL then
|
|
66
|
+
bullets = Array(list_item.label).map do |label|
|
|
67
|
+
attributes(label).strip
|
|
68
|
+
end.join "\n"
|
|
69
|
+
|
|
70
|
+
bullets << ":\n" unless bullets.empty?
|
|
71
|
+
|
|
72
|
+
@prefix = ' ' * @indent
|
|
73
|
+
@indent += 2
|
|
74
|
+
@prefix << bullets + (' ' * @indent)
|
|
75
|
+
else
|
|
76
|
+
bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
|
|
77
|
+
@prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
|
|
78
|
+
width = bullet.length + 1
|
|
79
|
+
@indent += width
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def calculate_text_width(text)
|
|
84
|
+
text.gsub(/_\x08/, '').gsub(/\x08./, '').size
|
|
85
|
+
end
|
|
86
|
+
end
|