module Puppet::Interface::TinyDocs

This module can be mixed in to provide a minimal set of documentation attributes. @api public

Public Instance Methods

build_synopsis(face, action = nil, arguments = nil) click to toggle source

@api private

# File lib/puppet/interface/documentation.rb, line 81
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

    display_global_options.sort.each do |option|
      wrap = %w{ [ ] }
      s.group(0, *wrap) do
        desc = Puppet.settings.setting(option).desc
        type = Puppet.settings.setting(option).default
        type ||= Puppet.settings.setting(option).type.to_s.upcase
        s.text "--#{option} #{type}"
        s.breakable
      end
      s.breakable
    end

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