### Home Classes Methods

### In Files

- lib/yard/templates/helpers/html_helper.rb

### Methods

- #anchor_for
- #charset
- #format_object_name_list
- #format_types
- #h
- #html_markup_html
- #html_markup_markdown
- #html_markup_none
- #html_markup_pre
- #html_markup_rdoc
- #html_markup_ruby
- #html_markup_text
- #html_markup_textile
- #html_markup_textile_strict
- #html_syntax_highlight
- #html_syntax_highlight_plain
- #htmlify
- #htmlify_line
- #link_file
- #link_include_file
- #link_include_object
- #link_object
- #link_url
- #resolve_links
- #signature
- #signature_types
- #url_for
- #url_for_file
- #url_for_frameset
- #url_for_index
- #url_for_list
- #url_for_main
- #urlencode

### Included Modules

- YARD::Templates::Helpers::MarkupHelper
- YARD::Templates::Helpers::HtmlSyntaxHighlightHelper

### Files

- LICENSE.txt
- MIT.txt

### Class/Module Index

Quicksearch

- YARD
- YARD::CLI
- YARD::CLI::Command
- YARD::CLI::CommandParser
- YARD::CLI::Config
- YARD::CLI::Diff
- YARD::CLI::Gems
- YARD::CLI::Graph
- YARD::CLI::GraphOptions
- YARD::CLI::Help
- YARD::CLI::I18n
- YARD::CLI::List
- YARD::CLI::Server
- YARD::CLI::Stats
- YARD::CLI::YRI
- YARD::CLI::Yardoc
- YARD::CLI::YardocOptions
- YARD::CodeObjects
- YARD::CodeObjects::Base
- YARD::CodeObjects::ClassObject
- YARD::CodeObjects::ClassVariableObject
- YARD::CodeObjects::CodeObjectList
- YARD::CodeObjects::ConstantObject
- YARD::CodeObjects::ExtendedMethodObject
- YARD::CodeObjects::ExtraFileObject
- YARD::CodeObjects::MacroObject
- YARD::CodeObjects::MethodObject
- YARD::CodeObjects::ModuleObject
- YARD::CodeObjects::NamespaceObject
- YARD::CodeObjects::Proxy
- YARD::CodeObjects::ProxyMethodError
- YARD::CodeObjects::RootObject
- YARD::Config
- YARD::Docstring
- YARD::DocstringParser
- YARD::Handlers
- YARD::Handlers::Base
- YARD::Handlers::C
- YARD::Handlers::C::AliasHandler
- YARD::Handlers::C::AttributeHandler
- YARD::Handlers::C::Base
- YARD::Handlers::C::ClassHandler
- YARD::Handlers::C::ConstantHandler
- YARD::Handlers::C::HandlerMethods
- YARD::Handlers::C::InitHandler
- YARD::Handlers::C::MethodHandler
- YARD::Handlers::C::MixinHandler
- YARD::Handlers::C::ModuleHandler
- YARD::Handlers::C::OverrideCommentHandler
- YARD::Handlers::C::PathHandler
- YARD::Handlers::C::StructHandler
- YARD::Handlers::C::SymbolHandler
- YARD::Handlers::NamespaceMissingError
- YARD::Handlers::Processor
- YARD::Handlers::Ruby
- YARD::Handlers::Ruby::AliasHandler
- YARD::Handlers::Ruby::AttributeHandler
- YARD::Handlers::Ruby::Base
- YARD::Handlers::Ruby::ClassConditionHandler
- YARD::Handlers::Ruby::ClassHandler
- YARD::Handlers::Ruby::ClassVariableHandler
- YARD::Handlers::Ruby::CommentHandler
- YARD::Handlers::Ruby::ConstantHandler
- YARD::Handlers::Ruby::DSLHandler
- YARD::Handlers::Ruby::DSLHandlerMethods
- YARD::Handlers::Ruby::ExceptionHandler
- YARD::Handlers::Ruby::ExtendHandler
- YARD::Handlers::Ruby::HandlesExtension
- YARD::Handlers::Ruby::Legacy
- YARD::Handlers::Ruby::Legacy::AliasHandler
- YARD::Handlers::Ruby::Legacy::AttributeHandler
- YARD::Handlers::Ruby::Legacy::Base
- YARD::Handlers::Ruby::Legacy::ClassConditionHandler
- YARD::Handlers::Ruby::Legacy::ClassHandler
- YARD::Handlers::Ruby::Legacy::ClassVariableHandler
- YARD::Handlers::Ruby::Legacy::CommentHandler
- YARD::Handlers::Ruby::Legacy::ConstantHandler
- YARD::Handlers::Ruby::Legacy::DSLHandler
- YARD::Handlers::Ruby::Legacy::ExceptionHandler
- YARD::Handlers::Ruby::Legacy::ExtendHandler
- YARD::Handlers::Ruby::Legacy::MethodHandler
- YARD::Handlers::Ruby::Legacy::MixinHandler
- YARD::Handlers::Ruby::Legacy::ModuleFunctionHandler
- YARD::Handlers::Ruby::Legacy::ModuleHandler
- YARD::Handlers::Ruby::Legacy::PrivateConstantHandler
- YARD::Handlers::Ruby::Legacy::VisibilityHandler
- YARD::Handlers::Ruby::Legacy::YieldHandler
- YARD::Handlers::Ruby::MethodCallWrapper
- YARD::Handlers::Ruby::MethodConditionHandler
- YARD::Handlers::Ruby::MethodHandler
- YARD::Handlers::Ruby::MixinHandler
- YARD::Handlers::Ruby::ModuleFunctionHandler
- YARD::Handlers::Ruby::ModuleHandler
- YARD::Handlers::Ruby::PrivateConstantHandler
- YARD::Handlers::Ruby::StructHandlerMethods
- YARD::Handlers::Ruby::TestNodeWrapper
- YARD::Handlers::Ruby::VisibilityHandler
- YARD::Handlers::Ruby::YieldHandler
- YARD::I18n
- YARD::I18n::Locale
- YARD::I18n::Message
- YARD::I18n::Messages
- YARD::I18n::PotGenerator
- YARD::I18n::Text
- YARD::Logger
- YARD::Options
- YARD::Parser
- YARD::Parser::Base
- YARD::Parser::C
- YARD::Parser::C::BodyStatement
- YARD::Parser::C::CParser
- YARD::Parser::C::Comment
- YARD::Parser::C::CommentParser
- YARD::Parser::C::Statement
- YARD::Parser::C::ToplevelStatement
- YARD::Parser::OrderedParser
- YARD::Parser::ParserSyntaxError
- YARD::Parser::Ruby
- YARD::Parser::Ruby::AstNode
- YARD::Parser::Ruby::ClassNode
- YARD::Parser::Ruby::CommentNode
- YARD::Parser::Ruby::ConditionalNode
- YARD::Parser::Ruby::KeywordNode
- YARD::Parser::Ruby::Legacy
- YARD::Parser::Ruby::Legacy::RubyLex
- YARD::Parser::Ruby::Legacy::RubyLex::BufferedReader
- YARD::Parser::Ruby::Legacy::RubyParser
- YARD::Parser::Ruby::Legacy::RubyToken
- YARD::Parser::Ruby::Legacy::RubyToken::TkBlockContents
- YARD::Parser::Ruby::Legacy::RubyToken::TkError
- YARD::Parser::Ruby::Legacy::RubyToken::TkId
- YARD::Parser::Ruby::Legacy::RubyToken::TkKW
- YARD::Parser::Ruby::Legacy::RubyToken::TkNode
- YARD::Parser::Ruby::Legacy::RubyToken::TkOPASGN
- YARD::Parser::Ruby::Legacy::RubyToken::TkOp
- YARD::Parser::Ruby::Legacy::RubyToken::TkStatementEnd
- YARD::Parser::Ruby::Legacy::RubyToken::TkUnknownChar
- YARD::Parser::Ruby::Legacy::RubyToken::TkVal
- YARD::Parser::Ruby::Legacy::RubyToken::TkWhitespace
- YARD::Parser::Ruby::Legacy::RubyToken::Token
- YARD::Parser::Ruby::Legacy::Statement
- YARD::Parser::Ruby::Legacy::StatementList
- YARD::Parser::Ruby::Legacy::TokenList
- YARD::Parser::Ruby::LiteralNode
- YARD::Parser::Ruby::LoopNode
- YARD::Parser::Ruby::MethodCallNode
- YARD::Parser::Ruby::MethodDefinitionNode
- YARD::Parser::Ruby::ModuleNode
- YARD::Parser::Ruby::ParameterNode
- YARD::Parser::Ruby::ReferenceNode
- YARD::Parser::Ruby::RipperParser
- YARD::Parser::Ruby::RubyParser
- YARD::Parser::SourceParser
- YARD::Parser::UndocumentableError
- YARD::Rake
- YARD::Rake::YardocTask
- YARD::Registry
- YARD::RegistryStore
- YARD::Serializers
- YARD::Serializers::Base
- YARD::Serializers::FileSystemSerializer
- YARD::Serializers::ProcessSerializer
- YARD::Serializers::StdoutSerializer
- YARD::Serializers::YardocSerializer
- YARD::Server
- YARD::Server::Adapter
- YARD::Server::Commands
- YARD::Server::Commands::Base
- YARD::Server::Commands::DisplayFileCommand
- YARD::Server::Commands::DisplayObjectCommand
- YARD::Server::Commands::FramesCommand
- YARD::Server::Commands::LibraryCommand
- YARD::Server::Commands::LibraryIndexCommand
- YARD::Server::Commands::LibraryOptions
- YARD::Server::Commands::ListCommand
- YARD::Server::Commands::SearchCommand
- YARD::Server::Commands::StaticFileCommand
- YARD::Server::DocServerHelper
- YARD::Server::DocServerSerializer
- YARD::Server::FinishRequest
- YARD::Server::LibraryNotPreparedError
- YARD::Server::LibraryVersion
- YARD::Server::NotFoundError
- YARD::Server::RackAdapter
- YARD::Server::RackMiddleware
- YARD::Server::Router
- YARD::Server::StaticCaching
- YARD::Server::WebrickAdapter
- YARD::Server::WebrickServlet
- YARD::StubProxy
- YARD::Tags
- YARD::Tags::AttributeDirective
- YARD::Tags::DefaultFactory
- YARD::Tags::DefaultTag
- YARD::Tags::Directive
- YARD::Tags::EndGroupDirective
- YARD::Tags::GroupDirective
- YARD::Tags::Library
- YARD::Tags::MacroDirective
- YARD::Tags::MethodDirective
- YARD::Tags::OptionTag
- YARD::Tags::OverloadTag
- YARD::Tags::ParseDirective
- YARD::Tags::RefTag
- YARD::Tags::RefTagList
- YARD::Tags::ScopeDirective
- YARD::Tags::Tag
- YARD::Tags::TagFormatError
- YARD::Tags::VisibilityDirective
- YARD::Templates
- YARD::Templates::Engine
- YARD::Templates::ErbCache
- YARD::Templates::Helpers
- YARD::Templates::Helpers::BaseHelper
- YARD::Templates::Helpers::FilterHelper
- YARD::Templates::Helpers::HtmlHelper
- YARD::Templates::Helpers::HtmlSyntaxHighlightHelper
- YARD::Templates::Helpers::Markup
- YARD::Templates::Helpers::Markup::RDocMarkup
- YARD::Templates::Helpers::Markup::RDocMarkup::RDocMarkup
- YARD::Templates::Helpers::Markup::RDocMarkup::RDocMarkup::RDocMarkupToHtml
- YARD::Templates::Helpers::Markup::RDocMarkup::RDocMarkupToHtml
- YARD::Templates::Helpers::MarkupHelper
- YARD::Templates::Helpers::MethodHelper
- YARD::Templates::Helpers::ModuleHelper
- YARD::Templates::Helpers::TextHelper
- YARD::Templates::Helpers::UMLHelper
- YARD::Templates::Section
- YARD::Templates::Template
- YARD::Templates::Template::ClassMethods
- YARD::Templates::TemplateOptions
- YARD::Verifier
- Gem
- Gem::DocManager
- Gem::SourceIndex
- Gem::Specification
- Rack
- Rack::Request
- WEBrick
- WEBrick::HTTPRequest
- Array
- File
- Hash
- Insertion
- Module
- Object
- String
- SymbolHash

