Class: WeaselDiesel::Documentation
- Inherits:
-
Object
- Object
- WeaselDiesel::Documentation
- Defined in:
- lib/documentation.rb
Overview
Service documentation class
Defined Under Namespace
Classes: ElementDoc, NamespacedParam
Instance Attribute Summary collapse
- #desc ⇒ Object readonly
- #elements ⇒ Object readonly
- #examples ⇒ Object readonly
- #namespaced_params ⇒ Object readonly
- #params_doc ⇒ Object readonly
Instance Method Summary collapse
-
#element(opts = {}) {|ElementDoc| ... } ⇒ Array<ElementDoc>
Add a new element to the doc currently only used for response doc.
-
#example(desc) ⇒ Array<String>
Service usage example.
-
#initialize ⇒ Documentation
constructor
Initialize a Documentation object wrapping all the documentation aspect of the service.
-
#namespace(ns_name) ⇒ Array
(also: #object)
Define a new namespaced param and yield it to the passed block if available.
-
#overall(desc) ⇒ String
Sets or returns the overall description.
-
#params(name, desc) ⇒ String
(also: #param)
Sets the description/documentation of a specific param.
- #response ⇒ Object
Constructor Details
#initialize ⇒ Documentation
Initialize a Documentation object wrapping all the documentation aspect of the service. The response documentation is a Documentation instance living inside the service documentation object.
81 82 83 84 85 86 |
# File 'lib/documentation.rb', line 81 def initialize @params_doc = {} @examples = [] @elements = [] @namespaced_params = [] end |
Instance Attribute Details
#desc ⇒ Object (readonly)
8 9 10 |
# File 'lib/documentation.rb', line 8 def desc @desc end |
#elements ⇒ Object (readonly)
20 21 22 |
# File 'lib/documentation.rb', line 20 def elements @elements end |
#examples ⇒ Object (readonly)
17 18 19 |
# File 'lib/documentation.rb', line 17 def examples @examples end |
#namespaced_params ⇒ Object (readonly)
14 15 16 |
# File 'lib/documentation.rb', line 14 def namespaced_params @namespaced_params end |
#params_doc ⇒ Object (readonly)
11 12 13 |
# File 'lib/documentation.rb', line 11 def params_doc @params_doc end |
Instance Method Details
#element(opts = {}) {|ElementDoc| ... } ⇒ Array<ElementDoc>
Add a new element to the doc currently only used for response doc
144 145 146 147 148 |
# File 'lib/documentation.rb', line 144 def element(opts={}) element = ElementDoc.new(opts) yield(element) @elements << element end |
#example(desc) ⇒ Array<String>
Service usage example
133 134 135 |
# File 'lib/documentation.rb', line 133 def example(desc) @examples << desc end |
#namespace(ns_name) ⇒ Array Also known as: object
Define a new namespaced param and yield it to the passed block if available.
115 116 117 118 119 120 121 |
# File 'lib/documentation.rb', line 115 def namespace(ns_name) new_ns_param = NamespacedParam.new(ns_name) if block_given? yield(new_ns_param) end @namespaced_params << new_ns_param end |
#overall(desc) ⇒ String
Sets or returns the overall description
93 94 95 96 97 98 99 |
# File 'lib/documentation.rb', line 93 def overall(desc) if desc.nil? @desc else @desc = desc end end |
#params(name, desc) ⇒ String Also known as: param
Sets the description/documentation of a specific param
105 106 107 |
# File 'lib/documentation.rb', line 105 def params(name, desc) @params_doc[name] = desc end |
#response ⇒ Object
124 125 126 |
# File 'lib/documentation.rb', line 124 def response @response ||= Documentation.new end |