### Home Classes Methods

### In Files

- lib/rdoc/parser/simple.rb

### Parent

RDoc::Parser

### Methods

- ::new
- #remove_coding_comment
- #remove_private_comment
- #scan

### Included Modules

- RDoc::Parser::Text

### Files

- CONTRIBUTING.rdoc
- CVE-2013-0256.rdoc
- ExampleRDoc.rdoc
- LICENSE.rdoc
- Manifest.txt
- README.rdoc
- RI.rdoc
- Rakefile
- TODO.rdoc

### Class/Module Index

Quicksearch

- RDoc
- RDoc::Alias
- RDoc::AnonClass
- RDoc::AnyMethod
- RDoc::Attr
- RDoc::ClassModule
- RDoc::CodeObject
- RDoc::Comment
- RDoc::Constant
- RDoc::Context
- RDoc::Context::Section
- RDoc::CrossReference
- RDoc::ERBIO
- RDoc::ERBPartial
- RDoc::Encoding
- RDoc::Error
- RDoc::Extend
- RDoc::Gauntlet
- RDoc::Generator
- RDoc::Generator::Darkfish
- RDoc::Generator::JsonIndex
- RDoc::Generator::Markup
- RDoc::Generator::RI
- RDoc::GhostMethod
- RDoc::Include
- RDoc::Markdown
- RDoc::Markdown::Literals
- RDoc::Markup
- RDoc::Markup::AttrChanger
- RDoc::Markup::AttrSpan
- RDoc::Markup::AttributeManager
- RDoc::Markup::Attributes
- RDoc::Markup::BlankLine
- RDoc::Markup::BlockQuote
- RDoc::Markup::Document
- RDoc::Markup::Formatter
- RDoc::Markup::FormatterTestCase
- RDoc::Markup::HardBreak
- RDoc::Markup::Include
- RDoc::Markup::IndentedParagraph
- RDoc::Markup::List
- RDoc::Markup::ListItem
- RDoc::Markup::Paragraph
- RDoc::Markup::Parser
- RDoc::Markup::Parser::Error
- RDoc::Markup::Parser::ParseError
- RDoc::Markup::PreProcess
- RDoc::Markup::Raw
- RDoc::Markup::Rule
- RDoc::Markup::Special
- RDoc::Markup::TextFormatterTestCase
- RDoc::Markup::ToAnsi
- RDoc::Markup::ToBs
- RDoc::Markup::ToHtml
- RDoc::Markup::ToHtmlCrossref
- RDoc::Markup::ToHtmlSnippet
- RDoc::Markup::ToJoinedParagraph
- RDoc::Markup::ToLabel
- RDoc::Markup::ToMarkdown
- RDoc::Markup::ToRdoc
- RDoc::Markup::ToTableOfContents
- RDoc::Markup::ToTest
- RDoc::Markup::ToTtOnly
- RDoc::Markup::Verbatim
- RDoc::MetaMethod
- RDoc::MethodAttr
- RDoc::Mixin
- RDoc::NormalClass
- RDoc::NormalModule
- RDoc::Options
- RDoc::Parser
- RDoc::Parser::C
- RDoc::Parser::ChangeLog
- RDoc::Parser::Markdown
- RDoc::Parser::RD
- RDoc::Parser::Ruby
- RDoc::Parser::RubyTools
- RDoc::Parser::Simple
- RDoc::Parser::Text
- RDoc::RD
- RDoc::RD::BlockParser
- RDoc::RD::Inline
- RDoc::RD::InlineParser
- RDoc::RDoc
- RDoc::RI
- RDoc::RI::Driver
- RDoc::RI::Driver::Error
- RDoc::RI::Driver::NotFoundError
- RDoc::RI::Error
- RDoc::RI::Paths
- RDoc::Require
- RDoc::RubyLex
- RDoc::RubyLex::Error
- RDoc::RubyToken
- RDoc::RubygemsHook
- RDoc::Servlet
- RDoc::SingleClass
- RDoc::Stats
- RDoc::Stats::Normal
- RDoc::Stats::Quiet
- RDoc::Stats::Verbose
- RDoc::Store
- RDoc::Store::Error
- RDoc::Store::MissingFileError
- RDoc::Task
- RDoc::Task
- RDoc::TestCase
- RDoc::TokenStream
- RDoc::TomDoc
- RDoc::TopLevel
- Object

No matching classes.

# RDoc::Parser::Simple

Parse a non-source file. We basically take the whole thing as one big comment.

### Public Class Methods

new(top_level, file_name, content, options, stats) click to toggle source

Prepare to parse a plain file

    # File lib/rdoc/parser/simple.rb, line 16
    def initialize(top_level, file_name, content, options, stats)
      super

      preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include

      preprocess.handle @content, @top_level
    end

### Public Instance Methods

remove_coding_comment(text) click to toggle source

Removes the encoding magic comment from `text`

    # File lib/rdoc/parser/simple.rb, line 40
    def remove_coding_comment text
      text.sub(/\A# .*coding[=:].*$/, '')
    end

remove_private_comment(comment) click to toggle source

Removes private comments.

Unlike RDoc::Comment#remove_private this implementation only looks for two dashes at the beginning of the line. Three or more dashes are considered to be a rule and ignored.

    # File lib/rdoc/parser/simple.rb, line 51
    def remove_private_comment comment
      # Workaround for gsub encoding for Ruby 1.9.2 and earlier
      empty = ''
      empty.force_encoding comment.encoding if Object.const_defined? :Encoding

      comment = comment.gsub(%^--\n.*?^\+\+\n?%, empty)
      comment.sub(%^--\n.*%, empty)
    end

scan() click to toggle source

Extract the file contents and attach them to the TopLevel as a comment

    # File lib/rdoc/parser/simple.rb, line 27
    def scan
      comment = remove_coding_comment @content
      comment = remove_private_comment comment

      comment = RDoc::Comment.new comment, @top_level

      @top_level.comment = comment
      @top_level
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.