Class: WsdlMapper::Generation::YardDocFormatter
- Inherits:
-
Object
- Object
- WsdlMapper::Generation::YardDocFormatter
- Defined in:
- lib/wsdl_mapper/generation/yard_doc_formatter.rb
Instance Method Summary collapse
- #attribute!(name, type, doc, &block) ⇒ Object
- #blank_line ⇒ Object
- #class_doc(type) ⇒ Object
- #dec_indent ⇒ Object
- #inc_indent ⇒ Object
-
#initialize(formatter) ⇒ YardDocFormatter
constructor
A new instance of YardDocFormatter.
- #line(line) ⇒ Object
- #option(param_name, type, name, text = nil) ⇒ Object
- #param(name, type, text = nil) ⇒ Object
- #params(*params) ⇒ Object
- #tag(tag, text) ⇒ Object
- #text(text) ⇒ Object
- #type_tag(tag_name, type, text = nil) ⇒ Object
Constructor Details
#initialize(formatter) ⇒ YardDocFormatter
Returns a new instance of YardDocFormatter.
4 5 6 7 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 4 def initialize(formatter) @formatter = formatter @i = 0 end |
Instance Method Details
#attribute!(name, type, doc, &block) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 65 def attribute!(name, type, doc, &block) tag '!attribute', name inc_indent text doc if doc type_tag 'return', type block.call if block_given? dec_indent end |
#blank_line ⇒ Object
50 51 52 53 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 50 def blank_line @formatter.blank_comment self end |
#class_doc(type) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 27 def class_doc(type) if type.documentation.present? text type.documentation.default blank_line end return unless type.name tag :xml_name, type.name.name if type.name.ns tag :xml_namespace, type.name.ns end end |
#dec_indent ⇒ Object
22 23 24 25 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 22 def dec_indent @i -= 1 self end |
#inc_indent ⇒ Object
17 18 19 20 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 17 def inc_indent @i += 1 self end |
#line(line) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 9 def line(line) buf = '# ' buf << ' ' * @i buf << strip(line) @formatter.statement buf self end |
#option(param_name, type, name, text = nil) ⇒ Object
74 75 76 77 78 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 74 def option(param_name, type, name, text = nil) buf = "@option #{param_name} [#{type}] :#{name}" buf << " #{text}" if text line buf end |
#param(name, type, text = nil) ⇒ Object
80 81 82 83 84 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 80 def param(name, type, text = nil) buf = "@param #{name} [#{type}]" buf << " #{text}" if text line buf end |
#params(*params) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 86 def params(*params) return if params.empty? params.each do |p| param(*p) end blank_line end |
#tag(tag, text) ⇒ Object
55 56 57 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 55 def tag(tag, text) line "@#{tag} #{text}" end |
#text(text) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 41 def text(text) lines = process(text).strip.split("\n") lines.each do |l| line l end self end |
#type_tag(tag_name, type, text = nil) ⇒ Object
59 60 61 62 63 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 59 def type_tag(tag_name, type, text = nil) buf = "@#{tag_name} [#{type}]" buf << " #{text}" if text line buf end |