Add a server action to the yardoc face

This commit adds the `puppet yardoc server` action which is designed to
mimic `yard server --gems`. This action generates YARD indicies by invoking
`puppet yardoc modules` and then configures `YARD::CLI::Server` to serve the
resulting documentation.
This commit is contained in:
Charlie Sharpsteen 2014-06-01 17:37:18 -07:00
parent e2a9e40f01
commit afb053c03b
1 changed files with 24 additions and 0 deletions

View File

@ -85,4 +85,28 @@ Puppet::Face.define(:yardoc, '0.0.1') do
end end
end end
end end
action(:server) do
summary "Serve YARD documentation for modules."
when_invoked do |*args|
check_required_features
require 'puppetx/yardoc/yard/plugin'
opts = args.pop
# 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.
module_list = Puppet::Face[:yardoc, :current].modules
module_tuples = module_list.map do |mod|
name = (mod.forge_name || mod.name).gsub('/', '-')
yard_index = File.join(mod.path, '.yardoc')
[name, yard_index]
end
YARD::CLI::Server.run('-m', *module_tuples.flatten)
end
end
end end