2014-05-16 17:54:34 +00:00
|
|
|
require 'puppet/face'
|
2014-09-19 17:59:37 +00:00
|
|
|
require 'puppetx/puppetlabs/strings/actions'
|
|
|
|
|
|
|
|
include Puppetx::PuppetLabs::Strings::Actions
|
2014-05-16 17:54:34 +00:00
|
|
|
|
2014-09-11 00:07:33 +00:00
|
|
|
Puppet::Face.define(:strings, '0.0.1') do
|
2014-06-01 06:24:27 +00:00
|
|
|
summary "Generate Puppet documentation with YARD."
|
2014-05-16 17:54:34 +00:00
|
|
|
|
|
|
|
action(:yardoc) do
|
|
|
|
default
|
|
|
|
|
2014-06-01 19:33:34 +00:00
|
|
|
summary "Generate YARD documentation from files."
|
2014-06-01 06:24:27 +00:00
|
|
|
arguments "[manifest_file.pp ...]"
|
|
|
|
|
2014-05-26 19:02:59 +00:00
|
|
|
when_invoked do |*args|
|
2014-06-01 19:33:34 +00:00
|
|
|
check_required_features
|
2014-09-19 17:59:37 +00:00
|
|
|
require 'puppetx/puppetlabs/strings/yard/plugin'
|
2014-05-30 16:59:55 +00:00
|
|
|
|
2014-05-26 19:02:59 +00:00
|
|
|
# The last element of the argument array should be the options hash.
|
|
|
|
#
|
|
|
|
# NOTE: The Puppet Face will throw 'unrecognized option' errors if any
|
|
|
|
# YARD options are passed to it. The best way to approach this problem is
|
|
|
|
# by using the `.yardopts` file. YARD will autoload any options placed in
|
|
|
|
# that file.
|
|
|
|
opts = args.pop
|
|
|
|
|
|
|
|
# For now, assume the remaining positional args are a list of manifest
|
2014-06-03 04:55:27 +00:00
|
|
|
# and ruby files to parse.
|
2014-06-03 02:38:19 +00:00
|
|
|
yard_args = (args.empty? ? MODULE_SOURCEFILES : args)
|
2014-05-24 19:54:22 +00:00
|
|
|
|
2014-09-19 17:59:37 +00:00
|
|
|
generate_documentation(*yard_args)
|
2014-05-16 17:54:34 +00:00
|
|
|
end
|
|
|
|
end
|
2014-06-01 19:33:34 +00:00
|
|
|
|
|
|
|
# NOTE: Modeled after the `yard gems` command which builds doc indicies
|
|
|
|
# (.yardoc directories) for Ruby Gems. Currently lacks the fine-grained
|
|
|
|
# control over where these indicies are created and just dumps them in the
|
|
|
|
# module roots.
|
2014-06-02 00:37:18 +00:00
|
|
|
|
|
|
|
action(:server) do
|
|
|
|
summary "Serve YARD documentation for modules."
|
|
|
|
|
|
|
|
when_invoked do |*args|
|
|
|
|
check_required_features
|
2014-09-16 16:07:59 +00:00
|
|
|
require 'puppetx/puppetlabs/strings/yard/plugin'
|
2014-09-19 21:44:22 +00:00
|
|
|
|
2014-06-02 00:37:18 +00:00
|
|
|
opts = args.pop
|
|
|
|
|
2014-09-19 17:59:37 +00:00
|
|
|
module_names = args
|
|
|
|
|
2014-06-02 00:37:18 +00:00
|
|
|
# FIXME: This is pretty inefficient as it forcibly re-generates the YARD
|
|
|
|
# indicies each time the server is started. However, it ensures things are
|
|
|
|
# generated properly.
|
2014-09-19 17:59:37 +00:00
|
|
|
module_list = index_documentation_for_modules(module_names)
|
2014-06-02 00:37:18 +00:00
|
|
|
|
2014-09-19 17:59:37 +00:00
|
|
|
module_tuples = generate_module_tuples(module_list)
|
2014-06-02 00:37:18 +00:00
|
|
|
|
2014-09-19 17:59:37 +00:00
|
|
|
module_tuples.map! do |mod|
|
|
|
|
[mod[:name], mod[:index_path]]
|
2014-06-02 00:37:18 +00:00
|
|
|
end
|
|
|
|
|
2014-06-03 02:38:19 +00:00
|
|
|
# The `-m` flag means a list of name/path pairs will follow. The name is
|
|
|
|
# used as the module name and the path indicates which `.yardoc` index to
|
|
|
|
# generate documentation from.
|
2014-09-22 23:54:28 +00:00
|
|
|
yard_args = %w[-m -q] + module_tuples.flatten
|
2014-06-03 02:38:19 +00:00
|
|
|
merge_puppet_args!(yard_args)
|
|
|
|
|
2014-09-19 17:59:37 +00:00
|
|
|
serve_documentation(*yard_args)
|
2014-06-02 00:37:18 +00:00
|
|
|
end
|
|
|
|
end
|
2014-05-16 17:54:34 +00:00
|
|
|
end
|
2014-09-19 17:59:37 +00:00
|
|
|
|