Class: WsdlMapper::Generation::YardDocFormatter
- Inherits:
-
Object
- Object
- WsdlMapper::Generation::YardDocFormatter
- Defined in:
- lib/wsdl_mapper/generation/yard_doc_formatter.rb
Instance Method Summary (collapse)
- - (Object) attribute!(name, type, doc, &block)
- - (Object) blank_line
- - (Object) class_doc(type)
- - (Object) dec_indent
- - (Object) inc_indent
-
- (YardDocFormatter) initialize(formatter)
constructor
A new instance of YardDocFormatter.
- - (Object) 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)
Constructor Details
- (YardDocFormatter) initialize(formatter)
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
- (Object) attribute!(name, type, doc, &block)
63 64 65 66 67 68 69 70 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 63 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 |
- (Object) blank_line
48 49 50 51 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 48 def blank_line @formatter.blank_comment self end |
- (Object) class_doc(type)
27 28 29 30 31 32 33 34 35 36 37 |
# 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 tag :xml_name, type.name.name if type.name.ns tag :xml_namespace, type.name.ns end end |
- (Object) dec_indent
22 23 24 25 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 22 def dec_indent @i -= 1 self end |
- (Object) inc_indent
17 18 19 20 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 17 def inc_indent @i += 1 self end |
- (Object) line(line)
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 |
- (Object) option(param_name, type, name, text = nil)
72 73 74 75 76 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 72 def option(param_name, type, name, text = nil) buf = "@option #{param_name} [#{type}] :#{name}" buf << " #{text}" if text line buf end |
- (Object) param(name, type, text = nil)
78 79 80 81 82 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 78 def param(name, type, text = nil) buf = "@param #{name} [#{type}]" buf << " #{text}" if text line buf end |
- (Object) params(*params)
84 85 86 87 88 89 90 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 84 def params(*params) return if params.empty? params.each do |p| param *p end blank_line end |
- (Object) tag(tag, text)
53 54 55 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 53 def tag(tag, text) line "@#{tag} #{text}" end |
- (Object) text(text)
39 40 41 42 43 44 45 46 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 39 def text(text) lines = process(text).strip.split("\n") lines.each do |l| line l end self end |
- (Object) type_tag(tag_name, type, text = nil)
57 58 59 60 61 |
# File 'lib/wsdl_mapper/generation/yard_doc_formatter.rb', line 57 def type_tag(tag_name, type, text = nil) buf = "@#{tag_name} [#{type}]" buf << " #{text}" if text line buf end |