Top Level Namespace

Defined Under Namespace

Modules: YardXML

Instance Method Summary collapse

Instance Method Details

#describe_method(xml, object, method) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/templates/default/method/xml/setup.rb', line 79

def describe_method(xml, object, method)
  xml.overload do
    xml.signature(text_signature(method))
    xml.description(docstring_description(method, object.docstring.summary))

    option_tags = method.tags(:option)
    [:param, :yieldparam].each do |tag_name|
      xml.tag!("#{tag_name}s") do
        method.tags(tag_name).each do |param|
          info = {:name => param.name}
          default = method.parameters.assoc(param.name)
          if default && default[1]
            info[:default] = default[1]
          end
          xml.tag!(param.tag_name, info) do
            xml.types do
              if param.types
                param.types.each do |type|
                  xml.type(type)
                end
              else
                xml.type("Object")
              end
            end
            options = option_tags.select{|x| x.name.to_s == param.name}
            unless options.empty?
              xml.options do
                options.each do |option|
                  info = {:name => option.pair.name}
                  if option.pair.defaults
                    info[:default] = option.pair.defaults.first
                  end
                  xml.option(info) do
                    xml.types do
                      if option.pair.types
                        option.pair.types.each do |type|
                          xml.type(type)
                        end
                      else
                        xml.type("Object")
                      end
                    end
                    xml.description do
                      xml.cdata!(html_markup_rdoc(option.pair.text || ""))
                    end
                  end
                end
              end
            end
            xml.description do
              xml.cdata!(html_markup_rdoc(param.text || ""))
            end
          end
        end
      end if method.has_tag?(tag_name)
    end

    [:yieldreturn, :return].each do |tag_name|
      xml.tag!("#{tag_name}s") do
        ret = method.tag(tag_name)
        xml.types do
          if ret.types
            ret.types.each do |type|
              xml.type(type)
            end
          else
            xml.type("Object")
          end
        end
        xml.description do
          xml.cdata!(html_markup_rdoc(ret.text || ""))
        end
      end if method.has_tag?(tag_name)
    end

    xml.exceptions do
      method.tags(:raise).each do |exc|
        xml.exception do
          xml.types do
            if exc.types
              exc.types.each do |type|
                xml.type(type)
              end
            end
          end
          xml.description do
            xml.cdata!(html_markup_rdoc(exc.text || ""))
          end
        end
      end
    end if method.has_tag?(:raise)

    xml.notes do
      object.tags(:note).each do |note|
        xml.note do
          xml.cdata!(html_markup_rdoc(note.text || ""))
        end
      end
    end if object.has_tag?(:note)
    xml.links do
      object.tags(:see).each do |link|
        xml.link(link.name)
      end
    end if object.has_tag?(:see)

    xml.examples do
      method.tags(:example).each do |example|
        xml.example do
          xml.description do
            xml.cdata!(html_markup_rdoc(example.name || ""))
          end
          xml.code(example.text)
        end
      end
    end if method.has_tag?(:example)
  end
end

#initObject

Author

Couchbase <[email protected]>

Copyright

2012 Couchbase, Inc.

License

Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/templates/default/class/xml/setup.rb', line 19

def init
  xml = options[:xml_builder]
  xml.class(:name => object.name, :superclass => object.superclass.name) do
    xml.summary(docstring_summary(object))
    xml.description do
      xml.cdata!(html_markup_rdoc(object.docstring))
    end
    if object.respond_to?(:children)
      object.children.sort_by do |child|
        [
          child.type.to_s,
          child.respond_to?(:scope) ? child.scope.to_s : "",
          child.name.to_s
        ]
      end.each do |child|
        child.format(options.merge(:type => child.type))
      end
    end
  end
end