class Object

Public Instance Methods

describe_method(xml, object, method) click to toggle source
# 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.to_s}
          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.to_s}
                  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
init() click to toggle source
Author

Couchbase <info@couchbase.com>

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.

# File lib/templates/default/class/xml/setup.rb, line 18
def init
  xml = options[:xml_builder]
  xml.class(:name => object.name.to_s, :superclass => object.superclass.path.to_s) do

    object.instance_mixins.each do |mixin|
      xml.instance_mixin mixin.path
    end

    object.class_mixins.each do |mixin|
      xml.class_mixin mixin.path
    end

    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