Class: RD::RD2MANVisitor

### Home Classes Methods

### In Files

- lib/rd/rd2man-lib.rb

### Parent

RDVisitor

### Methods

- ::new
- ::version
- #apply_to_Code
- #apply_to_DescList
- #apply_to_DescListItem
- #apply_to_DocumentElement
- #apply_to_Emphasis
- #apply_to_EnumList
- #apply_to_EnumListItem
- #apply_to_Footnote
- #apply_to_Headline
- #apply_to_Index
- #apply_to_ItemList
- #apply_to_ItemListItem
- #apply_to_Keyboard
- #apply_to_MethodList
- #apply_to_MethodListItem
- #apply_to_RefToElement
- #apply_to_RefToOtherFile
- #apply_to_RefToURL
- #apply_to_Reference
- #apply_to_String
- #apply_to_StringElement
- #apply_to_TextBlock
- #apply_to_Var
- #apply_to_Verb
- #apply_to_Verbatim
- #visit

### Included Modules

- RD::AutoLabel
- RD::MethodParse

### Files

- post-install

### Class/Module Index

Quicksearch

- RD
- RD::AutoLabel
- RD::BlockElement
- RD::Code
- RD::ComplexListItem
- RD::DescList
- RD::DescListItem
- RD::DescListItem::Term
- RD::DocumentElement
- RD::DocumentStructure
- RD::Element
- RD::ElementRelationship
- RD::Emphasis
- RD::EnumList
- RD::EnumListItem
- RD::Filter
- RD::Filter::FileInclude
- RD::Footnote
- RD::Headline
- RD::Include
- RD::Index
- RD::InlineElement
- RD::InlineIncludable
- RD::ItemList
- RD::ItemListItem
- RD::Keyboard
- RD::LabelComposable
- RD::LabeledElement
- RD::List
- RD::ListItem
- RD::ListItemComposable
- RD::MethodList
- RD::MethodListItem
- RD::MethodListItem::Term
- RD::MethodParse
- RD::NonterminalElement
- RD::NonterminalInline
- RD::OutputFormatVisitor
- RD::ParserUtility
- RD::Part
- RD::RBLFile
- RD::RBLSuite
- RD::RD2HTMLExtVisitor
- RD::RD2HTMLExtVisitor::EnableBr
- RD::RD2HTMLExtVisitor::HeadElement
- RD::RD2HTMLExtVisitor::HeadLineTitle
- RD::RD2HTMLExtVisitor::HeadlineSecno
- RD::RD2HTMLExtVisitor::NativeInline
- RD::RD2HTMLExtVisitor::RefExtension
- RD::RD2HTMLVisitor
- RD::RD2MANVisitor
- RD::RD2RDOVisitor
- RD::RD2RMIVisitor
- RD::RDElement
- RD::RDInlineParser
- RD::RDParser
- RD::RDTree
- RD::RDVisitor
- RD::Reference
- RD::Reference::Label
- RD::Reference::RDLabel
- RD::Reference::TemporaryLabel
- RD::Reference::URL
- RD::ReferenceResolver
- RD::SearchFile
- RD::StringElement
- RD::TerminalElement
- RD::TerminalInline
- RD::TextBlock
- RD::Tree
- RD::Var
- RD::Verb
- RD::Verbatim
- RD::Version
- RD::Visitor
- Array

No matching classes.

# RD::RD2MANVisitor

### Constants

INCLUDE_SUFFIX
OUTPUT_SUFFIX

  must-have constants

SYSTEM_NAME
SYSTEM_VERSION
VERSION

### Public Class Methods

new() click to toggle source

    # File lib/rd/rd2man-lib.rb, line 31
    def initialize
      @enumcounter = 0
      @index = {}
      @filename = nil
    end

version() click to toggle source

    # File lib/rd/rd2man-lib.rb, line 23
    def self.version
      VERSION
    end

### Public Instance Methods

