rdoc 4.0.1 → 4.1.0.preview.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.

Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +1 -3
  5. data/{DEVELOPERS.rdoc → CONTRIBUTING.rdoc} +28 -3
  6. data/ExampleMarkdown.md +37 -0
  7. data/ExampleRDoc.rdoc +208 -0
  8. data/History.rdoc +81 -0
  9. data/Manifest.txt +11 -2
  10. data/README.rdoc +5 -5
  11. data/Rakefile +34 -4
  12. data/lib/rdoc.rb +4 -3
  13. data/lib/rdoc/any_method.rb +48 -4
  14. data/lib/rdoc/class_module.rb +16 -2
  15. data/lib/rdoc/code_object.rb +85 -24
  16. data/lib/rdoc/comment.rb +0 -3
  17. data/lib/rdoc/constant.rb +9 -1
  18. data/lib/rdoc/context.rb +20 -2
  19. data/lib/rdoc/cross_reference.rb +1 -1
  20. data/lib/rdoc/extend.rb +4 -112
  21. data/lib/rdoc/generator/darkfish.rb +46 -7
  22. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +4 -4
  23. data/lib/rdoc/generator/template/darkfish/_head.rhtml +14 -8
  24. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +4 -3
  25. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +3 -3
  26. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +3 -4
  27. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +4 -3
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +3 -4
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +3 -3
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +4 -4
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +9 -5
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -3
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +12 -7
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +5 -4
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +6 -7
  37. data/lib/rdoc/generator/template/darkfish/class.rhtml +36 -41
  38. data/lib/rdoc/generator/template/darkfish/fonts.css +167 -0
  39. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  40. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  41. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  42. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  43. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  44. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  45. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  46. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  47. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  48. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  49. data/lib/rdoc/generator/template/darkfish/index.rhtml +11 -7
  50. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +0 -15
  51. data/lib/rdoc/generator/template/darkfish/js/search.js +12 -4
  52. data/lib/rdoc/generator/template/darkfish/page.rhtml +9 -9
  53. data/lib/rdoc/generator/template/darkfish/rdoc.css +226 -241
  54. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +5 -5
  55. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +13 -6
  56. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +17 -14
  57. data/lib/rdoc/include.rb +4 -114
  58. data/lib/rdoc/known_classes.rb +1 -0
  59. data/lib/rdoc/markdown.kpeg +126 -117
  60. data/lib/rdoc/markdown.rb +404 -389
  61. data/lib/rdoc/markdown/literals_1_8.kpeg +1 -1
  62. data/lib/rdoc/markdown/literals_1_8.rb +15 -12
  63. data/lib/rdoc/markdown/literals_1_9.kpeg +1 -1
  64. data/lib/rdoc/markdown/literals_1_9.rb +15 -12
  65. data/lib/rdoc/markup.rb +10 -13
  66. data/lib/rdoc/markup/attribute_manager.rb +3 -2
  67. data/lib/rdoc/markup/formatter.rb +3 -3
  68. data/lib/rdoc/markup/heading.rb +13 -0
  69. data/lib/rdoc/markup/parser.rb +10 -3
  70. data/lib/rdoc/markup/pre_process.rb +1 -1
  71. data/lib/rdoc/markup/to_html.rb +46 -31
  72. data/lib/rdoc/markup/to_html_crossref.rb +3 -0
  73. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -1
  74. data/lib/rdoc/markup/to_markdown.rb +7 -5
  75. data/lib/rdoc/markup/verbatim.rb +1 -1
  76. data/lib/rdoc/method_attr.rb +13 -1
  77. data/lib/rdoc/mixin.rb +120 -0
  78. data/lib/rdoc/normal_class.rb +4 -0
  79. data/lib/rdoc/normal_module.rb +4 -0
  80. data/lib/rdoc/options.rb +42 -8
  81. data/lib/rdoc/parser.rb +4 -2
  82. data/lib/rdoc/parser/c.rb +13 -7
  83. data/lib/rdoc/parser/ruby.rb +683 -480
  84. data/lib/rdoc/rdoc.rb +4 -3
  85. data/lib/rdoc/ri/driver.rb +174 -103
  86. data/lib/rdoc/ri/paths.rb +6 -6
  87. data/lib/rdoc/ruby_lex.rb +125 -102
  88. data/lib/rdoc/ruby_token.rb +41 -40
  89. data/lib/rdoc/servlet.rb +16 -6
  90. data/lib/rdoc/stats.rb +61 -48
  91. data/lib/rdoc/store.rb +5 -3
  92. data/lib/rdoc/test_case.rb +39 -0
  93. data/lib/rdoc/tom_doc.rb +28 -4
  94. data/lib/rdoc/top_level.rb +2 -2
  95. data/test/test_rdoc_any_method.rb +104 -1
  96. data/test/test_rdoc_class_module.rb +9 -15
  97. data/test/test_rdoc_code_object.rb +133 -8
  98. data/test/test_rdoc_context.rb +17 -0
  99. data/test/test_rdoc_context_section.rb +0 -7
  100. data/test/test_rdoc_cross_reference.rb +4 -3
  101. data/test/test_rdoc_generator_darkfish.rb +61 -19
  102. data/test/test_rdoc_generator_json_index.rb +0 -11
  103. data/test/test_rdoc_generator_ri.rb +0 -8
  104. data/test/test_rdoc_markdown.rb +15 -12
  105. data/test/test_rdoc_markdown_test.rb +0 -7
  106. data/test/test_rdoc_markup_attribute_manager.rb +121 -0
  107. data/test/test_rdoc_markup_document.rb +0 -7
  108. data/test/test_rdoc_markup_formatter.rb +29 -3
  109. data/test/test_rdoc_markup_heading.rb +9 -0
  110. data/test/test_rdoc_markup_parser.rb +0 -7
  111. data/test/test_rdoc_markup_pre_process.rb +15 -3
  112. data/test/test_rdoc_markup_raw.rb +0 -7
  113. data/test/test_rdoc_markup_to_html.rb +50 -8
  114. data/test/test_rdoc_markup_to_html_crossref.rb +7 -0
  115. data/test/test_rdoc_markup_to_html_snippet.rb +4 -4
  116. data/test/test_rdoc_markup_to_markdown.rb +6 -0
  117. data/test/test_rdoc_method_attr.rb +8 -0
  118. data/test/test_rdoc_normal_class.rb +5 -0
  119. data/test/test_rdoc_normal_module.rb +5 -0
  120. data/test/test_rdoc_options.rb +61 -22
  121. data/test/test_rdoc_parser.rb +10 -0
  122. data/test/test_rdoc_parser_c.rb +17 -5
  123. data/test/test_rdoc_parser_changelog.rb +0 -7
  124. data/test/test_rdoc_parser_rd.rb +0 -7
  125. data/test/test_rdoc_parser_ruby.rb +305 -28
  126. data/test/test_rdoc_rd_block_parser.rb +0 -8
  127. data/test/test_rdoc_rd_inline_parser.rb +0 -1
  128. data/test/test_rdoc_rdoc.rb +27 -1
  129. data/test/test_rdoc_ri_driver.rb +19 -7
  130. data/test/test_rdoc_ruby_lex.rb +116 -9
  131. data/test/test_rdoc_rubygems_hook.rb +1 -1
  132. data/test/test_rdoc_servlet.rb +44 -6
  133. data/test/test_rdoc_stats.rb +161 -141
  134. data/test/test_rdoc_store.rb +11 -19
  135. data/test/test_rdoc_text.rb +0 -7
  136. data/test/test_rdoc_tom_doc.rb +44 -16
  137. data/test/xref_test_case.rb +2 -0
  138. metadata +28 -27
  139. metadata.gz.sig +0 -0
  140. data/test/test_attribute_manager.rb +0 -120
