Module: Puppet::Interface::TinyDocs

Extended by:
DocGen
Included in:
FullDocs, Option
Defined in:
lib/vendor/puppet/interface/documentation.rb

Instance Method Summary collapse

Methods included from DocGen

attr_doc, strip_whitespace

Instance Method Details

#build_synopsis(face, action = nil, arguments = nil) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/vendor/puppet/interface/documentation.rb', line 65

def build_synopsis(face, action = nil, arguments = nil)
  output = PrettyPrint.format do |s|
    s.text("puppet #{face}")
    s.text(" #{action}") unless action.nil?
    s.text(" ")

    options.each do |option|
      option = get_option(option)
      wrap = option.required? ? %w{ < > } : %w{ [ ] }

      s.group(0, *wrap) do
        option.optparse.each do |item|
          unless s.current_group.first?
            s.breakable
            s.text '|'
            s.breakable
          end
          s.text item
        end
      end

      s.breakable
    end

    if arguments then
      s.text arguments.to_s
    end
  end
end