123456789_123456789_123456789_123456789_123456789_

Class: RDoc::Parser::Simple

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Parser
Instance Chain:
self, Text, Parser
Inherits: Parser
  • Object
Defined in: lib/rdoc/parser/simple.rb

Overview

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

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(top_level, content, options, stats) ⇒ Simple

Prepare to parse a plain file

[ GitHub ]

  
# File 'lib/rdoc/parser/simple.rb', line 19

def initialize(top_level, content, options, stats)
  super

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

  content = ::RDoc::Text.expand_tabs(@content)
  @content, = preprocess.run_pre_processes(content, @top_level, 1, :simple)
end

Instance Attribute Details

#content (readonly)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/parser/simple.rb', line 14

attr_reader :content # :nodoc:

Instance Method Details

#remove_coding_comment(text)

Removes the encoding magic comment from text

[ GitHub ]

  
# File 'lib/rdoc/parser/simple.rb', line 43

def remove_coding_comment(text)
  text.sub(/\A# .*coding[=:].*$/, '')
end

#scan

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

[ GitHub ]

  
# File 'lib/rdoc/parser/simple.rb', line 31

def scan
  content = remove_coding_comment @content

  comment = Comment.new content, @top_level

  @top_level.comment = comment
  @top_level
end