@@ -1,5 +1,5 @@
1
- <body>
2
- <nav id="metadata">
1
+ <body role="document">
2
+ <nav role="navigation">
3
3
  <%= render '_sidebar_navigation.rhtml' %>
4
4
 
5
5
  <%= render '_sidebar_search.rhtml' %>
@@ -10,9 +10,9 @@
10
10
  </div>
11
11
  </nav>
12
12
 
13
- <div id="documentation" class="description">
13
+ <main role="main">
14
14
  <h1>Not Found</h1>
15
15
 
16
- <p>The page <kbd><%=h path %></kbd> was not found
17
- </div>
16
+ <p><%= message %>
17
+ </main>
18
18
 
@@ -1,11 +1,19 @@
1
- <body>
2
- <nav id="metadata">
3
- <%= render '_sidebar_search.rhtml' %>
1
+ <body role="document">
2
+ <nav role="navigation">
3
+ <div id="project-navigation">
4
+ <div id="home-section" class="nav-section">
5
+ <h2>
6
+ <a href="<%= rel_prefix %>/" rel="home">Home</a>
7
+ </h2>
8
+ </div>
9
+
10
+ <%= render '_sidebar_search.rhtml' %>
11
+ </div>
4
12
 
5
13
  <%= render '_sidebar_installed.rhtml' %>
6
14
  </nav>
7
15
 
8
- <div id="documentation" class="description">
16
+ <main role="main">
9
17
  <h1>Local RDoc Documentation</h1>
10
18
 
11
19
  <p>Here you can browse local documentation from the ruby standard library and
@@ -51,6 +59,5 @@
51
59
  <% end %>
52
60
  </ul>
53
61
  <% end %>
54
-
55
- </div>
62
+ </main>
56
63
 
@@ -1,9 +1,10 @@
1
- <body class="indexpage">
2
- <h1><%= h @title %></h1>
1
+ <body id="top" class="table-of-contents">
2
+ <main role="main">
3
+ <h1 class="class"><%= h @title %></h1>
3
4
 
4
5
  <% simple_files = @files.select { |f| f.text? } %>
5
6
  <% unless simple_files.empty? then %>
6
- <h2>Pages</h2>
7
+ <h2 id="pages">Pages</h2>
7
8
  <ul>
8
9
  <% simple_files.sort.each do |file| %>
9
10
  <li class="file">
@@ -12,8 +13,7 @@
12
13
  # HACK table_of_contents should not exist on Document
13
14
  table = file.parse(file.comment).table_of_contents
14
15
  unless table.empty? then %>
15
- <img class="toc-toggle" src="images/transparent.png" alt="" title="toggle headings">
16
- <ul class="initially-hidden">
16
+ <ul>
17
17
  <% table.each do |heading| %>
18
18
  <li><a href="<%= file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a>
19
19
  <% end %>
@@ -24,7 +24,7 @@
24
24
  </ul>
25
25
  <% end %>
26
26
 
27
- <h2 id="classes">Classes/Modules</h2>
27
+ <h2 id="classes">Classes and Modules</h2>
28
28
  <ul>
29
29
  <% @modsort.each do |klass| %>
30
30
  <li class="<%= klass.type %>">
@@ -34,22 +34,25 @@
34
34
  table.concat klass.section_contents
35
35
 
36
36
  unless table.empty? then %>