No matching classes.

# YARD::Templates::Helpers::HtmlHelper

The helper module for HTML templates.

### Public Instance Methods

anchor_for(object) click to toggle source

@param [CodeObjects::Base] object the object to get an anchor for @return [String] the anchor for a specific object

    # File lib/yard/templates/helpers/html_helper.rb, line 288
    def anchor_for(object)
      case object
      when CodeObjects::MethodObject
        "#{object.name}-#{object.scope}_#{object.type}"
      when CodeObjects::ClassVariableObject
        "#{object.name.to_s.gsub('@@', '')}-#{object.type}"
      when CodeObjects::Base
        "#{object.name}-#{object.type}"
      when CodeObjects::Proxy
        object.path
      else
        object.to_s
      end
    end

charset() click to toggle source

Returns the current character set. The default value can be overridden by setting the `LANG` environment variable or by overriding this method. In Ruby 1.9 you can also modify this value by setting `Encoding.default_external`.

@return [String] the current character set @since 0.5.4

    # File lib/yard/templates/helpers/html_helper.rb, line 510
    def charset
      if @file && RUBY19
        lang = @file.contents.encoding.to_s
      else
        return 'utf-8' unless RUBY19 || lang = ENV['LANG']
        if RUBY19
          lang = ::Encoding.default_external.name.downcase
        else
          lang = lang.downcase.split('.').last
        end
      end
      case lang
      when "ascii-8bit", "us-ascii", "ascii-7bit"; 'iso-8859-1'
      when "utf8"; 'utf-8'
      else; lang
      end
    end