apply_to_Code(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 162
    def apply_to_Code(element, content)
      %{\\&\\fB#{content.join.sub(/\./, '\\.')}\\fP}
    end

apply_to_DescList(element, items) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 90
    def apply_to_DescList(element, items)
      items.map{ |i| i =~ /\n$/ ? i : i + "\n" }.join("")
    end

apply_to_DescListItem(element, term, description) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 107
    def apply_to_DescListItem(element, term, description)
      anchor = refer(element)
      if description.empty?
        ".TP\n.fi\n.B\n#{term.join(" ")}"
      else
        %[.TP\n.fi\n.B\n#{term.join(" ")}\n#{description.join("\n")}].chomp
      end
    end

apply_to_DocumentElement(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 42
    def apply_to_DocumentElement(element, content)
      content = content.join
      title = guess_title
      title = title.sub(/\.rd$/, '').upcase
      .\\" DO NOT MODIFY THIS FILE! it was generated by rd2.TH #{title} 1 "#{Time.now.strftime '%B %Y'}"#{content}
    end

apply_to_Emphasis(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 158
    def apply_to_Emphasis(element, content)
      %[\\fI#{content.join}\\fP]
    end

apply_to_EnumList(element, items) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 85
    def apply_to_EnumList(element, items)
      @enumcounter = 0
      items.join
    end

apply_to_EnumListItem(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 102
    def apply_to_EnumListItem(element, content)
      @enumcounter += 1
      %[.TP\n#{@enumcounter}.\n#{content.join("\n")}]
    end

apply_to_Footnote(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 215
    def apply_to_Footnote(element, content)
      ""
    end

apply_to_Headline(element, title) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 53
    def apply_to_Headline(element, title)
      title = title.join(" ")
      element.level <= 1 ? ".SH #{title}\n" : ".SS #{title}\n"
    end

apply_to_Index(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 174
    def apply_to_Index(element, content)
      tmp = []
      element.each do |i|
        tmp.push(i) if i.is_a?(String)
      end
      key = meta_char_escape(tmp.join)
      if @index.has_key?(key)
        # warning?
        ""
      else
        num = @index[key] = @index.size
        %{\\&\\fB#{content.join.sub(/\./, '\\.')}\\fP}
      end
    end

apply_to_ItemList(element, items) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 79
    def apply_to_ItemList(element, items)
      items.collect! do |x| x.sub(/\n\n/, "\n") end
      items = items.join(".IP\n.B\n\\(bu\n")  # "\\(bu" -> "" ?
      ".IP\n.B\n\\(bu\n" + items
    end

apply_to_ItemListItem(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 98
    def apply_to_ItemListItem(element, content)
      content.map{ |c| c =~ /\n$/ ? c : c + "\n" }.join("")
    end

apply_to_Keyboard(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 170
    def apply_to_Keyboard(element, content)
      content.join
    end

apply_to_MethodList(element, items) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 94
    def apply_to_MethodList(element, items)
      items.map{ |i| i =~ /\n$/ ? i : i + "\n" }.join("")
    end

apply_to_MethodListItem(element, term, description) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 116
    def apply_to_MethodListItem(element, term, description)
      term = parse_method(term)  # maybe: term -> element.term
      anchor = refer(element)
      if description.empty?
        ".TP\n.fi\n.B\n#{term.join(" ")}"
      else
        %[.TP\n.fi\n.B\n#{term.join(" ")}\n#{description.join("\n")}]
      end
    end

apply_to_RefToElement(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 202
    def apply_to_RefToElement(element, content)
      content = content.join
      content.sub(/^function#/, "")
    end

apply_to_RefToOtherFile(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 207
    def apply_to_RefToOtherFile(element, content)
      content.join
    end

apply_to_RefToURL(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 211
    def apply_to_RefToURL(element, content)
      content.join
    end

apply_to_Reference(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 189
    def apply_to_Reference(element, content)
      case element.label
      when Reference::URL
        apply_to_RefToURL(element, content)
      when Reference::RDLabel
        if element.label.filename
          apply_to_RefToOtherFile(element, content)
        else
          apply_to_RefToElement(element, content)
        end
      end
    end

apply_to_String(element) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 223
    def apply_to_String(element)
      meta_char_escape(element)
    end

apply_to_StringElement(element) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 154
    def apply_to_StringElement(element)
      apply_to_String(element.content)
    end

apply_to_TextBlock(element, content) click to toggle source

RDVisitor#apply_to_Include

    # File lib/rd/rd2man-lib.rb, line 60
    def apply_to_TextBlock(element, content)
      if RD::DescListItem === element.parent ||
          RD::ItemListItem === element.parent ||
          RD::EnumListItem === element.parent
        return content.join
      else
        return ".PP\n" + content.join
      end
    end

apply_to_Var(element, content) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 166
    def apply_to_Var(element, content)
      content.join
    end

apply_to_Verb(element) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 219
    def apply_to_Verb(element)
      apply_to_String(element.content)
    end

apply_to_Verbatim(element) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 70
    def apply_to_Verbatim(element)
      content = []
      element.each_line do |i|
        content.push(apply_to_String(i))
      end
      # Can we use BLOCKQUOTE such like?
      %[.nf\n\\&    #{content.join("\\&    ")}.fi\n]
    end

visit(tree) click to toggle source

    # File lib/rd/rd2man-lib.rb, line 37
    def visit(tree)
      prepare_labels(tree, "")
      super(tree)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.