gitlab-rdoc 6.3.2
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/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 +133 -0
- data/RI.rdoc +57 -0
- data/Rakefile +101 -0
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/exe/rdoc +44 -0
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +112 -0
- data/lib/rdoc/anon_class.rb +11 -0
- data/lib/rdoc/any_method.rb +361 -0
- data/lib/rdoc/attr.rb +176 -0
- data/lib/rdoc/class_module.rb +802 -0
- data/lib/rdoc/code_object.rb +421 -0
- data/lib/rdoc/code_objects.rb +6 -0
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +187 -0
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +1266 -0
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +136 -0
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +42 -0
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +790 -0
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +160 -0
- 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 +31 -0
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- 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/brick.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
- data/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +84 -0
- 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 +51 -0
- data/lib/rdoc/ghost_method.rb +7 -0
- 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 +10 -0
- data/lib/rdoc/known_classes.rb +73 -0
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +417 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16685 -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 +409 -0
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +28 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +165 -0
- data/lib/rdoc/markup/formatter.rb +266 -0
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +79 -0
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +102 -0
- data/lib/rdoc/markup/list_item.rb +100 -0
- data/lib/rdoc/markup/paragraph.rb +29 -0
- data/lib/rdoc/markup/parser.rb +575 -0
- data/lib/rdoc/markup/pre_process.rb +296 -0
- data/lib/rdoc/markup/raw.rb +70 -0
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +21 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +94 -0
- data/lib/rdoc/markup/to_bs.rb +77 -0
- data/lib/rdoc/markup/to_html.rb +444 -0
- data/lib/rdoc/markup/to_html_crossref.rb +176 -0
- 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 +362 -0
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +70 -0
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +84 -0
- data/lib/rdoc/markup.rb +867 -0
- data/lib/rdoc/meta_method.rb +7 -0
- data/lib/rdoc/method_attr.rb +419 -0
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +93 -0
- data/lib/rdoc/normal_module.rb +74 -0
- data/lib/rdoc/options.rb +1285 -0
- data/lib/rdoc/parser/c.rb +1225 -0
- 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 +2327 -0
- data/lib/rdoc/parser/ruby_tools.rb +167 -0
- data/lib/rdoc/parser/simple.rb +61 -0
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +277 -0
- 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 +579 -0
- data/lib/rdoc/require.rb +52 -0
- data/lib/rdoc/ri/driver.rb +1572 -0
- data/lib/rdoc/ri/formatter.rb +6 -0
- data/lib/rdoc/ri/paths.rb +171 -0
- data/lib/rdoc/ri/store.rb +7 -0
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +21 -0
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +26 -0
- data/lib/rdoc/stats/normal.rb +58 -0
- data/lib/rdoc/stats/quiet.rb +60 -0
- data/lib/rdoc/stats/verbose.rb +46 -0
- data/lib/rdoc/stats.rb +462 -0
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +329 -0
- data/lib/rdoc/text.rb +304 -0
- data/lib/rdoc/token_stream.rb +119 -0
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +289 -0
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +201 -0
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +279 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# A TokenStream is a list of tokens, gathered during the parse of some entity
|
|
4
|
+
# (say a method). Entities populate these streams by being registered with the
|
|
5
|
+
# lexer. Any class can collect tokens by including TokenStream. From the
|
|
6
|
+
# outside, you use such an object by calling the start_collecting_tokens
|
|
7
|
+
# method, followed by calls to add_token and pop_token.
|
|
8
|
+
|
|
9
|
+
module RDoc::TokenStream
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# Converts +token_stream+ to HTML wrapping various tokens with
|
|
13
|
+
# <tt><span></tt> elements. Some tokens types are wrapped in spans
|
|
14
|
+
# with the given class names. Other token types are not wrapped in spans.
|
|
15
|
+
|
|
16
|
+
def self.to_html token_stream
|
|
17
|
+
starting_title = false
|
|
18
|
+
|
|
19
|
+
token_stream.map do |t|
|
|
20
|
+
next unless t
|
|
21
|
+
|
|
22
|
+
style = case t[:kind]
|
|
23
|
+
when :on_const then 'ruby-constant'
|
|
24
|
+
when :on_kw then 'ruby-keyword'
|
|
25
|
+
when :on_ivar then 'ruby-ivar'
|
|
26
|
+
when :on_cvar then 'ruby-identifier'
|
|
27
|
+
when :on_gvar then 'ruby-identifier'
|
|
28
|
+
when '=' != t[:text] && :on_op
|
|
29
|
+
then 'ruby-operator'
|
|
30
|
+
when :on_tlambda then 'ruby-operator'
|
|
31
|
+
when :on_ident then 'ruby-identifier'
|
|
32
|
+
when :on_label then 'ruby-value'
|
|
33
|
+
when :on_backref, :on_dstring
|
|
34
|
+
then 'ruby-node'
|
|
35
|
+
when :on_comment then 'ruby-comment'
|
|
36
|
+
when :on_embdoc then 'ruby-comment'
|
|
37
|
+
when :on_regexp then 'ruby-regexp'
|
|
38
|
+
when :on_tstring then 'ruby-string'
|
|
39
|
+
when :on_int, :on_float,
|
|
40
|
+
:on_rational, :on_imaginary,
|
|
41
|
+
:on_heredoc,
|
|
42
|
+
:on_symbol, :on_CHAR then 'ruby-value'
|
|
43
|
+
when :on_heredoc_beg, :on_heredoc_end
|
|
44
|
+
then 'ruby-identifier'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
comment_with_nl = false
|
|
48
|
+
if :on_comment == t[:kind] or :on_embdoc == t[:kind] or :on_heredoc_end == t[:kind]
|
|
49
|
+
comment_with_nl = true if "\n" == t[:text][-1]
|
|
50
|
+
text = t[:text].rstrip
|
|
51
|
+
else
|
|
52
|
+
text = t[:text]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
if :on_ident == t[:kind] && starting_title
|
|
56
|
+
starting_title = false
|
|
57
|
+
style = 'ruby-identifier ruby-title'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if :on_kw == t[:kind] and 'def' == t[:text]
|
|
61
|
+
starting_title = true
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
text = CGI.escapeHTML text
|
|
65
|
+
|
|
66
|
+
if style then
|
|
67
|
+
"<span class=\"#{style}\">#{text}</span>#{"\n" if comment_with_nl}"
|
|
68
|
+
else
|
|
69
|
+
text
|
|
70
|
+
end
|
|
71
|
+
end.join
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
##
|
|
75
|
+
# Adds +tokens+ to the collected tokens
|
|
76
|
+
|
|
77
|
+
def add_tokens(tokens)
|
|
78
|
+
@token_stream.concat(tokens)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
##
|
|
82
|
+
# Adds one +token+ to the collected tokens
|
|
83
|
+
|
|
84
|
+
def add_token(token)
|
|
85
|
+
@token_stream.push(token)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# Starts collecting tokens
|
|
90
|
+
|
|
91
|
+
def collect_tokens
|
|
92
|
+
@token_stream = []
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
alias start_collecting_tokens collect_tokens
|
|
96
|
+
|
|
97
|
+
##
|
|
98
|
+
# Remove the last token from the collected tokens
|
|
99
|
+
|
|
100
|
+
def pop_token
|
|
101
|
+
@token_stream.pop
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
##
|
|
105
|
+
# Current token stream
|
|
106
|
+
|
|
107
|
+
def token_stream
|
|
108
|
+
@token_stream
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
##
|
|
112
|
+
# Returns a string representation of the token stream
|
|
113
|
+
|
|
114
|
+
def tokens_to_s
|
|
115
|
+
token_stream.compact.map { |token| token[:text] }.join ''
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
|
data/lib/rdoc/tom_doc.rb
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# :markup: tomdoc
|
|
3
|
+
|
|
4
|
+
# A parser for TomDoc based on TomDoc 1.0.0-rc1 (02adef9b5a)
|
|
5
|
+
#
|
|
6
|
+
# The TomDoc specification can be found at:
|
|
7
|
+
#
|
|
8
|
+
# http://tomdoc.org
|
|
9
|
+
#
|
|
10
|
+
# The latest version of the TomDoc specification can be found at:
|
|
11
|
+
#
|
|
12
|
+
# https://github.com/mojombo/tomdoc/blob/master/tomdoc.md
|
|
13
|
+
#
|
|
14
|
+
# To choose TomDoc as your only default format see RDoc::Options@Saved+Options
|
|
15
|
+
# for instructions on setting up a <code>.rdoc_options</code> file to store
|
|
16
|
+
# your project default.
|
|
17
|
+
#
|
|
18
|
+
# There are a few differences between this parser and the specification. A
|
|
19
|
+
# best-effort was made to follow the specification as closely as possible but
|
|
20
|
+
# some choices to deviate were made.
|
|
21
|
+
#
|
|
22
|
+
# A future version of RDoc will warn when a MUST or MUST NOT is violated and
|
|
23
|
+
# may warn when a SHOULD or SHOULD NOT is violated. RDoc will always try
|
|
24
|
+
# to emit documentation even if given invalid TomDoc.
|
|
25
|
+
#
|
|
26
|
+
# Here are some implementation choices this parser currently makes:
|
|
27
|
+
#
|
|
28
|
+
# This parser allows rdoc-style inline markup but you should not depended on
|
|
29
|
+
# it.
|
|
30
|
+
#
|
|
31
|
+
# This parser allows a space between the comment and the method body.
|
|
32
|
+
#
|
|
33
|
+
# This parser does not require the default value to be described for an
|
|
34
|
+
# optional argument.
|
|
35
|
+
#
|
|
36
|
+
# This parser does not examine the order of sections. An Examples section may
|
|
37
|
+
# precede the Arguments section.
|
|
38
|
+
#
|
|
39
|
+
# This class is documented in TomDoc format. Since this is a subclass of the
|
|
40
|
+
# RDoc markup parser there isn't much to see here, unfortunately.
|
|
41
|
+
|
|
42
|
+
class RDoc::TomDoc < RDoc::Markup::Parser
|
|
43
|
+
|
|
44
|
+
# Internal: Token accessor
|
|
45
|
+
|
|
46
|
+
attr_reader :tokens
|
|
47
|
+
|
|
48
|
+
# Internal: Adds a post-processor which sets the RDoc section based on the
|
|
49
|
+
# comment's status.
|
|
50
|
+
#
|
|
51
|
+
# Returns nothing.
|
|
52
|
+
|
|
53
|
+
def self.add_post_processor # :nodoc:
|
|
54
|
+
RDoc::Markup::PreProcess.post_process do |comment, code_object|
|
|
55
|
+
next unless code_object and
|
|
56
|
+
RDoc::Comment === comment and comment.format == 'tomdoc'
|
|
57
|
+
|
|
58
|
+
comment.text.gsub!(/(\A\s*# )(Public|Internal|Deprecated):\s+/) do
|
|
59
|
+
section = code_object.add_section $2
|
|
60
|
+
code_object.temporary_section = section
|
|
61
|
+
|
|
62
|
+
$1
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
add_post_processor
|
|
68
|
+
|
|
69
|
+
# Public: Parses TomDoc from text
|
|
70
|
+
#
|
|
71
|
+
# text - A String containing TomDoc-format text.
|
|
72
|
+
#
|
|
73
|
+
# Examples
|
|
74
|
+
#
|
|
75
|
+
# RDoc::TomDoc.parse <<-TOMDOC
|
|
76
|
+
# This method does some things
|
|
77
|
+
#
|
|
78
|
+
# Returns nothing.
|
|
79
|
+
# TOMDOC
|
|
80
|
+
# # => #<RDoc::Markup::Document:0xXXX @parts=[...], @file=nil>
|
|
81
|
+
#
|
|
82
|
+
# Returns an RDoc::Markup::Document representing the TomDoc format.
|
|
83
|
+
|
|
84
|
+
def self.parse text
|
|
85
|
+
parser = new
|
|
86
|
+
|
|
87
|
+
parser.tokenize text
|
|
88
|
+
doc = RDoc::Markup::Document.new
|
|
89
|
+
parser.parse doc
|
|
90
|
+
doc
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Internal: Extracts the Signature section's method signature
|
|
94
|
+
#
|
|
95
|
+
# comment - An RDoc::Comment that will be parsed and have the signature
|
|
96
|
+
# extracted
|
|
97
|
+
#
|
|
98
|
+
# Returns a String containing the signature and nil if not
|
|
99
|
+
|
|
100
|
+
def self.signature comment
|
|
101
|
+
return unless comment.tomdoc?
|
|
102
|
+
|
|
103
|
+
document = comment.parse
|
|
104
|
+
|
|
105
|
+
signature = nil
|
|
106
|
+
found_heading = false
|
|
107
|
+
found_signature = false
|
|
108
|
+
|
|
109
|
+
document.parts.delete_if do |part|
|
|
110
|
+
next false if found_signature
|
|
111
|
+
|
|
112
|
+
found_heading ||=
|
|
113
|
+
RDoc::Markup::Heading === part && part.text == 'Signature'
|
|
114
|
+
|
|
115
|
+
next false unless found_heading
|
|
116
|
+
|
|
117
|
+
next true if RDoc::Markup::BlankLine === part
|
|
118
|
+
|
|
119
|
+
if RDoc::Markup::Verbatim === part then
|
|
120
|
+
signature = part
|
|
121
|
+
found_signature = true
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
signature and signature.text
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Public: Creates a new TomDoc parser. See also RDoc::Markup::parse
|
|
129
|
+
|
|
130
|
+
def initialize
|
|
131
|
+
super
|
|
132
|
+
|
|
133
|
+
@section = nil
|
|
134
|
+
@seen_returns = false
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Internal: Builds a heading from the token stream
|
|
138
|
+
#
|
|
139
|
+
# level - The level of heading to create
|
|
140
|
+
#
|
|
141
|
+
# Returns an RDoc::Markup::Heading
|
|
142
|
+
|
|
143
|
+
def build_heading level
|
|
144
|
+
heading = super
|
|
145
|
+
|
|
146
|
+
@section = heading.text
|
|
147
|
+
|
|
148
|
+
heading
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Internal: Builds a verbatim from the token stream. A verbatim in the
|
|
152
|
+
# Examples section will be marked as in Ruby format.
|
|
153
|
+
#
|
|
154
|
+
# margin - The indentation from the margin for lines that belong to this
|
|
155
|
+
# verbatim section.
|
|
156
|
+
#
|
|
157
|
+
# Returns an RDoc::Markup::Verbatim
|
|
158
|
+
|
|
159
|
+
def build_verbatim margin
|
|
160
|
+
verbatim = super
|
|
161
|
+
|
|
162
|
+
verbatim.format = :ruby if @section == 'Examples'
|
|
163
|
+
|
|
164
|
+
verbatim
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Internal: Builds a paragraph from the token stream
|
|
168
|
+
#
|
|
169
|
+
# margin - Unused
|
|
170
|
+
#
|
|
171
|
+
# Returns an RDoc::Markup::Paragraph.
|
|
172
|
+
|
|
173
|
+
def build_paragraph margin
|
|
174
|
+
p :paragraph_start => margin if @debug
|
|
175
|
+
|
|
176
|
+
paragraph = RDoc::Markup::Paragraph.new
|
|
177
|
+
|
|
178
|
+
until @tokens.empty? do
|
|
179
|
+
type, data, = get
|
|
180
|
+
|
|
181
|
+
case type
|
|
182
|
+
when :TEXT then
|
|
183
|
+
@section = 'Returns' if data =~ /\A(Returns|Raises)/
|
|
184
|
+
|
|
185
|
+
paragraph << data
|
|
186
|
+
when :NEWLINE then
|
|
187
|
+
if :TEXT == peek_token[0] then
|
|
188
|
+
# Lines beginning with 'Raises' in the Returns section should not be
|
|
189
|
+
# treated as multiline text
|
|
190
|
+
if 'Returns' == @section and
|
|
191
|
+
peek_token[1].start_with?('Raises') then
|
|
192
|
+
break
|
|
193
|
+
else
|
|
194
|
+
paragraph << ' '
|
|
195
|
+
end
|
|
196
|
+
else
|
|
197
|
+
break
|
|
198
|
+
end
|
|
199
|
+
else
|
|
200
|
+
unget
|
|
201
|
+
break
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
p :paragraph_end => margin if @debug
|
|
206
|
+
|
|
207
|
+
paragraph
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
##
|
|
211
|
+
# Detects a section change to "Returns" and adds a heading
|
|
212
|
+
|
|
213
|
+
def parse_text parent, indent # :nodoc:
|
|
214
|
+
paragraph = build_paragraph indent
|
|
215
|
+
|
|
216
|
+
if false == @seen_returns and 'Returns' == @section then
|
|
217
|
+
@seen_returns = true
|
|
218
|
+
parent << RDoc::Markup::Heading.new(3, 'Returns')
|
|
219
|
+
parent << RDoc::Markup::BlankLine.new
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
parent << paragraph
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Internal: Turns text into an Array of tokens
|
|
226
|
+
#
|
|
227
|
+
# text - A String containing TomDoc-format text.
|
|
228
|
+
#
|
|
229
|
+
# Returns self.
|
|
230
|
+
|
|
231
|
+
def tokenize text
|
|
232
|
+
text = text.sub(/\A(Public|Internal|Deprecated):\s+/, '')
|
|
233
|
+
|
|
234
|
+
setup_scanner text
|
|
235
|
+
|
|
236
|
+
until @s.eos? do
|
|
237
|
+
pos = @s.pos
|
|
238
|
+
|
|
239
|
+
# leading spaces will be reflected by the column of the next token
|
|
240
|
+
# the only thing we loose are trailing spaces at the end of the file
|
|
241
|
+
next if @s.scan(/ +/)
|
|
242
|
+
|
|
243
|
+
@tokens << case
|
|
244
|
+
when @s.scan(/\r?\n/) then
|
|
245
|
+
token = [:NEWLINE, @s.matched, *pos]
|
|
246
|
+
@s.newline!
|
|
247
|
+
token
|
|
248
|
+
when @s.scan(/(Examples|Signature)$/) then
|
|
249
|
+
@tokens << [:HEADER, 3, *pos]
|
|
250
|
+
|
|
251
|
+
[:TEXT, @s[1], *pos]
|
|
252
|
+
when @s.scan(/([:\w][\w\[\]]*)[ ]+- /) then
|
|
253
|
+
[:NOTE, @s[1], *pos]
|
|
254
|
+
else
|
|
255
|
+
@s.scan(/.*/)
|
|
256
|
+
[:TEXT, @s.matched.sub(/\r$/, ''), *pos]
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
self
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
end
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
##
|
|
3
|
+
# A TopLevel context is a representation of the contents of a single file
|
|
4
|
+
|
|
5
|
+
class RDoc::TopLevel < RDoc::Context
|
|
6
|
+
|
|
7
|
+
MARSHAL_VERSION = 0 # :nodoc:
|
|
8
|
+
|
|
9
|
+
##
|
|
10
|
+
# This TopLevel's File::Stat struct
|
|
11
|
+
|
|
12
|
+
attr_accessor :file_stat
|
|
13
|
+
|
|
14
|
+
##
|
|
15
|
+
# Relative name of this file
|
|
16
|
+
|
|
17
|
+
attr_accessor :relative_name
|
|
18
|
+
|
|
19
|
+
##
|
|
20
|
+
# Absolute name of this file
|
|
21
|
+
|
|
22
|
+
attr_accessor :absolute_name
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# All the classes or modules that were declared in
|
|
26
|
+
# this file. These are assigned to either +#classes_hash+
|
|
27
|
+
# or +#modules_hash+ once we know what they really are.
|
|
28
|
+
|
|
29
|
+
attr_reader :classes_or_modules
|
|
30
|
+
|
|
31
|
+
attr_accessor :diagram # :nodoc:
|
|
32
|
+
|
|
33
|
+
##
|
|
34
|
+
# The parser class that processed this file
|
|
35
|
+
|
|
36
|
+
attr_reader :parser
|
|
37
|
+
|
|
38
|
+
##
|
|
39
|
+
# Creates a new TopLevel for the file at +absolute_name+. If documentation
|
|
40
|
+
# is being generated outside the source dir +relative_name+ is relative to
|
|
41
|
+
# the source directory.
|
|
42
|
+
|
|
43
|
+
def initialize absolute_name, relative_name = absolute_name
|
|
44
|
+
super()
|
|
45
|
+
@name = nil
|
|
46
|
+
@absolute_name = absolute_name
|
|
47
|
+
@relative_name = relative_name
|
|
48
|
+
@file_stat = File.stat(absolute_name) rescue nil # HACK for testing
|
|
49
|
+
@diagram = nil
|
|
50
|
+
@parser = nil
|
|
51
|
+
|
|
52
|
+
@classes_or_modules = []
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def parser=(val)
|
|
56
|
+
@parser = val
|
|
57
|
+
@store.update_parser_of_file(absolute_name, val) if @store
|
|
58
|
+
@parser
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
##
|
|
62
|
+
# An RDoc::TopLevel is equal to another with the same relative_name
|
|
63
|
+
|
|
64
|
+
def == other
|
|
65
|
+
self.class === other and @relative_name == other.relative_name
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
alias eql? ==
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# Adds +an_alias+ to +Object+ instead of +self+.
|
|
72
|
+
|
|
73
|
+
def add_alias(an_alias)
|
|
74
|
+
object_class.record_location self
|
|
75
|
+
return an_alias unless @document_self
|
|
76
|
+
object_class.add_alias an_alias
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
##
|
|
80
|
+
# Adds +constant+ to +Object+ instead of +self+.
|
|
81
|
+
|
|
82
|
+
def add_constant constant
|
|
83
|
+
object_class.record_location self
|
|
84
|
+
return constant unless @document_self
|
|
85
|
+
object_class.add_constant constant
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# Adds +include+ to +Object+ instead of +self+.
|
|
90
|
+
|
|
91
|
+
def add_include(include)
|
|
92
|
+
object_class.record_location self
|
|
93
|
+
return include unless @document_self
|
|
94
|
+
object_class.add_include include
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
##
|
|
98
|
+
# Adds +method+ to +Object+ instead of +self+.
|
|
99
|
+
|
|
100
|
+
def add_method(method)
|
|
101
|
+
object_class.record_location self
|
|
102
|
+
return method unless @document_self
|
|
103
|
+
object_class.add_method method
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# Adds class or module +mod+. Used in the building phase
|
|
108
|
+
# by the Ruby parser.
|
|
109
|
+
|
|
110
|
+
def add_to_classes_or_modules mod
|
|
111
|
+
@classes_or_modules << mod
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
##
|
|
115
|
+
# Base name of this file
|
|
116
|
+
|
|
117
|
+
def base_name
|
|
118
|
+
File.basename @relative_name
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
alias name base_name
|
|
122
|
+
|
|
123
|
+
##
|
|
124
|
+
# Only a TopLevel that contains text file) will be displayed. See also
|
|
125
|
+
# RDoc::CodeObject#display?
|
|
126
|
+
|
|
127
|
+
def display?
|
|
128
|
+
text? and super
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
##
|
|
132
|
+
# See RDoc::TopLevel::find_class_or_module
|
|
133
|
+
#--
|
|
134
|
+
# TODO Why do we search through all classes/modules found, not just the
|
|
135
|
+
# ones of this instance?
|
|
136
|
+
|
|
137
|
+
def find_class_or_module name
|
|
138
|
+
@store.find_class_or_module name
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
##
|
|
142
|
+
# Finds a class or module named +symbol+
|
|
143
|
+
|
|
144
|
+
def find_local_symbol(symbol)
|
|
145
|
+
find_class_or_module(symbol) || super
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
##
|
|
149
|
+
# Finds a module or class with +name+
|
|
150
|
+
|
|
151
|
+
def find_module_named(name)
|
|
152
|
+
find_class_or_module(name)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
##
|
|
156
|
+
# Returns the relative name of this file
|
|
157
|
+
|
|
158
|
+
def full_name
|
|
159
|
+
@relative_name
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
##
|
|
163
|
+
# An RDoc::TopLevel has the same hash as another with the same
|
|
164
|
+
# relative_name
|
|
165
|
+
|
|
166
|
+
def hash
|
|
167
|
+
@relative_name.hash
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
##
|
|
171
|
+
# URL for this with a +prefix+
|
|
172
|
+
|
|
173
|
+
def http_url(prefix)
|
|
174
|
+
path = [prefix, @relative_name.tr('.', '_')]
|
|
175
|
+
|
|
176
|
+
File.join(*path.compact) + '.html'
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def inspect # :nodoc:
|
|
180
|
+
"#<%s:0x%x %p modules: %p classes: %p>" % [
|
|
181
|
+
self.class, object_id,
|
|
182
|
+
base_name,
|
|
183
|
+
@modules.map { |n,m| m },
|
|
184
|
+
@classes.map { |n,c| c }
|
|
185
|
+
]
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
##
|
|
189
|
+
# Time this file was last modified, if known
|
|
190
|
+
|
|
191
|
+
def last_modified
|
|
192
|
+
@file_stat ? file_stat.mtime : nil
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
##
|
|
196
|
+
# Dumps this TopLevel for use by ri. See also #marshal_load
|
|
197
|
+
|
|
198
|
+
def marshal_dump
|
|
199
|
+
[
|
|
200
|
+
MARSHAL_VERSION,
|
|
201
|
+
@relative_name,
|
|
202
|
+
@parser,
|
|
203
|
+
parse(@comment),
|
|
204
|
+
]
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
##
|
|
208
|
+
# Loads this TopLevel from +array+.
|
|
209
|
+
|
|
210
|
+
def marshal_load array # :nodoc:
|
|
211
|
+
initialize array[1]
|
|
212
|
+
|
|
213
|
+
@parser = array[2]
|
|
214
|
+
@comment = array[3]
|
|
215
|
+
|
|
216
|
+
@file_stat = nil
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
##
|
|
220
|
+
# Returns the NormalClass "Object", creating it if not found.
|
|
221
|
+
#
|
|
222
|
+
# Records +self+ as a location in "Object".
|
|
223
|
+
|
|
224
|
+
def object_class
|
|
225
|
+
@object_class ||= begin
|
|
226
|
+
oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object')
|
|
227
|
+
oc.record_location self
|
|
228
|
+
oc
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
##
|
|
233
|
+
# Base name of this file without the extension
|
|
234
|
+
|
|
235
|
+
def page_name
|
|
236
|
+
basename = File.basename @relative_name
|
|
237
|
+
basename =~ /\.(rb|rdoc|txt|md)$/i
|
|
238
|
+
|
|
239
|
+
$` || basename
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
##
|
|
243
|
+
# Path to this file for use with HTML generator output.
|
|
244
|
+
|
|
245
|
+
def path
|
|
246
|
+
http_url @store.rdoc.generator.file_dir
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def pretty_print q # :nodoc:
|
|
250
|
+
q.group 2, "[#{self.class}: ", "]" do
|
|
251
|
+
q.text "base name: #{base_name.inspect}"
|
|
252
|
+
q.breakable
|
|
253
|
+
|
|
254
|
+
items = @modules.map { |n,m| m }
|
|
255
|
+
items.concat @modules.map { |n,c| c }
|
|
256
|
+
q.seplist items do |mod| q.pp mod end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
##
|
|
261
|
+
# Search record used by RDoc::Generator::JsonIndex
|
|
262
|
+
|
|
263
|
+
def search_record
|
|
264
|
+
return unless @parser < RDoc::Parser::Text
|
|
265
|
+
|
|
266
|
+
[
|
|
267
|
+
page_name,
|
|
268
|
+
'',
|
|
269
|
+
page_name,
|
|
270
|
+
'',
|
|
271
|
+
path,
|
|
272
|
+
'',
|
|
273
|
+
snippet(@comment),
|
|
274
|
+
]
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
##
|
|
278
|
+
# Is this TopLevel from a text file instead of a source code file?
|
|
279
|
+
|
|
280
|
+
def text?
|
|
281
|
+
@parser and @parser.include? RDoc::Parser::Text
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def to_s # :nodoc:
|
|
285
|
+
"file #{full_name}"
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
end
|
|
289
|
+
|