format_object_name_list(objects) click to toggle source

Formats a list of objects and links them @return [String] a formatted list of objects

    # File lib/yard/templates/helpers/html_helper.rb, line 396
    def format_object_name_list(objects)
      objects.sort_by {|o| o.name.to_s.downcase }.map do |o|
        "<span class='name'>" + linkify(o, o.name) + "</span>"
      end.join(", ")
    end

format_types(typelist, brackets = true) click to toggle source

Formats a list of types from a tag.

@param [Array<String>, FalseClass] typelist

    the list of types to be formatted.

@param [Boolean] brackets omits the surrounding

    brackets if +brackets+ is set to +false+.

@return [String] the list of types formatted

    as [Type1, Type2, ...] with the types linked
    to their respective descriptions.

    # File lib/yard/templates/helpers/html_helper.rb, line 414
    def format_types(typelist, brackets = true)
      return unless typelist.is_a?(Array)
      list = typelist.map do |type|
        type = type.gsub(/([<>])/) { h($1) }
        type = type.gsub(/([\w:]+)/) { $1 == "lt" || $1 == "gt" ? $1 : linkify($1, $1) }
        "<tt>" + type + "</tt>"
      end
      list.empty? ? "" : (brackets ? "(#{list.join(", ")})" : list.join(", "))
    end

