Class: Decode::Language::Generic
- Inherits:
-
Object
- Object
- Decode::Language::Generic
- Defined in:
- lib/decode/language/generic.rb
Overview
Represents a generic language implementation that can be extended for specific languages.
Direct Known Subclasses
Constant Summary collapse
- EXTENSIONS =
[]
- TAGS =
Comment::Tags.build do || ["attribute"] = Comment::Attribute ["parameter"] = Comment::Parameter ["option"] = Comment::Option ["yields"] = Comment::Yields ["returns"] = Comment::Returns ["raises"] = Comment::Raises ["throws"] = Comment::Throws ["deprecated"] = Comment::Pragma ["asynchronous"] = Comment::Pragma ["public"] = Comment::Pragma ["private"] = Comment::Pragma ["example"] = Comment::Example end
Instance Attribute Summary collapse
-
#extensions ⇒ Object
readonly
The file extensions this language supports.
-
#name ⇒ Object
readonly
The name of this language.
-
#tags ⇒ Object
readonly
The comment tags this language recognizes.
-
#The language name.(languagename.) ⇒ Object
readonly
The name of this language.
-
#The supported file extensions.(supportedfileextensions.) ⇒ Object
readonly
The file extensions this language supports.
Instance Method Summary collapse
-
#code_for(text, index, relative_to: nil) ⇒ Object
Generate a code representation with syntax highlighting and link resolution.
-
#definitions_for(source, &block) ⇒ Object
Parse the input yielding definitions.
-
#initialize(name, extensions: self.class::EXTENSIONS, tags: self.class::TAGS) ⇒ Generic
constructor
Initialize a new generic language.
-
#names ⇒ Object
Get all names for this language.
-
#parser ⇒ Object
Get the parser for this language.
-
#reference_for(identifier) ⇒ Object
Generate a language-specific reference.
-
#segments_for(source, &block) ⇒ Object
Parse the input yielding segments.
-
#The tag definitions.=(tagdefinitions. = (value)) ⇒ Object
The comment tags this language recognizes.
Constructor Details
#initialize(name, extensions: self.class::EXTENSIONS, tags: self.class::TAGS) ⇒ Generic
Initialize a new generic language.
38 39 40 41 42 |
# File 'lib/decode/language/generic.rb', line 38 def initialize(name, extensions: self.class::EXTENSIONS, tags: self.class::TAGS) @name = name @extensions = extensions = end |
Instance Attribute Details
#extensions ⇒ Object (readonly)
The file extensions this language supports.
56 57 58 |
# File 'lib/decode/language/generic.rb', line 56 def extensions @extensions end |
#name ⇒ Object (readonly)
The name of this language.
46 47 48 |
# File 'lib/decode/language/generic.rb', line 46 def name @name end |
#tags ⇒ Object (readonly)
The comment tags this language recognizes.
60 61 62 |
# File 'lib/decode/language/generic.rb', line 60 def end |
#The language name.(languagename.) ⇒ Object (readonly)
The name of this language.
46 |
# File 'lib/decode/language/generic.rb', line 46 attr :name |
#The supported file extensions.(supportedfileextensions.) ⇒ Object (readonly)
The file extensions this language supports.
56 |
# File 'lib/decode/language/generic.rb', line 56 attr :extensions |
Instance Method Details
#code_for(text, index, relative_to: nil) ⇒ Object
Generate a code representation with syntax highlighting and link resolution.
103 104 105 |
# File 'lib/decode/language/generic.rb', line 103 def code_for(text, index, relative_to: nil) raise NotImplementedError, "Code generation is not implemented for #{self.class}!" end |
#definitions_for(source, &block) ⇒ Object
Parse the input yielding definitions.
80 81 82 83 84 |
# File 'lib/decode/language/generic.rb', line 80 def definitions_for(source, &block) if parser = self.parser parser.definitions_for(source, &block) end end |
#names ⇒ Object
Get all names for this language.
50 51 52 |
# File 'lib/decode/language/generic.rb', line 50 def names [@name] end |
#parser ⇒ Object
Get the parser for this language.
71 72 73 |
# File 'lib/decode/language/generic.rb', line 71 def parser nil end |
#reference_for(identifier) ⇒ Object
Generate a language-specific reference.
65 66 67 |
# File 'lib/decode/language/generic.rb', line 65 def reference_for(identifier) Reference.new(identifier, self) end |
#segments_for(source, &block) ⇒ Object
Parse the input yielding segments. Segments are constructed from a block of top level comments followed by a block of code.
92 93 94 95 96 |
# File 'lib/decode/language/generic.rb', line 92 def segments_for(source, &block) if parser = self.parser parser.segments_for(source, &block) end end |
#The tag definitions.=(tagdefinitions. = (value)) ⇒ Object
The comment tags this language recognizes.
60 |
# File 'lib/decode/language/generic.rb', line 60 attr :tags |