Class: Puppet::Application::Doc
Constant Summary
DOCPATTERN
Instance Attribute Summary collapse
#command_line, #options
Instance Method Summary
collapse
[], banner, clear!, clear?, controlled_run, exit, find, #handlearg, #help, #initialize, interrupted?, #main, #name, option, option_parser_commands, #parse_options, restart!, restart_requested?, #run, run_mode, #set_run_mode, should_not_parse_config, should_parse_config, #should_parse_config?, should_parse_config?, stop!, stop_requested?
Methods included from Util
activerecord_version, benchmark, chuser, classproxy, #execfail, #execpipe, execute, logmethods, memory, proxy, recmkdir, secure_open, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, which, withumask
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Instance Attribute Details
Returns the value of attribute manifest.
8
9
10
|
# File 'lib/puppet/application/doc.rb', line 8
def manifest
@manifest
end
|
#unknown_args ⇒ Object
Returns the value of attribute unknown_args.
8
9
10
|
# File 'lib/puppet/application/doc.rb', line 8
def unknown_args
@unknown_args
end
|
Instance Method Details
#handle_unknown(opt, arg) ⇒ Object
53
54
55
56
|
# File 'lib/puppet/application/doc.rb', line 53
def handle_unknown( opt, arg )
@unknown_args << {:opt => opt, :arg => arg }
true
end
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/puppet/application/doc.rb', line 95
def other
text = ""
with_contents = options[:references].length <= 1
exit_code = 0
require 'puppet/util/reference'
options[:references].sort { |a,b| a.to_s <=> b.to_s }.each do |name|
raise "Could not find reference #{name}" unless section = Puppet::Util::Reference.reference(name)
begin
text += section.send(options[:format], with_contents)
rescue => detail
puts detail.backtrace
$stderr.puts "Could not generate reference #{name}: #{detail}"
exit_code = 1
next
end
end
text += Puppet::Util::Reference. unless with_contents
if options[:mode] == :pdf
Puppet::Util::Reference.pdf(text)
else
puts text
end
exit exit_code
end
|
10
11
12
13
14
15
16
|
# File 'lib/puppet/application/doc.rb', line 10
def preinit
{:references => [], :mode => :text, :format => :to_markdown }.each do |name,value|
options[name] = value
end
@unknown_args = []
@manifest = false
end
|
62
63
64
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/puppet/application/doc.rb', line 62
def rdoc
exit_code = 0
files = []
unless @manifest
env = Puppet::Node::Environment.new
files += env.modulepath
files << File.dirname(env[:manifest])
end
files += command_line.args
Puppet.info "scanning: #{files.inspect}"
Puppet.settings.setdefaults(
"puppetdoc",
"document_all" => [false, "Document all resources"]
)
Puppet.settings[:document_all] = options[:all] || false
begin
require 'puppet/util/rdoc'
if @manifest
Puppet::Util::RDoc.manifestdoc(files)
else
options[:outputdir] = "doc" unless options[:outputdir]
Puppet::Util::RDoc.rdoc(options[:outputdir], files, options[:charset])
end
rescue => detail
puts detail.backtrace if Puppet[:trace]
$stderr.puts "Could not generate documentation: #{detail}"
exit_code = 1
end
exit exit_code
end
|
#run_command ⇒ Object
58
59
60
|
# File 'lib/puppet/application/doc.rb', line 58
def run_command
return[:rdoc].include?(options[:mode]) ? send(options[:mode]) : other
end
|
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/puppet/application/doc.rb', line 125
def setup
if command_line.args.size > 0
options[:mode] = :rdoc
@manifest = true
end
if options[:mode] == :rdoc
setup_rdoc
else
setup_reference
end
end
|
#setup_rdoc(dummy_argument = :work_arround_for_ruby_GC_bug) ⇒ Object
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/puppet/application/doc.rb', line 151
def setup_rdoc(dummy_argument=:work_arround_for_ruby_GC_bug)
if @unknown_args.size > 0
@unknown_args.each do |option|
if option[:opt]=="--modulepath" or option[:opt] == "--manifestdir"
option[:arg] = option[:arg].split(':').collect { |p| File.expand_path(p) }.join(':')
end
Puppet.settings.handlearg(option[:opt], option[:arg])
end
end
Puppet.parse_config
if options[:debug] or options[:verbose]
if options[:debug]
Puppet::Util::Log.level = :debug
else
Puppet::Util::Log.level = :info
end
Puppet::Util::Log.newdestination(:console)
end
end
|
#setup_reference ⇒ Object
139
140
141
142
143
144
145
146
147
148
149
|
# File 'lib/puppet/application/doc.rb', line 139
def setup_reference
if options[:all]
require 'puppet/util/reference'
options[:references] = Puppet::Util::Reference.references.reject do |ref|
Puppet::Util::Reference.reference(ref).dynamic?
end
end
options[:references] << :type if options[:references].empty?
end
|