h(text) click to toggle source

Escapes HTML entities

@param [String] text the text to escape @return [String] the HTML with escaped entities

    # File lib/yard/templates/helpers/html_helper.rb, line 16
    def h(text)
      CGI.escapeHTML(text.to_s)
    end

html_markup_html(text) click to toggle source

Converts HTML to HTML @param [String] text input html @return [String] output HTML @since 0.6.0

    # File lib/yard/templates/helpers/html_helper.rb, line 123
    def html_markup_html(text)
      text
    end

html_markup_markdown(text) click to toggle source

Converts Markdown to HTML @param [String] text input Markdown text @return [String] output HTML @since 0.6.0

    # File lib/yard/templates/helpers/html_helper.rb, line 57
    def html_markup_markdown(text)
      # TODO: other libraries might be more complex
      provider = markup_class(:markdown)
      if provider.to_s == 'RDiscount'
        provider.new(text, :autolink).to_html
      elsif provider.to_s == 'RedcarpetCompat'
        provider.new(text, :gh_blockcode, :fenced_code, :autolink).to_html
      else
        provider.new(text).to_html
      end
    end

html_markup_none(text) click to toggle source

@return [String] the same text with no markup @since 0.6.6

    # File lib/yard/templates/helpers/html_helper.rb, line 115
    def html_markup_none(text)
      h(text)
    end

