diff options
author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-27 12:12:05 -0700 |
---|---|---|
committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-27 12:12:05 -0700 |
commit | ebf49f98357f93b33e09c0ecbdee1c5c2db87569 (patch) | |
tree | 8500c7f7c87ca5f32f22a70fde97b738c0427f54 /lib/puppet/interface.rb | |
parent | 1aaf5fdc51e165c7d0f377450016cd4fb3767c02 (diff) | |
parent | 0256d67e1a51a37f2c87ec197bdff6ef3a6b269f (diff) | |
download | puppet-ebf49f98357f93b33e09c0ecbdee1c5c2db87569.tar.gz puppet-ebf49f98357f93b33e09c0ecbdee1c5c2db87569.tar.xz puppet-ebf49f98357f93b33e09c0ecbdee1c5c2db87569.zip |
Merge branch 'feature/2.7.x/6962-finish-documentation-api-for-faces' into 2.7.x
Diffstat (limited to 'lib/puppet/interface.rb')
-rw-r--r-- | lib/puppet/interface.rb | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb index ba68ac65b..c7a167d3a 100644 --- a/lib/puppet/interface.rb +++ b/lib/puppet/interface.rb @@ -1,7 +1,11 @@ require 'puppet' require 'puppet/util/autoload' +require 'puppet/interface/documentation' +require 'prettyprint' class Puppet::Interface + include FullDocs + require 'puppet/interface/face_collection' require 'puppet/interface/action_manager' @@ -65,27 +69,33 @@ class Puppet::Interface Puppet.warning("set_default_format is deprecated (and ineffective); use render_as on your actions instead.") end + ######################################################################## # Documentation. We currently have to rewrite both getters because we share # the same instance between build-time and the runtime instance. When that # splits out this should merge into a module that both the action and face # include. --daniel 2011-04-17 - attr_accessor :summary, :description - def summary(value = nil) - self.summary = value unless value.nil? - @summary - end - def summary=(value) - value = value.to_s - value =~ /\n/ and - raise ArgumentError, "Face summary should be a single line; put the long text in 'description' instead." - - @summary = value - end - - def description(value = nil) - self.description = value unless value.nil? - @description + def synopsis + output = PrettyPrint.format do |s| + s.text("puppet #{name} <action>") + s.breakable + + 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 + end + end end @@ -97,9 +107,15 @@ class Puppet::Interface raise ArgumentError, "Cannot create face #{name.inspect} with invalid version number '#{version}'!" end - @name = Puppet::Interface::FaceCollection.underscorize(name) + @name = Puppet::Interface::FaceCollection.underscorize(name) @version = version + # The few bits of documentation we actually demand. The default license + # is a favour to our end users; if you happen to get that in a core face + # report it as a bug, please. --daniel 2011-04-26 + @authors = [] + @license = 'All Rights Reserved' + instance_eval(&block) if block_given? end |