Class: RdocExplainer
- Inherits:
-
Object
- Object
- RdocExplainer
- Includes:
- Depix
- Defined in:
- lib/depix/struct_explainer.rb
Overview
Generates an RDoc description of the DPX structs from the structs.rb file
Constant Summary collapse
- TPL =
<<eof = DPX header structure description DPX metadata gets returned as a Depix::DPX object with nested properties. meta.file.magic # => "SDPX" == Metadata structure %s eof
Constants included from Depix
Depix::COLORIMETRIC, Depix::COMPONENT_TYPE, Depix::CompactFilmInfo, Depix::CompactInfo, Depix::CompactOrientation, Depix::CompactTelevision, Depix::VERSION
Instance Attribute Summary collapse
-
#attr_template ⇒ Object
:nodoc:.
-
#io ⇒ Object
:nodoc:.
-
#struct_template ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #explain_attr(padding, e) ⇒ Object
-
#explain_struct(struct, padding = '') ⇒ Object
:nodoc:.
- #get_rdoc_for(struct) ⇒ Object
-
#initialize ⇒ RdocExplainer
constructor
A new instance of RdocExplainer.
Methods included from Depix
describe_brief, describe_file, from_file, from_string
Constructor Details
#initialize ⇒ RdocExplainer
Returns a new instance of RdocExplainer.
17 18 19 20 21 22 23 |
# File 'lib/depix/struct_explainer.rb', line 17 def initialize @padding = ' ' @attr_template = "%s* <tt>%s</tt> %s" @struct_template = "%s* <tt>%s</tt> %s:" @array_template = "%s* <tt>%s</tt> %s:" end |
Instance Attribute Details
#attr_template ⇒ Object
:nodoc:
3 4 5 |
# File 'lib/depix/struct_explainer.rb', line 3 def attr_template @attr_template end |
#io ⇒ Object
:nodoc:
3 4 5 |
# File 'lib/depix/struct_explainer.rb', line 3 def io @io end |
#struct_template ⇒ Object
:nodoc:
3 4 5 |
# File 'lib/depix/struct_explainer.rb', line 3 def struct_template @struct_template end |
Instance Method Details
#explain_attr(padding, e) ⇒ Object
55 56 57 58 |
# File 'lib/depix/struct_explainer.rb', line 55 def explain_attr(padding, e) type_name = e.rtype ? "(#{e.rtype})" : nil @io.puts( @attr_template % [padding, e.name, e.explain]) end |
#explain_struct(struct, padding = '') ⇒ Object
:nodoc:
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/depix/struct_explainer.rb', line 33 def explain_struct(struct, padding = '') #:nodoc: struct.fields.each do | e | if e.is_a?(InnerField) @io.puts( @struct_template % [padding, e.name, e.explain]) explain_struct(e.rtype, padding + @padding) elsif e.is_a?(ArrayField) @io.puts( @array_template % [padding, e.name, e.explain]) inner_struct = e.members[0] if inner_struct.is_a?(InnerField) explain_struct(inner_struct.rtype, padding + @padding) end else explain_attr(padding, e) end end end |
#get_rdoc_for(struct) ⇒ Object
25 26 27 28 29 |
# File 'lib/depix/struct_explainer.rb', line 25 def get_rdoc_for(struct) @io = StringIO.new explain_struct(struct) TPL % @io.string end |