html_markup_pre(text) click to toggle source

Converts plaintext to pre-formatted HTML @param [String] text the input text @return [String] the output HTML @since 0.6.0

    # File lib/yard/templates/helpers/html_helper.rb, line 101
    def html_markup_pre(text)
      "<pre>" + h(text) + "</pre>"
    end

html_markup_rdoc(text) click to toggle source

Converts RDoc formatting (SimpleMarkup) to HTML @param [String] text the input RDoc formatted text @return [String] output HTML @since 0.6.0

    # File lib/yard/templates/helpers/html_helper.rb, line 91
    def html_markup_rdoc(text)
      doc = markup_class(:rdoc).new(text)
      doc.from_path = url_for(object) if doc.respond_to?(:from_path=)
      doc.to_html
    end

html_markup_ruby(source) click to toggle source

Highlights Ruby source. Similar to {html_syntax_highlight}, but this method is meant to be called from {htmlify} when markup is set to "ruby".

@param [String] source the Ruby source @return [String] the highlighted HTML @since 0.7.0

    # File lib/yard/templates/helpers/html_helper.rb, line 134
    def html_markup_ruby(source)
      '<pre class="code ruby">' + html_syntax_highlight(source, :ruby) + '</pre>'
    end

html_markup_text(text) click to toggle source

Converts plaintext to regular HTML @param [String] text the input text @return [String] the output HTML @since 0.6.0

    # File lib/yard/templates/helpers/html_helper.rb, line 109
    def html_markup_text(text)
      h(text).gsub(/\r?\n/, '<br/>')
    end

html_markup_textile(text) click to toggle source

Converts Textile to HTML @param [String] text the input Textile text @return [String] output HTML @since 0.6.0

    # File lib/yard/templates/helpers/html_helper.rb, line 73
    def html_markup_textile(text)
      doc = markup_class(:textile).new(text)
      doc.hard_breaks = false if doc.respond_to?(:hard_breaks=)
      doc.to_html
    end

html_markup_textile_strict(text) click to toggle source

Converts plaintext to strict Textile (hard breaks) @param [String] text the input textile data @return [String] the output HTML @since 0.6.0

    # File lib/yard/templates/helpers/html_helper.rb, line 83
    def html_markup_textile_strict(text)
      markup_class(:textile).new(text).to_html
    end

html_syntax_highlight(source, type = nil) click to toggle source

Syntax highlights `source` in language `type`.

@note To support a specific language `type`, implement the method

    +html_syntax_highlight_TYPE+ in this class.

@param [String] source the source code to highlight @param [Symbol, String] type the language type (:ruby, :plain, etc). Use

    :plain for no syntax highlighting.

@return [String] the highlighted source

    # File lib/yard/templates/helpers/html_helper.rb, line 154
    def html_syntax_highlight(source, type = nil)
      return "" unless source
      return h(source) unless options.highlight

      new_type, source = parse_lang_for_codeblock(source)
      type ||= new_type || :ruby
      meth = "html_syntax_highlight_#{type}"
      respond_to?(meth) ? send(meth, source) : h(source)
    end

html_syntax_highlight_plain(source) click to toggle source

@return [String] unhighlighted source

    # File lib/yard/templates/helpers/html_helper.rb, line 165
    def html_syntax_highlight_plain(source)
      h(source)
    end

htmlify(text, markup = options.markup) click to toggle source

Turns text into HTML using `markup` style formatting.

@param [String] text the text to format @param [Symbol] markup examples are `:markdown`, `:textile`, `:rdoc`.

    To add a custom markup type, see {MarkupHelper}