37
- <img class="toc-toggle" src="images/transparent.png" alt="" title="toggle headings">
38
- <ul class="initially-hidden">
37
+ <ul>
39
38
  <% table.each do |item| %>
40
39
  <li><a href="<%= klass.path %>#<%= item.aref %>"><%= item.plain_html %></a>
41
40
  <% end %>
42
41
  </ul>
43
42
  <% end %>
44
43
  </li>
45
- <% end %>
44
+ <% end %>
46
45
  </ul>
47
46
 
48
47
  <h2 id="methods">Methods</h2>
49
48
  <ul>
50
- <% @store.all_classes_and_modules.map do |mod|
51
- mod.method_list
52
- end.flatten.sort.each do |method| %>
53
- <li class="method"><a href="<%= method.path %>"><%= method.pretty_name %> &mdash; <%= method.parent.full_name %></a>
54
- <% end %>
49
+ <% @store.all_classes_and_modules.map do |mod|
50
+ mod.method_list
51
+ end.flatten.sort.each do |method| %>
52
+ <li class="method">
53
+ <a href="<%= method.path %>"><%= h method.pretty_name %></a>
54
+ &mdash;
55
+ <span class="container"><%= method.parent.full_name %></span>
56
+ <% end %>
55
57
  </ul>
58
+ </main>
@@ -1,119 +1,9 @@
1
1
  ##
2
- # A Module include in a class with \#include
2
+ # A Module included in a class with \#include
3
+ #
4
+ # RDoc::Include.new 'Enumerable', 'comment ...'
3
5
 
4
- class RDoc::Include < RDoc::CodeObject
5
-
6
- ##
7
- # Name of included module
8
-
9
- attr_accessor :name
10
-
11
- ##
12
- # Creates a new Include for +name+ with +comment+
13
-
14
- def initialize(name, comment)
15
- super()
16
- @name = name
17
- self.comment = comment
18
- @module = nil # cache for module if found
19
- end
20
-
21
- ##
22
- # Includes are sorted by name
23
-
24
- def <=> other
25
- return unless self.class === other
26
-
27
- name <=> other.name
28
- end
29
-
30
- def == other # :nodoc:
31
- self.class === other and @name == other.name
32
- end
33
-
34
- alias eql? ==
35
-
36
- ##
37
- # Full name based on #module
38
-
39
- def full_name
40
- m = self.module
41
- RDoc::ClassModule === m ? m.full_name : @name
42
- end
43
-
44
- def hash # :nodoc:
45
- [@name, self.module].hash
46
- end
47
-
48
- def inspect # :nodoc:
49
- "#<%s:0x%x %s.include %s>" % [
50
- self.class,
51
- object_id,
52
- parent_name, @name,
53
- ]
54
- end
55
-
56
- ##
57
- # Attempts to locate the included module object. Returns the name if not
58
- # known.
59
- #
60
- # The scoping rules of Ruby to resolve the name of an included module are:
61
- # - first look into the children of the current context;
62
- # - if not found, look into the children of included modules,
63
- # in reverse inclusion order;
64
- # - if still not found, go up the hierarchy of names.
65
- #
66
- # This method has <code>O(n!)</code> behavior when the module calling
67
- # include is referencing nonexistent modules. Avoid calling #module until
68
- # after all the files are parsed. This behavior is due to ruby's constant
69
- # lookup behavior.
70
- #
71
- # As of the beginning of October, 2011, no gem includes nonexistent modules.
72
-
73
- def module
74
- return @module if @module
75
-
76
- # search the current context
77
- return @name unless parent
78
- full_name = parent.child_name(@name)
79
- @module = @store.modules_hash[full_name]
80
- return @module if @module
81
- return @name if @name =~ /^::/
82
-
83
- # search the includes before this one, in reverse order
84
- searched = parent.includes.take_while { |i| i != self }.reverse
85
- searched.each do |i|
86
- inc = i.module
87
- next if String === inc
88
- full_name = inc.child_name(@name)
89
- @module = @store.modules_hash[full_name]
90
- return @module if @module
91
- end
92
-
93
- # go up the hierarchy of names
94
- up = parent.parent
95
- while up
96
- full_name = up.child_name(@name)
97
- @module = @store.modules_hash[full_name]
98
- return @module if @module
99
- up = up.parent
100
- end
101
-
102
- @name
103
- end
104
-
105
- ##
106
- # Sets the store for this class or module and its contained code objects.
107
-
108
- def store= store
109
- super
110
-
111
- @file = @store.add_file @file.full_name if @file
112
- end
113
-
114
- def to_s # :nodoc:
115
- "include #@name in: #{parent}"
116
- end
6
+ class RDoc::Include < RDoc::Mixin
117
7
 
118
8
  end
119
9
 
@@ -62,6 +62,7 @@ module RDoc
62
62
  "rb_mDL" => "DL",
63
63
  "rb_mEnumerable" => "Enumerable",
64
64
  "rb_mErrno" => "Errno",
65
+ "rb_mFConst" => "File::Constants",
65
66
  "rb_mFileTest" => "FileTest",
66
67
  "rb_mGC" => "GC",
67
68
  "rb_mKernel" => "Kernel",
@@ -11,6 +11,16 @@
11
11
  # RDoc::Options@Saved+Options for instructions on setting up a `.doc_options`
12
12
  # file to store your project default.
13
13
  #
14
+ # ## Usage
15
+ #
16
+ # Here is a brief example of using this parse to read a markdown file by hand.
17
+ #
18
+ # data = File.read("README.md")
19
+ # formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
20
+ # html = RDoc::Markdown.parse(data).accept(@formatter)
21
+ #
22
+ # # do something with html
23
+ #
14
24
  # ## Extensions
