class Puppet::Application::Doc
Attributes
manifest[RW]
unknown_args[RW]
Public Instance Methods
handle_unknown( opt, arg )
click to toggle source
# File lib/puppet/application/doc.rb 118 def handle_unknown( opt, arg ) 119 @unknown_args << {:opt => opt, :arg => arg } 120 true 121 end
help()
click to toggle source
# File lib/puppet/application/doc.rb 57 def help 58 <<-HELP 59 60 puppet-doc(8) -- #{summary} 61 ======== 62 63 SYNOPSIS 64 -------- 65 Generates a reference for all Puppet types. Largely meant for internal 66 Puppet Inc. use. (Deprecated) 67 68 69 USAGE 70 ----- 71 puppet doc [-h|--help] [-l|--list] 72 [-r|--reference <reference-name>] 73 74 75 DESCRIPTION 76 ----------- 77 This deprecated command generates a Markdown document to stdout 78 describing all installed Puppet types or all allowable arguments to 79 puppet executables. It is largely meant for internal use and is used to 80 generate the reference document available on the Puppet Inc. web site. 81 82 For Puppet module documentation (and all other use cases) this command 83 has been superseded by the "puppet-strings" 84 module - see https://github.com/puppetlabs/puppetlabs-strings for more information. 85 86 This command (puppet-doc) will be removed once the 87 puppetlabs internal documentation processing pipeline is completely based 88 on puppet-strings. 89 90 OPTIONS 91 ------- 92 93 * --help: 94 Print this help message 95 96 * --reference: 97 Build a particular reference. Get a list of references by running 98 'puppet doc --list'. 99 100 101 EXAMPLE 102 ------- 103 $ puppet doc -r type > /tmp/type_reference.markdown 104 105 106 AUTHOR 107 ------ 108 Luke Kanies 109 110 111 COPYRIGHT 112 --------- 113 Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License 114 115 HELP 116 end
other()
click to toggle source
# File lib/puppet/application/doc.rb 154 def other 155 text = String.new 156 with_contents = options[:references].length <= 1 157 exit_code = 0 158 require_relative '../../puppet/util/reference' 159 options[:references].sort_by(&:to_s).each do |name| 160 section = Puppet::Util::Reference.reference(name) 161 raise _("Could not find reference %{name}") % { name: name } unless section 162 163 begin 164 # Add the per-section text, but with no ToC 165 text += section.send(options[:format], with_contents) 166 rescue => detail 167 Puppet.log_exception(detail, _("Could not generate reference %{name}: %{detail}") % { name: name, detail: detail }) 168 exit_code = 1 169 next 170 end 171 end 172 173 text += Puppet::Util::Reference.footer unless with_contents # We've only got one reference 174 175 if options[:mode] == :pdf 176 Puppet::Util::Reference.pdf(text) 177 else 178 puts text 179 end 180 181 exit exit_code 182 end
preinit()
click to toggle source
# File lib/puppet/application/doc.rb 9 def preinit 10 {:references => [], :mode => :text, :format => :to_markdown }.each do |name,value| 11 options[name] = value 12 end 13 @unknown_args = [] 14 @manifest = false 15 end
rdoc()
click to toggle source
# File lib/puppet/application/doc.rb 127 def rdoc 128 exit_code = 0 129 files = [] 130 unless @manifest 131 env = Puppet.lookup(:current_environment) 132 files += env.modulepath 133 files << ::File.dirname(env.manifest) if env.manifest != Puppet::Node::Environment::NO_MANIFEST 134 end 135 files += command_line.args 136 Puppet.info _("scanning: %{files}") % { files: files.inspect } 137 138 Puppet.settings[:document_all] = options[:all] || false 139 begin 140 require_relative '../../puppet/util/rdoc' 141 if @manifest 142 Puppet::Util::RDoc.manifestdoc(files) 143 else 144 options[:outputdir] = "doc" unless options[:outputdir] 145 Puppet::Util::RDoc.rdoc(options[:outputdir], files, options[:charset]) 146 end 147 rescue => detail 148 Puppet.log_exception(detail, _("Could not generate documentation: %{detail}") % { detail: detail }) 149 exit_code = 1 150 end 151 exit exit_code 152 end
run_command()
click to toggle source
# File lib/puppet/application/doc.rb 123 def run_command 124 return [:rdoc].include?(options[:mode]) ? send(options[:mode]) : other 125 end
setup()
click to toggle source
# File lib/puppet/application/doc.rb 184 def setup 185 # sole manifest documentation 186 if command_line.args.size > 0 187 options[:mode] = :rdoc 188 @manifest = true 189 end 190 191 if options[:mode] == :rdoc 192 setup_rdoc 193 else 194 setup_reference 195 end 196 197 setup_logging 198 end
setup_logging()
click to toggle source
# File lib/puppet/application/doc.rb 227 def setup_logging 228 Puppet::Util::Log.level = :warning 229 230 set_log_level 231 232 Puppet::Util::Log.newdestination(:console) 233 end
setup_rdoc()
click to toggle source
# File lib/puppet/application/doc.rb 213 def setup_rdoc 214 # consume the unknown options 215 # and feed them as settings 216 if @unknown_args.size > 0 217 @unknown_args.each do |option| 218 # force absolute path for modulepath when passed on commandline 219 if option[:opt]=="--modulepath" 220 option[:arg] = option[:arg].split(::File::PATH_SEPARATOR).collect { |p| ::File.expand_path(p) }.join(::File::PATH_SEPARATOR) 221 end 222 Puppet.settings.handlearg(option[:opt], option[:arg]) 223 end 224 end 225 end
setup_reference()
click to toggle source
# File lib/puppet/application/doc.rb 200 def setup_reference 201 if options[:all] 202 # Don't add dynamic references to the "all" list. 203 require_relative '../../puppet/util/reference' 204 refs = Puppet::Util::Reference.references(Puppet.lookup(:current_environment)) 205 options[:references] = refs.reject do |ref| 206 Puppet::Util::Reference.reference(ref).dynamic? 207 end 208 end 209 210 options[:references] << :type if options[:references].empty? 211 end
summary()
click to toggle source
# File lib/puppet/application/doc.rb 53 def summary 54 _("Generate Puppet references") 55 end