@return [String] the HTML

    # File lib/yard/templates/helpers/html_helper.rb, line 36
    def htmlify(text, markup = options.markup)
      markup_meth = "html_markup_#{markup}"
      return text unless respond_to?(markup_meth)
      return "" unless text
      return text unless markup
      html = send(markup_meth, text)
      if html.respond_to?(:encode)
        html = html.force_encoding(text.encoding) # for libs that mess with encoding
        html = html.encode(:invalid => :replace, :replace => '?')
      end
      html = resolve_links(html)
      unless [:text, :none, :pre].include?(markup)
        html = parse_codeblocks(html)
      end
      html
    end

htmlify_line(*args) click to toggle source

@return [String] HTMLified text as a single line (paragraphs removed)

    # File lib/yard/templates/helpers/html_helper.rb, line 139
    def htmlify_line(*args)
      "<div class='inline'>" + htmlify(*args) + "</div>"
    end

link_file(filename, title = nil, anchor = nil) click to toggle source

(see BaseHelper#link_file)

    # File lib/yard/templates/helpers/html_helper.rb, line 219
    def link_file(filename, title = nil, anchor = nil)
      if CodeObjects::ExtraFileObject === filename
        file = filename
      else
        contents = File.file?(filename) ? nil : ''
        file = CodeObjects::ExtraFileObject.new(filename, contents)
      end
      return title || file.title unless serializer
      link_url(url_for_file(file, anchor), title || file.title)
    end

link_include_file(file) click to toggle source

(see BaseHelper#link_include_file)

    # File lib/yard/templates/helpers/html_helper.rb, line 231
    def link_include_file(file)
      unless file.is_a?(CodeObjects::ExtraFileObject)
        file = CodeObjects::ExtraFileObject.new(file)
      end
      file.attributes[:markup] ||= markup_for_file('', file.filename)
      htmlify(file.contents, file.attributes[:markup] || options.markup)
    end

link_include_object(obj) click to toggle source

(see BaseHelper#link_include_object)

    # File lib/yard/templates/helpers/html_helper.rb, line 240
    def link_include_object(obj)
      htmlify(obj.docstring)
    end

link_object(obj, otitle = nil, anchor = nil, relative = true) click to toggle source

(see BaseHelper#link_object)

    # File lib/yard/templates/helpers/html_helper.rb, line 245
    def link_object(obj, otitle = nil, anchor = nil, relative = true)
      return otitle if obj.nil?
      obj = Registry.resolve(object, obj, true, true) if obj.is_a?(String)
      if !otitle && obj.root?
        title = "Top Level Namespace"
      elsif otitle
        title = otitle.to_s
      elsif object.is_a?(CodeObjects::Base)
        # Check if we're linking to a class method in the current
        # object. If we are, create a title in the format of
        # "CurrentClass.method_name"
        if obj.is_a?(CodeObjects::MethodObject) && obj.scope == :class && obj.parent == object
          title = h([object.name, obj.sep, obj.name].join)
        else
          title = h(object.relative_path(obj))
        end
      else
        title = h(obj.to_s)
      end
      return title unless serializer
      return title if obj.is_a?(CodeObjects::Proxy)

      link = url_for(obj, anchor, relative)
      link = link ? link_url(link, title, :title => h("#{obj.path} (#{obj.type})")) : title
      "<span class='object_link'>" + link + "</span>"
    end

link_url(url, title = nil, params = {}) click to toggle source

(see BaseHelper#link_url)

    # File lib/yard/templates/helpers/html_helper.rb, line 273
    def link_url(url, title = nil, params = {})
      title ||= url
      title.gsub!(/[\r\n]/, ' ')
      params = SymbolHash.new(false).update(
        :href => url,
        :title  => h(title)
      ).update(params)
      params[:target] ||= '_parent' if url =~ /^(\w+):\/\//
      "<a #{tag_attrs(params)}>#{title}</a>".gsub(/[\r\n]/, ' ')
    end

resolve_links(text) click to toggle source

Resolves any text in the form of +{Name}+ to the object specified by Name. Also supports link titles in the form +{Name title}+.

@example Linking to an instance method

    resolve_links("{MyClass#method}") # => "<a href='...'>MyClass#method</a>"

@example Linking to a class with a title

    resolve_links("{A::B::C the C class}") # => "<a href='...'>the c class</a>"

@param [String] text the text to resolve links in @return [String] HTML with linkified references

    # File lib/yard/templates/helpers/html_helper.rb, line 180
    def resolve_links(text)
      code_tags = 0
      text.gsub(/<(\/)?(pre|code|tt)|(\\|!)?\{(?!\})(\S+?)(?:\s([^\}]*?\S))?\}(?=[\W<]|.+<\/|$)/) do |str|
        closed, tag, escape, name, title, match = $1, $2, $3, $4, $5, $&
        if tag
          code_tags += (closed ? -1 : 1)
          next str
        end
        next str unless code_tags == 0

        next(match[1..-1]) if escape

        next(match) if name[0,1] == '|'

        if name == '<a' && title =~ /href=["'](.+?)["'].*>.*<\/a>\s*(.*)\Z/
          name, title = $1, $2
          title = nil if title.empty?
        end

        name = CGI.unescapeHTML(name)

        if object.is_a?(String)
          object
        else
          link = linkify(name, title)
          if (link == name || link == title) && (name+' '+link !~ /\A<a\s.*>/)
            match = /(.+)?(\{#{Regexp.quote name}(?:\s.*?)?\})(.+)?/.match(text)
            file = (@file ? @file.filename : object.file) || '(unknown)'
            line = (@file ? 1 : (object.docstring.line_range ? object.docstring.line_range.first : 1)) + (match ? $`.count("\n") : 0)
            log.warn "In file `#{file}':#{line}: Cannot resolve link to #{name} from text" + (match ? ":" : ".")
            log.warn((match[1] ? '...' : '') + match[2].gsub("\n","") + (match[3] ? '...' : '')) if match
          end

          link
        end
      end
    end

signature(meth, link = true, show_extras = true, full_attr_name = true) click to toggle source

Formats the signature of method `meth`.

@param [CodeObjects::MethodObject] meth the method object to list

    the signature of

@param [Boolean] link whether to link the method signature to the details view @param [Boolean] show_extras whether to show extra meta-data (visibility, attribute info) @param [Boolean] full_attr_name whether to show the full attribute name

    ("name=" instead of "name")

@return [String] the formatted method signature

    # File lib/yard/templates/helpers/html_helper.rb, line 467
    def signature(meth, link = true, show_extras = true, full_attr_name = true)
      meth = convert_method_to_overload(meth)

      type = signature_types(meth, link)
      scope = meth.scope == :class ? "+" : "-"
      name = full_attr_name ? meth.name : meth.name.to_s.gsub(/^(\w+)=$/, '\1')
      blk = format_block(meth)
      args = !full_attr_name && meth.writer? ? "" : format_args(meth)
      extras = []
      extras_text = ''
      if show_extras
        if rw = meth.attr_info
          attname = [rw[:read] ? 'read' : nil, rw[:write] ? 'write' : nil].compact
          attname = attname.size == 1 ? attname.join('') + 'only' : nil
          extras << attname if attname
        end
        extras << meth.visibility if meth.visibility != :public
        extras_text = ' <span class="extras">(' + extras.join(", ") + ')</span>' unless extras.empty?
      end
      title = "%s %s<strong>%s</strong>%s %s" % [scope, type, h(name), args, blk]
      if link
        if meth.is_a?(YARD::CodeObjects::MethodObject)
          link_title = "#{h meth.name(true)} (#{meth.scope} #{meth.type})"
        else
          link_title = "#{h name} (#{meth.type})"
        end
        obj = meth.respond_to?(:object) ? meth.object : meth
        url = url_for(object, obj)
        link_url(url, title, :title => link_title) + extras_text
      else
        title + extras_text
      end
    end

signature_types(meth, link = true) click to toggle source

Get the return types for a method signature.

@param [CodeObjects::MethodObject] meth the method object @param [Boolean] link whether to link the types @return [String] the signature types @since 0.5.3

    # File lib/yard/templates/helpers/html_helper.rb, line 430
    def signature_types(meth, link = true)
      meth = convert_method_to_overload(meth)
      if meth.respond_to?(:object) && !meth.has_tag?(:return)
        meth = meth.object
      end

      type = options.default_return || ""
      if meth.tag(:return) && meth.tag(:return).types
        types = meth.tags(:return).map {|t| t.types ? t.types : [] }.flatten.uniq
        first = link ? h(types.first) : format_types([types.first], false)
        if types.size == 2 && types.last == 'nil'
          type = first + '<sup>?</sup>'
        elsif types.size == 2 && types.last =~ /^(Array)?<#{Regexp.quote types.first}>$/
          type = first + '<sup>+</sup>'
        elsif types.size > 2
          type = [first, '...'].join(', ')
        elsif types == ['void'] && options.hide_void_return
          type = ""
        else
          type = link ? h(types.join(", ")) : format_types(types, false)
        end
      elsif !type.empty?
        type = link ? h(type) : format_types([type], false)
      end
      type = "(#{type}) " unless type.empty?
      type
    end

url_for(obj, anchor = nil, relative = true) click to toggle source

Returns the URL for an object.

@param [String, CodeObjects::Base] obj the object (or object path) to link to @param [String] anchor the anchor to link to @param [Boolean] relative use a relative or absolute link @return [String] the URL location of the object

    # File lib/yard/templates/helpers/html_helper.rb, line 309
    def url_for(obj, anchor = nil, relative = true)
      link = nil
      return link unless serializer

      if obj.is_a?(CodeObjects::Base) && !obj.is_a?(CodeObjects::NamespaceObject)
        # If the obj is not a namespace obj make it the anchor.
        anchor, obj = obj, obj.namespace
      end

      objpath = serializer.serialized_path(obj)
      return link unless objpath

      if relative
        fromobj = object
        if object.is_a?(CodeObjects::Base) &&
            !object.is_a?(CodeObjects::NamespaceObject)
          fromobj = owner
        end

        from = serializer.serialized_path(fromobj)
        link = File.relative_path(from, objpath)
      else
        link = objpath
      end

      link + (anchor ? '#' + urlencode(anchor_for(anchor)) : '')
    end

url_for_file(filename, anchor = nil) click to toggle source

Returns the URL for a specific file

@param [String, CodeObjects::ExtraFileObject] filename the filename to link to @param [String] anchor optional anchor @return [String] the URL pointing to the file

    # File lib/yard/templates/helpers/html_helper.rb, line 342
    def url_for_file(filename, anchor = nil)
      return '' unless serializer
      fromobj = object
      if CodeObjects::Base === fromobj && !fromobj.is_a?(CodeObjects::NamespaceObject)
        fromobj = fromobj.namespace
      end
      from = serializer.serialized_path(fromobj)
      if filename == options.readme
        path = 'index.html'
      else
        path = serializer.serialized_path(filename)
      end
      link = File.relative_path(from, path)
      link += (anchor ? '#' + urlencode(anchor) : '')
      link
    end

url_for_frameset() click to toggle source

Returns the URL for the frameset page

@return [String] the URL pointing to the frames page @since 0.8.0

    # File lib/yard/templates/helpers/html_helper.rb, line 372
    def url_for_frameset
      url_for_file("frames.html")
    end

url_for_index() click to toggle source

Returns the URL for the alphabetic index page

@return [String] the URL pointing to the first main page the

    user should see.

    # File lib/yard/templates/helpers/html_helper.rb, line 388
    def url_for_index
      url_for_file("_index.html")
    end

url_for_list(type) click to toggle source

Returns the URL for a list type

@param [String, Symbol] type the list type to generate a URL for @return [String] the URL pointing to the list @since 0.8.0

    # File lib/yard/templates/helpers/html_helper.rb, line 364
    def url_for_list(type)
      url_for_file("#{type}_list.html")
    end

url_for_main() click to toggle source

Returns the URL for the main page (README or alphabetic index)

@return [String] the URL pointing to the first main page the

    user should see.

    # File lib/yard/templates/helpers/html_helper.rb, line 380
    def url_for_main
      url_for_file("index.html")
    end

urlencode(text) click to toggle source

Escapes a URL

@param [String] text the URL @return [String] the escaped URL

    # File lib/yard/templates/helpers/html_helper.rb, line 24
    def urlencode(text)
      CGI.escape(text.to_s)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.