15
25
  #
16
26
  # The following markdown extensions are supported by the parser, but not all
@@ -123,7 +133,6 @@
123
133
  # ## Limitations
124
134
  #
125
135
  # * Link titles are not used
126
- # * Image links are not generated correctly
127
136
  # * Footnotes are collapsed into a single paragraph
128
137
  #
129
138
  # ## Author
@@ -468,7 +477,7 @@ root = Doc
468
477
 
469
478
  Doc = BOM? Block*:a { RDoc::Markup::Document.new(*a.compact) }
470
479
 
471
- Block = BlankLine*
480
+ Block = @BlankLine*
472
481
  ( BlockQuote
473
482
  | Verbatim
474
483
  | CodeFence
@@ -484,33 +493,33 @@ Block = BlankLine*
484
493
  | Para
485
494
  | Plain )
486
495
 
487
- Para = NonindentSpace Inlines:a BlankLine+
496
+ Para = @NonindentSpace Inlines:a @BlankLine+
488
497
  { paragraph a }
489
498
 
490
499
  Plain = Inlines:a
491
500
  { paragraph a }
492
501
 
493
- AtxInline = !Newline !(Sp? /#*/ Sp Newline) Inline
502
+ AtxInline = !@Newline !(@Sp? /#*/ @Sp @Newline) Inline
494
503
 
495
504
  AtxStart = < /\#{1,6}/ >
496
505
  { text.length }
497
506
 
498
- AtxHeading = AtxStart:s Sp? AtxInline+:a (Sp? /#*/ Sp)? Newline
507
+ AtxHeading = AtxStart:s @Sp? AtxInline+:a (@Sp? /#*/ @Sp)? @Newline
499
508
  { RDoc::Markup::Heading.new(s, a.join) }
500
509
 
501
510
  SetextHeading = SetextHeading1 | SetextHeading2
502
511
 
503
- SetextBottom1 = /={3,}/ Newline
512
+ SetextBottom1 = /={3,}/ @Newline
504
513
 
505
- SetextBottom2 = /-{3,}/ Newline
514
+ SetextBottom2 = /-{3,}/ @Newline
506
515
 
507
- SetextHeading1 = &(RawLine SetextBottom1)
508
- StartList:a ( !Endline Inline:b { a << b } )+ Sp? Newline
516
+ SetextHeading1 = &(@RawLine SetextBottom1)
517
+ @StartList:a ( !@Endline Inline:b { a << b } )+ @Sp? @Newline
509
518
  SetextBottom1
510
519
  { RDoc::Markup::Heading.new(1, a.join) }
511
520
 
512
- SetextHeading2 = &(RawLine SetextBottom2)
513
- StartList:a ( !Endline Inline:b { a << b })+ Sp? Newline
521
+ SetextHeading2 = &(@RawLine SetextBottom2)
522
+ @StartList:a ( !@Endline Inline:b { a << b })+ @Sp? @Newline
514
523
  SetextBottom2
515
524
  { RDoc::Markup::Heading.new(2, a.join) }
516
525
 
@@ -519,44 +528,44 @@ Heading = SetextHeading | AtxHeading
519
528
  BlockQuote = BlockQuoteRaw:a
520
529
  { RDoc::Markup::BlockQuote.new(*a) }
521
530
 
522
- BlockQuoteRaw = StartList:a
531
+ BlockQuoteRaw = @StartList:a
523
532
  (( ">" " "? Line:l { a << l } )
524
- ( !">" !BlankLine Line:c { a << c } )*
525
- ( BlankLine:n { a << n } )*
533
+ ( !">" !@BlankLine Line:c { a << c } )*
534
+ ( @BlankLine:n { a << n } )*
526
535
  )+
527
536
  { inner_parse a.join }
528
537
 
529
- NonblankIndentedLine = !BlankLine IndentedLine
538
+ NonblankIndentedLine = !@BlankLine IndentedLine
530
539
 
531
- VerbatimChunk = BlankLine*:a
540
+ VerbatimChunk = @BlankLine*:a
532
541
  NonblankIndentedLine+:b
533
542
  { a.concat b }
534
543
 
535
544
  Verbatim = VerbatimChunk+:a
536
545
  { RDoc::Markup::Verbatim.new(*a.flatten) }
537
546
 
538
- HorizontalRule = NonindentSpace
539
- ( "*" Sp "*" Sp "*" (Sp "*")*
540
- | "-" Sp "-" Sp "-" (Sp "-")*
541
- | "_" Sp "_" Sp "_" (Sp "_")*)
542
- Sp Newline BlankLine+
547
+ HorizontalRule = @NonindentSpace
548
+ ( "*" @Sp "*" @Sp "*" (@Sp "*")*
549
+ | "-" @Sp "-" @Sp "-" (@Sp "-")*
550
+ | "_" @Sp "_" @Sp "_" (@Sp "_")*)
551
+ @Sp @Newline @BlankLine+
543
552
  { RDoc::Markup::Rule.new 1 }
544
553
 
545
- Bullet = !HorizontalRule NonindentSpace /[+*-]/ Spacechar+
554
+ Bullet = !HorizontalRule @NonindentSpace /[+*-]/ @Spacechar+
546
555
 
547
556
  BulletList = &Bullet (ListTight | ListLoose):a
548
557
  { RDoc::Markup::List.new(:BULLET, *a) }
549
558
 
550
559
  ListTight = ListItemTight+:a
551
- BlankLine* !(Bullet | Enumerator)
560
+ @BlankLine* !(Bullet | Enumerator)
552
561
  { a }
553
562
 
554
- ListLoose = StartList:a
555
- ( ListItem:b BlankLine* { a << b } )+
563
+ ListLoose = @StartList:a
564
+ ( ListItem:b @BlankLine* { a << b } )+
556
565
  { a }
557
566
 
558
567
  ListItem = ( Bullet | Enumerator )
559
- StartList:a
568
+ @StartList:a
560
569
  ListBlock:b { a << b }
561
570
  ( ListContinuationBlock:c { a.push(*c) } )*
562
571
  { list_item_from a }
@@ -564,28 +573,28 @@ ListItem = ( Bullet | Enumerator )
564
573
  ListItemTight =
565
574
  ( Bullet | Enumerator )
566
575
  ListBlock:a
567
- ( !BlankLine
576
+ ( !@BlankLine
568
577
  ListContinuationBlock:b { a.push(*b) } )*
569
578
  !ListContinuationBlock
570
579
  { list_item_from a }
571
580
 
572
- ListBlock = !BlankLine Line:a
581
+ ListBlock = !@BlankLine Line:a
573
582
  ListBlockLine*:c
574
583
  { [a, *c] }
575
584
 
576
- ListContinuationBlock = StartList:a
577
- ( BlankLine*
585
+ ListContinuationBlock = @StartList:a
586
+ ( @BlankLine*
578
587
  { a << "\n" } )
579
588
  ( Indent
580
589
  ListBlock:b { a.concat b } )+
581
590
  { a }
582
591
 
583
- Enumerator = NonindentSpace [0-9]+ "." Spacechar+
592
+ Enumerator = @NonindentSpace [0-9]+ "." @Spacechar+
584
593
 
585
594
  OrderedList = &Enumerator (ListTight | ListLoose):a
586
595
  { RDoc::Markup::List.new(:NUMBER, *a) }
587
596
 
588
- ListBlockLine = !BlankLine
597
+ ListBlockLine = !@BlankLine
589
598
  !( Indent? (Bullet | Enumerator) )
590
599
  !HorizontalRule
591
600
  OptionallyIndentedLine
@@ -761,7 +770,7 @@ HtmlBlockInTags = HtmlBlockAddress
761
770
  | HtmlBlockScript
762
771
 
763
772
  HtmlBlock = < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | HtmlUnclosed) >
764
- BlankLine+
773
+ @BlankLine+
765
774
  { if html? then
766
775
  RDoc::Markup::Raw.new text
767
776
  end }
@@ -847,19 +856,19 @@ StyleOpen = "<" Spnl ("style" | "STYLE") Spnl HtmlAttribute* ">"
847
856
  StyleClose = "<" Spnl "/" ("style" | "STYLE") Spnl ">"
848
857
  InStyleTags = StyleOpen (!StyleClose .)* StyleClose
849
858
  StyleBlock = < InStyleTags >
850
- BlankLine*
859
+ @BlankLine*
851
860
  { if css? then
852
861
  RDoc::Markup::Raw.new text
853
862
  end }
854
863
 
855
- Inlines = ( !Endline Inline:i { i }
856
- | Endline:c &Inline { c } )+:chunks Endline?
864
+ Inlines = ( !@Endline Inline:i { i }
865
+ | @Endline:c &Inline { c } )+:chunks @Endline?
857
866
  { chunks }
858
867
 
859
868
  Inline = Str
860
- | Endline
869
+ | @Endline
861
870
  | UlOrStarLine
862
- | Space
871
+ | @Space
863
872
  | Strong
864
873
  | Emph
865
874
  | Image
@@ -872,85 +881,85 @@ Inline = Str
872
881
  | EscapedChar
873
882
  | Symbol
874
883
 
875
- Space = Spacechar+ { " " }
884
+ Space = @Spacechar+ { " " }
876
885
 
877
- Str = StartList:a
878
- < NormalChar+ > { a = text }
886
+ Str = @StartList:a
887
+ < @NormalChar+ > { a = text }
879
888
  ( StrChunk:c { a << c } )* { a }
880
889
 
881
- StrChunk = < (NormalChar | /_+/ &Alphanumeric)+ > { text }
890
+ StrChunk = < (@NormalChar | /_+/ &Alphanumeric)+ > { text }
882
891
 
883
- EscapedChar = "\\" !Newline < /[:\\`|*_{}\[\]()#+.!><-]/ > { text }
892
+ EscapedChar = "\\" !@Newline < /[:\\`|*_{}\[\]()#+.!><-]/ > { text }
884
893
 
885
894
  Entity = ( HexEntity | DecEntity | CharEntity ):a { a }
886
895
 
887
- Endline = LineBreak | TerminalEndline | NormalEndline
896
+ Endline = @LineBreak | @TerminalEndline | @NormalEndline
888
897
 
889
- NormalEndline = Sp Newline !BlankLine !">" !AtxStart
890
- !(Line /={3,}|-{3,}=/ Newline)
898
+ NormalEndline = @Sp @Newline !@BlankLine !">" !AtxStart
899
+ !(Line /={3,}|-{3,}=/ @Newline)
891
900
  { "\n" }
892
901
 
893
- TerminalEndline = Sp Newline Eof
902
+ TerminalEndline = @Sp @Newline @Eof
894
903
 
895
- LineBreak = " " NormalEndline { RDoc::Markup::HardBreak.new }
904
+ LineBreak = " " @NormalEndline { RDoc::Markup::HardBreak.new }
896
905
 
897
- Symbol = < SpecialChar >
906
+ Symbol = < @SpecialChar >
898
907
  { text }
899
908
 
900
909
  # This keeps the parser from getting bogged down on long strings of '*' or '_',
901
910
  # or strings of '*' or '_' with space on each side:
902
911
  UlOrStarLine = (UlLine | StarLine):a { a }
903
912
  StarLine = < /\*{4,}/ > { text } |
904
- < Spacechar /\*+/ &Spacechar > { text }
913
+ < @Spacechar /\*+/ &@Spacechar > { text }
905
914
  UlLine = < /_{4,}/ > { text } |
906
- < Spacechar /_+/ &Spacechar > { text }
915
+ < @Spacechar /_+/ &@Spacechar > { text }
907
916
 
908
917
  Emph = EmphStar | EmphUl
909
918
 
910
- OneStarOpen = !StarLine "*" !Spacechar !Newline
911
- OneStarClose = !Spacechar !Newline Inline:a "*"
919
+ OneStarOpen = !StarLine "*" !@Spacechar !@Newline
920
+ OneStarClose = !@Spacechar !@Newline Inline:a "*"
912
921
  { a }
913
922
 
914
923
  EmphStar = OneStarOpen
915
- StartList:a
924
+ @StartList:a
916
925
  ( !OneStarClose Inline:l { a << l } )*
917
926
  OneStarClose:l { a << l }
918
927
  { emphasis a.join }
919
928
 
920
- OneUlOpen = !UlLine "_" !Spacechar !Newline
921
- OneUlClose = !Spacechar !Newline Inline:a "_" # !Alphanumeric # TODO check
929
+ OneUlOpen = !UlLine "_" !@Spacechar !@Newline
930
+ OneUlClose = !@Spacechar !@Newline Inline:a "_" # !Alphanumeric # TODO check
922
931
  { a }
923
932
 
924
933
  EmphUl = OneUlOpen
925
- StartList:a
934
+ @StartList:a
926
935
  ( !OneUlClose Inline:l { a << l } )*
927
936
  OneUlClose:l { a << l }
928
937
  { emphasis a.join }
929
938
 
930
939
  Strong = StrongStar | StrongUl
931
940
 
932
- TwoStarOpen = !StarLine "**" !Spacechar !Newline
933
- TwoStarClose = !Spacechar !Newline Inline:a "**" { a }
941
+ TwoStarOpen = !StarLine "**" !@Spacechar !@Newline
942
+ TwoStarClose = !@Spacechar !@Newline Inline:a "**" { a }
934
943
 
935
944
  StrongStar = TwoStarOpen
936
- StartList:a
945
+ @StartList:a
937
946
  ( !TwoStarClose Inline:l { a << l } )*
938
947
  TwoStarClose:l { a << l }
939
948
  { strong a.join }
940
949
 
941
- TwoUlOpen = !UlLine "__" !Spacechar !Newline
942
- TwoUlClose = !Spacechar !Newline Inline:a "__" # !Alphanumeric # TODO check
950
+ TwoUlOpen = !UlLine "__" !@Spacechar !@Newline
951
+ TwoUlClose = !@Spacechar !@Newline Inline:a "__" # !Alphanumeric # TODO check
943
952
  { a }
944
953
 
945
954
  StrongUl = TwoUlOpen
946
- StartList:a
955
+ @StartList:a
947
956
  ( !TwoUlClose Inline:i { a << i } )*
948
957
  TwoUlClose:l { a << l }
949
958
  { strong a.join }
950
959
 
951
- # TODO image link support
960
+ # TODO alt text support
952
961
  Image = "!" ( ExplicitLink | ReferenceLink ):a
953
- { a }
962
+ { "rdoc-image:#{a[/\[(.*)\]/, 1]}" }
954
963
 
955
964
  Link = ExplicitLink | ReferenceLink | AutoLink
956
965
 
@@ -962,7 +971,7 @@ ReferenceLinkDouble = Label:content < Spnl > !"[]" Label:label
962
971
  ReferenceLinkSingle = Label:content < (Spnl "[]")? >
963
972
  { link_to content, content, text }
964
973
 
965
- ExplicitLink = Label:l Spnl "(" Sp Source:s Spnl Title Sp ")"
974
+ ExplicitLink = Label:l Spnl "(" @Sp Source:s Spnl Title @Sp ")"
966
975
  { "{#{l}}[#{s}]" }
967
976
 
968
977
  Source = ( "<" < SourceContents > ">" | < SourceContents > )
@@ -974,27 +983,27 @@ SourceContents = ( ( !"(" !")" !">" Nonspacechar )+ | "(" SourceContents ")")*
974
983
  Title = ( TitleSingle | TitleDouble | "" ):a
975
984
  { a }
976
985
 
977
- TitleSingle = "'" ( !( "'" Sp ( ")" | Newline ) ) . )* "'"
986
+ TitleSingle = "'" ( !( "'" @Sp ( ")" | @Newline ) ) . )* "'"
978
987
 
979
- TitleDouble = "\"" ( !( "\"" Sp ( ")" | Newline ) ) . )* "\""
988
+ TitleDouble = "\"" ( !( "\"" @Sp ( ")" | @Newline ) ) . )* "\""
980
989
 
981
990
  AutoLink = AutoLinkUrl | AutoLinkEmail
982
991
 
983
- AutoLinkUrl = "<" < /[A-Za-z]+/ "://" ( !Newline !">" . )+ > ">"
992
+ AutoLinkUrl = "<" < /[A-Za-z]+/ "://" ( !@Newline !">" . )+ > ">"
984
993
  { text }
985
994
 
986
- AutoLinkEmail = "<" ("mailto:")? < /[\w+.\/!%~$-]+/i "@" ( !Newline !">" . )+ > ">"
995
+ AutoLinkEmail = "<" ("mailto:")? < /[\w+.\/!%~$-]+/i "@" ( !@Newline !">" . )+ > ">"
987
996
  { "mailto:#{text}" }
988
997
 
989
- Reference = NonindentSpace !"[]"
990
- Label:label ":" Spnl RefSrc:link RefTitle BlankLine+
998
+ Reference = @NonindentSpace !"[]"
999
+ Label:label ":" Spnl RefSrc:link RefTitle @BlankLine+
991
1000
  { # TODO use title
992
1001
  reference label, link
993
1002
  nil
994
1003
  }
995
1004
 
996
1005
  Label = "[" ( !"^" &{ notes? } | &. &{ !notes? } )
997
- StartList:a
1006
+ @StartList:a
998
1007
  ( !"]" Inline:l { a << l } )*
999
1008
  "]"
1000
1009
  { a.join.gsub(/\s+/, ' ') }
@@ -1005,11 +1014,11 @@ RefTitle = ( RefTitleSingle | RefTitleDouble | RefTitleParens | EmptyTitle )
1005
1014
 
1006
1015
  EmptyTitle = ""
1007
1016
 
1008
- RefTitleSingle = Spnl "'" < ( !( "'" Sp Newline | Newline ) . )* > "'" { text }
1017
+ RefTitleSingle = Spnl "'" < ( !( "'" @Sp @Newline | @Newline ) . )* > "'" { text }
1009
1018
 
1010
- RefTitleDouble = Spnl "\"" < ( !("\"" Sp Newline | Newline) . )* > "\"" { text }
1019
+ RefTitleDouble = Spnl "\"" < ( !("\"" @Sp @Newline | @Newline) . )* > "\"" { text }
1011
1020
 
1012
- RefTitleParens = Spnl "(" < ( !(")" Sp Newline | Newline) . )* > ")" { text }
1021
+ RefTitleParens = Spnl "(" < ( !(")" @Sp @Newline | @Newline) . )* > ")" { text }
1013
1022
 
1014
1023
  References = ( Reference | SkipBlock )*
1015
1024
 
@@ -1019,48 +1028,48 @@ Ticks3 = "```" !"`"
1019
1028
  Ticks4 = "````" !"`"
1020
1029
  Ticks5 = "`````" !"`"
1021
1030
 
1022
- Code = ( Ticks1 Sp < (
1031
+ Code = ( Ticks1 @Sp < (
1023
1032
  ( !"`" Nonspacechar )+ | !Ticks1 /`+/ |
1024
- !( Sp Ticks1 ) ( Spacechar | Newline !BlankLine )
1025
- )+ > Sp Ticks1 |
1026
- Ticks2 Sp < (
1033
+ !( @Sp Ticks1 ) ( @Spacechar | @Newline !@BlankLine )
1034
+ )+ > @Sp Ticks1 |
1035
+ Ticks2 @Sp < (
1027
1036
  ( !"`" Nonspacechar )+ |
1028
1037
  !Ticks2 /`+/ |
1029
- !( Sp Ticks2 ) ( Spacechar | Newline !BlankLine )
1030
- )+ > Sp Ticks2 |
1031
- Ticks3 Sp < (
1038
+ !( @Sp Ticks2 ) ( @Spacechar | @Newline !@BlankLine )
1039
+ )+ > @Sp Ticks2 |
1040
+ Ticks3 @Sp < (
1032
1041
  ( !"`" Nonspacechar )+ |
1033
1042
  !Ticks3 /`+/ |
1034
- !( Sp Ticks3 ) ( Spacechar | Newline !BlankLine )
1035
- )+ > Sp Ticks3 |
1036
- Ticks4 Sp < (
1043
+ !( @Sp Ticks3 ) ( @Spacechar | @Newline !@BlankLine )
1044
+ )+ > @Sp Ticks3 |
1045
+ Ticks4 @Sp < (
1037
1046
  ( !"`" Nonspacechar )+ |
1038
1047
  !Ticks4 /`+/ |
1039
- !( Sp Ticks4 ) ( Spacechar | Newline !BlankLine )
1040
- )+ > Sp Ticks4 |
1041
- Ticks5 Sp < (
1048
+ !( @Sp Ticks4 ) ( @Spacechar | @Newline !@BlankLine )
1049
+ )+ > @Sp Ticks4 |
1050
+ Ticks5 @Sp < (
1042
1051
  ( !"`" Nonspacechar )+ |
1043
1052
  !Ticks5 /`+/ |
1044
- !( Sp Ticks5 ) ( Spacechar | Newline !BlankLine )
1045
- )+ > Sp Ticks5
1053
+ !( @Sp Ticks5 ) ( @Spacechar | @Newline !@BlankLine )
1054
+ )+ > @Sp Ticks5
1046
1055
  )
1047
1056
  { "<code>#{text}</code>" }
1048
1057
 
1049
1058
  RawHtml = < (HtmlComment | HtmlBlockScript | HtmlTag) >
1050
1059
  { if html? then text else '' end }
1051
1060
 
1052
- BlankLine = Sp Newline { "\n" }
1061
+ BlankLine = @Sp @Newline { "\n" }
1053
1062
 
1054
1063
  Quoted = "\"" (!"\"" .)* "\"" | "'" (!"'" .)* "'"
1055
1064
  HtmlAttribute = (AlphanumericAscii | "-")+ Spnl ("=" Spnl (Quoted | (!">" Nonspacechar)+))? Spnl
1056
1065
  HtmlComment = "<!--" (!"-->" .)* "-->"
1057
1066
  HtmlTag = "<" Spnl "/"? AlphanumericAscii+ Spnl HtmlAttribute* "/"? Spnl ">"
1058
1067
  Eof = !.
1059
- Nonspacechar = !Spacechar !Newline .
1060
- Sp = Spacechar*
1061
- Spnl = Sp (Newline Sp)?
1062
- SpecialChar = /[*_`&\[\]()<!#\\'"]/ | ExtendedSpecialChar
1063
- NormalChar = !( SpecialChar | Spacechar | Newline ) .
1068
+ Nonspacechar = !@Spacechar !@Newline .
1069
+ Sp = @Spacechar*
1070
+ Spnl = @Sp (@Newline @Sp)?
1071
+ SpecialChar = /[*_`&\[\]()<!#\\'"]/ | @ExtendedSpecialChar
1072
+ NormalChar = !( @SpecialChar | @Spacechar | @Newline ) .
1064
1073
  Digit = [0-9]
1065
1074
 
1066
1075
  %literals = RDoc::Markdown::Literals
@@ -1092,15 +1101,15 @@ OptionallyIndentedLine = Indent? Line
1092
1101
  StartList = &.
1093
1102
  { [] }
1094
1103
 
1095
- Line = RawLine:a { a }
1096
- RawLine = ( < (!"\r" !"\n" .)* Newline >
1097
- | < .+ > Eof ) { text }
1104
+ Line = @RawLine:a { a }
1105
+ RawLine = ( < (!"\r" !"\n" .)* @Newline >
1106
+ | < .+ > @Eof ) { text }
1098
1107
 
1099
1108
  SkipBlock = HtmlBlock
1100
- | ( !"#" !SetextBottom1 !SetextBottom2 !BlankLine RawLine )+
1101
- BlankLine*
1102
- | BlankLine+
1103
- | RawLine
1109
+ | ( !"#" !SetextBottom1 !SetextBottom2 !@BlankLine @RawLine )+
1110
+ @BlankLine*
1111
+ | @BlankLine+
1112
+ | @RawLine
1104
1113
 
1105
1114
  # Syntax extensions
1106
1115
 
@@ -1110,13 +1119,13 @@ NoteReference = &{ notes? }
1110
1119
  RawNoteReference:ref
1111
1120
  { note_for ref }
1112
1121
 
1113
- RawNoteReference = "[^" < ( !Newline !"]" . )+ > "]" { text }
1122
+ RawNoteReference = "[^" < ( !@Newline !"]" . )+ > "]" { text }
1114
1123
 
1115
1124
  # TODO multiple paragraphs for a footnote
1116
1125
  Note = &{ notes? }
1117
- NonindentSpace RawNoteReference:ref ":" Sp
1118
- StartList:a
1119
- RawNoteBlock
1126
+ @NonindentSpace RawNoteReference:ref ":" @Sp
1127
+ @StartList:a
1128
+ RawNoteBlock:i { a.concat i }
1120
1129
  ( &Indent RawNoteBlock:i { a.concat i } )*
1121
1130
  { @footnotes[ref] = paragraph a
1122
1131
 
@@ -1125,7 +1134,7 @@ Note = &{ notes? }
1125
1134
 
1126
1135
  InlineNote = &{ notes? }
1127
1136
  "^["
1128
- StartList:a
1137
+ @StartList:a
1129
1138
  ( !"]" Inline:l { a << l } )+
1130
1139
  "]"
1131
1140
  {
@@ -1137,20 +1146,20 @@ InlineNote = &{ notes? }
1137
1146
 
1138
1147
  Notes = ( Note | SkipBlock )*
1139
1148
 
1140
- RawNoteBlock = StartList:a
1141
- ( !BlankLine OptionallyIndentedLine:l { a << l } )+
1142
- ( < BlankLine* > { a << text } )
1149
+ RawNoteBlock = @StartList:a
1150
+ ( !@BlankLine OptionallyIndentedLine:l { a << l } )+
1151
+ ( < @BlankLine* > { a << text } )
1143
1152
  { a }
1144
1153
 
1145
1154
  # Markdown extensions added by RDoc follow
1146
1155
 
1147
1156
  CodeFence = &{ github? }
1148
- Ticks3 (Sp StrChunk:format)? Spnl < (
1157
+ Ticks3 (@Sp StrChunk:format)? Spnl < (
1149
1158
  ( !"`" Nonspacechar )+ |
1150
1159
  !Ticks3 /`+/ |
1151
1160
  Spacechar |
1152
- Newline
1153
- )+ > Ticks3 Sp Newline*
1161
+ @Newline
1162
+ )+ > Ticks3 @Sp @Newline*
1154
1163
  { verbatim = RDoc::Markup::Verbatim.new text
1155
1164
  verbatim.format = format.intern if format
1156
1165
  verbatim
@@ -1173,8 +1182,8 @@ DefinitionListItem = ( DefinitionListLabel+ ):label
1173
1182
  list_items
1174
1183
  }
1175
1184
 
1176
- DefinitionListLabel = StrChunk:label Sp Newline
1185
+ DefinitionListLabel = StrChunk:label @Sp @Newline
1177
1186
  { label }
1178
1187
 
1179
- DefinitionListDefinition = NonindentSpace ":" Space Inlines:a BlankLine+
1188
+ DefinitionListDefinition = @NonindentSpace ":" @Space Inlines:a @BlankLine+
1180
1189
  { paragraph a }