Class: RDoc::Parser::Simple

Inherits:
Parser
  • Object
show all
Includes:
Text
Defined in:
lib/rdoc/parser/simple.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(top_level, content, options, stats) ⇒ Simple

Prepare to parse a plain file



19
20
21
22
23
24
25
26
# 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 ⇒ Object (readonly)

:nodoc:



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

def content
  @content
end

Instance Method Details

#remove_coding_comment(text) ⇒ Object

Removes the encoding magic comment from text



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

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

#scan ⇒ Object

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



31
32
33
34
35
36
37
38
# 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