Module: PuppetX::PuppetLabs::Strings::Util
- Defined in:
- lib/puppet_x/puppetlabs/strings/util.rb
Constant Summary collapse
- MODULE_SOURCEFILES =
['manifests/**/*.pp', 'lib/**/*.rb']
Class Method Summary collapse
Class Method Details
.generate(args = []) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/puppet_x/puppetlabs/strings/util.rb', line 6 def self.generate(args = []) yardoc_actions = PuppetX::PuppetLabs::Strings::Actions.new(Puppet[:debug], Puppet[:trace]) # The last element of the argument array should be the options hash. # We don't have any options yet, so for now just pop the hash off and # toss it. # # 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. = args.pop YARD::Config. = YARD::Config..merge() if # For now, assume the remaining positional args are a list of manifest # and ruby files to parse. yard_args = (args.empty? ? MODULE_SOURCEFILES : args) # If json is going to be emitted to stdout, suppress statistics. if && [:emit_json_stdout] yard_args.push('--no-stats') end # This line monkeypatches yard's progress indicator so it doesn't write # all over the terminal. This should definitely not be in real code, but # it's very handy for debugging with pry #class YARD::Logger; def progress(*args); end; end YARD::Tags::Library.define_directive("puppet.type.param", :with_types_and_name, PuppetX::PuppetLabs::Strings::YARD::Tags::PuppetTypeParameterDirective) yardoc_actions.generate_documentation(*yard_args) end |
.serve(args = []) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/puppet_x/puppetlabs/strings/util.rb', line 40 def self.serve(args = []) server_actions = PuppetX::PuppetLabs::Strings::Actions.new(Puppet[:debug], Puppet[:trace]) args.pop module_names = args # 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 = server_actions.index_documentation_for_modules(module_names, MODULE_SOURCEFILES) module_tuples = server_actions.generate_module_tuples(module_list) module_tuples.map! do |mod| [mod[:name], mod[:index_path]] end # 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. yard_args = %w[-m -q] + module_tuples.flatten server_actions.serve_documentation(*yard_args) end |