Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • rdoc/generators/html_generator.rb


Class/Module Index [+]



Handle common markup tasks for the various Html classes

Public Instance Methods

cvs_url(url, full_path) click to toggle source

Build a webcvs URL with the given ‘url’ argument. URLs with a ‘%s’ in them get the file’s path sprintfed into them; otherwise they’re just catenated together.

               # File rdoc/generators/html_generator.rb, line 272
def cvs_url(url, full_path)
  if /%s/ =~ url
    return sprintf( url, full_path )
    return url + full_path
markup(str, remove_para=false) click to toggle source

Convert a string in markup format into HTML. We keep a cached SimpleMarkup object lying around after the first time we’re called per object.

               # File rdoc/generators/html_generator.rb, line 209
    def markup(str, remove_para=false)
      return '' unless str
      unless defined? @markup
        @markup = SM::SimpleMarkup.new

        # class names, variable names, or instance variables
                               \w+(::\w+)*[.\#]\w+(\([\.\w+\*\/\+\-\=\<\>]+\))?  # A::B.meth(**) (for operator in Fortran95)
                             | \#\w+(\([.\w\*\/\+\-\=\<\>]+\))?  #  meth(**) (for operator in Fortran95)
                             | \b([A-Z]\w*(::\w+)*[.\#]\w+)  #    A::B.meth
                             | \b([A-Z]\w+(::\w+)*)       #    A::B..
                             | \#\w+[!?=]?                #    #meth_name 
                             | \b\w+([_\/\.]+\w+)*[!?=]?  #    meth_name

        # external hyperlinks
        @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)

        # and links of the form  <text>[<url>]
        @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
#        @markup.add_special(/\b(\S+?\[\S+?\.\S+?\])/, :TIDYLINK)

      unless defined? @html_formatter
        @html_formatter = HyperlinkHtml.new(self.path, self)

      # Convert leading comment markers to spaces, but only
      # if all non-blank lines have them

      if str =~ /^(?>\s*)[^\#]/
        content = str
        content = str.gsub(/^\s*(#+)/)  { $1.tr('#',' ') }

      res = @markup.convert(content, @html_formatter)
      if remove_para
        res.sub!(/^<p>/, '')
        res.sub!(/<\/p>$/, '')
style_url(path, css_name=nil) click to toggle source

Qualify a stylesheet URL; if if css_name does not begin with ‘/’ or ‘http://’, prepend a prefix relative to path. Otherwise, return it unmodified.

               # File rdoc/generators/html_generator.rb, line 258
    def style_url(path, css_name=nil)
#      $stderr.puts "style_url( #{path.inspect}, #{css_name.inspect} )"
      css_name ||= CSS_NAME
      if %r{^(https?:/)?/} =~ css_name
        return css_name
        return HTMLGenerator.gen_url(path, css_name)

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus