Class: RWEB::Generator
Overview
The core of document generation is this Generator class, an abstract class that sets the footprint and makes sure that any implementing class has all required methods covered. Generators must provide all of the methods with proper semantics outlined in each method’s documentation.
Any state changes in the documentation (like the transition from code block to document block) must be handled by identifying the state changes through methods.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#directives ⇒ Object
readonly
Returns the value of attribute directives.
-
#docs ⇒ Object
readonly
Returns the value of attribute docs.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Instance Method Summary collapse
-
#code(chunk) ⇒ Object
This method gets called to perform any transformations on code chunks.
-
#doc(chunk) ⇒ Object
This method gets called to perform any transformations on documentation chunks.
-
#footer ⇒ Object
This method gets called at the end of the document for closing document sequences: e.g.
-
#header(title) ⇒ Object
This method gets called at the beginning of the document for initialization of the document format: e.g.
-
#initialize(docs, directives) ⇒ Generator
constructor
This method gets the array of documentation/code chunks and the block of detected directives.
Constructor Details
#initialize(docs, directives) ⇒ Generator
This method gets the array of documentation/code chunks and the block of detected directives. Any derived class must ensure that docs and directives are appropriately passed up the chain to this implementation. Too, any derived class must ensure that an @style member is set to the appropriate documentation style (as per the “style” keyword in directives).
321 322 323 324 |
# File 'lib/rweb.rb', line 321 def initialize(docs, directives) @docs = docs @directives = directives end |
Instance Attribute Details
#directives ⇒ Object (readonly)
Returns the value of attribute directives.
325 326 327 |
# File 'lib/rweb.rb', line 325 def directives @directives end |
#docs ⇒ Object (readonly)
Returns the value of attribute docs.
325 326 327 |
# File 'lib/rweb.rb', line 325 def docs @docs end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
325 326 327 |
# File 'lib/rweb.rb', line 325 def style @style end |
Instance Method Details
#code(chunk) ⇒ Object
This method gets called to perform any transformations on code chunks. For example code can be syntax-highlighted.
342 343 344 |
# File 'lib/rweb.rb', line 342 def code(chunk) raise NotImplementedError, "#{self.class.name}#code is an abstract method." end |
#doc(chunk) ⇒ Object
This method gets called to perform any transformations on documentation chunks. For example Markdown-formatted plaintext might get run through BlueCloth to get turned into proper HTML here.
336 337 338 |
# File 'lib/rweb.rb', line 336 def doc(chunk) raise NotImplementedError, "#{self.class.name}#doc is an abstract method." end |
#footer ⇒ Object
This method gets called at the end of the document for closing document sequences: e.g. XHTML’s </html> and </body> tags.
348 349 350 |
# File 'lib/rweb.rb', line 348 def raise NotImplementedError, "#{self.class.name}#footer is an abstract method." end |
#header(title) ⇒ Object
This method gets called at the beginning of the document for initialization of the document format: e.g. XHTML’s <html>, <head> and <body> tags.
329 330 331 |
# File 'lib/rweb.rb', line 329 def header(title) raise NotImplementedError, "#{self.class.name}#header is an abstract method." end |