diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-18 23:33:36 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-18 23:33:36 +0000 |
commit | df7dac9174a31e71b58be6184e23bfe6b742a494 (patch) | |
tree | 885edf624f0e8f37014b0d937340ac1c372a0066 /lib/rdoc/tom_doc.rb | |
parent | fed428007c015ac3b7f4586f2491517fafffa030 (diff) |
* lib/rdoc: Update to RDoc 4.1.0.preview.1
RDoc 4.1.0 contains a number of enhancements including a new default
style and accessibility support. You can see the changelog here:
https://github.com/rdoc/rdoc/blob/v4.1.0.preview.1/History.rdoc
* test/rdoc: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/tom_doc.rb')
-rw-r--r-- | lib/rdoc/tom_doc.rb | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/rdoc/tom_doc.rb b/lib/rdoc/tom_doc.rb index 4cee0ce182..2b62243525 100644 --- a/lib/rdoc/tom_doc.rb +++ b/lib/rdoc/tom_doc.rb @@ -129,7 +129,8 @@ class RDoc::TomDoc < RDoc::Markup::Parser def initialize super - @section = nil + @section = nil + @seen_returns = false end # Internal: Builds a heading from the token stream @@ -176,9 +177,17 @@ class RDoc::TomDoc < RDoc::Markup::Parser until @tokens.empty? do type, data, = get - if type == :TEXT then + case type + when :TEXT then + @section = 'Returns' if data =~ /\AReturns/ + paragraph << data - skip :NEWLINE + when :NEWLINE then + if :TEXT == peek_token[0] then + paragraph << ' ' + else + break + end else unget break @@ -190,6 +199,21 @@ class RDoc::TomDoc < RDoc::Markup::Parser paragraph end + ## + # Detects a section change to "Returns" and adds a heading + + def parse_text parent, indent # :nodoc: + paragraph = build_paragraph indent + + if false == @seen_returns and 'Returns' == @section then + @seen_returns = true + parent << RDoc::Markup::Heading.new(3, 'Returns') + parent << RDoc::Markup::BlankLine.new + end + + parent << paragraph + end + # Internal: Turns text into an Array of tokens # # text - A String containing TomDoc-format text. |