Class: RDoc::Parser::Simple
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::RDoc::Parser
|
|
Instance Chain:
self,
Text ,
::RDoc::Parser
|
|
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
-
.new(top_level, file_name, content, options, stats) ⇒ Simple
constructor
Prepare to parse a plain file.
::RDoc::Parser
- Inherited
.alias_extension |
|
.binary? | Determines if the file is a “binary” file which basically means it has content that an |
.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 |
.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 |
.zip? | Checks if |
Instance Attribute Summary
- #content readonly Internal use only
::RDoc::Parser
- Inherited
#file_name | The name of the file being parsed. |
Instance Method Summary
-
#remove_coding_comment(text)
Removes the encoding magic comment from
text
-
#remove_private_comment(comment)
Removes private comments.
-
#scan
Extract the file contents and attach them to the
::RDoc::TopLevel
as a comment.
Constructor Details
.new(top_level, file_name, content, options, stats) ⇒ Simple
Prepare to parse a plain file
Instance Attribute Details
#content (readonly)
# 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
# File 'lib/rdoc/parser/simple.rb', line 41
def remove_coding_comment text text.sub(/\A# .*coding[=:].*$/, '') end
#remove_private_comment(comment)
Removes private comments.
Unlike 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.
#scan
Extract the file contents and attach them to the ::RDoc::TopLevel
as a comment
# File 'lib/rdoc/parser/simple.rb', line 28
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