123456789_123456789_123456789_123456789_123456789_

Class: RDoc::Parser::Simple

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

Overview

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

Class Attribute Summary

::RDoc::Parser - Inherited

.parsers

An Array of arrays that maps file extension (or name) regular expressions to parser classes that will parse matching filenames.

Class Method Summary

::RDoc::Parser - Inherited

.alias_extension

::RDoc::Alias an extension to another extension.

.binary?

Determines if the file is a “binary” file which basically means it has content that an ::RDoc::RDoc parser shouldn’t try to consume.

.can_parse

Return a parser that can handle a particular extension.

.can_parse_by_name

Returns a parser that can handle the extension for #file_name.

.check_modeline

Returns the file type from the modeline in #file_name

.for

Finds and instantiates the correct parser for the given #file_name and #content.

.new

Creates a new ::RDoc::Parser storing top_level, #file_name, #content, options and stats in instance variables.

.parse_files_matching

Record which file types this parser can understand.

.remove_modeline

Removes an emacs-style modeline from the first line of the document.

.use_markup

If there is a markup: parser_name comment at the front of the file, use it to determine the parser.

.zip?

Checks if file is a zip file in disguise.

Instance Attribute Summary

::RDoc::Parser - Inherited

#file_name

The name of the file being parsed.

Instance Method Summary

::RDoc::Parser - Inherited

#handle_tab_width

Normalizes tabs in body

Constructor Details

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

Prepare to parse a plain file

[ GitHub ]

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

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

  preprocess = RDoc::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 12

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 41

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 29

def scan
  content = remove_coding_comment @content

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

  @top_level.comment = comment
  @top_level
end