(PDOC-63) Add initial YARD configuration.
This commit adds the initial YARD configuration. Subsequent commits will integrate the code objects, handlers, parsers, tags, and templates to support Puppet code.
This commit is contained in:
parent
ea9dd0c846
commit
d4bab8a5ab
|
@ -18,6 +18,9 @@ module PuppetStrings
|
|||
# @option options [Array<String>] :yard_args The arguments to pass to yard.
|
||||
# @return [void]
|
||||
def self.generate(search_patterns = DEFAULT_SEARCH_PATTERNS, options = {})
|
||||
require 'puppet-strings/yard'
|
||||
PuppetStrings::Yard.setup!
|
||||
|
||||
# Format the arguments to YARD
|
||||
args = ['doc']
|
||||
args << '--debug' if options[:debug]
|
||||
|
@ -51,6 +54,9 @@ module PuppetStrings
|
|||
# Runs the YARD documentation server.
|
||||
# @param [Array<String>] args The arguments to YARD.
|
||||
def self.run_server(*args)
|
||||
require 'puppet-strings/yard'
|
||||
PuppetStrings::Yard.setup!
|
||||
|
||||
YARD::CLI::Server.run(*args)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
require 'yard'
|
||||
|
||||
# Module for YARD related functionality.
|
||||
module PuppetStrings::Yard
|
||||
require 'puppet-strings/yard/code_objects'
|
||||
require 'puppet-strings/yard/handlers'
|
||||
require 'puppet-strings/yard/tags'
|
||||
require 'puppet-strings/yard/parsers'
|
||||
|
||||
# Sets up YARD for use with puppet-strings.
|
||||
# @return [void]
|
||||
def self.setup!
|
||||
# Register the template path
|
||||
YARD::Templates::Engine.register_template_path(File.join(File.dirname(__FILE__), 'yard', 'templates'))
|
||||
end
|
||||
end
|
||||
|
||||
# Monkey patch YARD::CLI::Yardoc#all_objects to return our custom code objects.
|
||||
# @private
|
||||
class YARD::CLI::Yardoc
|
||||
def all_objects
|
||||
YARD::Registry.all(
|
||||
:root,
|
||||
:module,
|
||||
:class
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# Monkey patch the stats object to return statistics for our objects.
|
||||
# This is the recommended way to add custom stats.
|
||||
# @private
|
||||
class YARD::CLI::Stats
|
||||
def output(name, data, undoc = nil)
|
||||
# Monkey patch output to accommodate our larger header widths
|
||||
@total += data if data.is_a?(Integer) && undoc
|
||||
@undocumented += undoc if undoc.is_a?(Integer)
|
||||
if undoc
|
||||
data = ('%5s (% 5d undocumented)' % [data, undoc])
|
||||
else
|
||||
data = '%5s' % data
|
||||
end
|
||||
log.puts('%-21s %s' % [name + ':', data])
|
||||
end
|
||||
|
||||
# This differs from the YARD implementation in that it considers
|
||||
# a docstring without text but with tags to be undocumented.
|
||||
def type_statistics_all(type)
|
||||
objs = all_objects.select {|m| m.type == type }
|
||||
undoc = objs.find_all {|m| m.docstring.all.empty? }
|
||||
@undoc_list |= undoc if @undoc_list
|
||||
[objs.size, undoc.size]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
# The module for custom YARD code objects.
|
||||
module PuppetStrings::Yard::CodeObjects
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
# The module for custom YARD handlers.
|
||||
module PuppetStrings::Yard::Handlers
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
# The module for custom YARD parsers.
|
||||
module PuppetStrings::Yard::Parsers
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
# The module for custom YARD tags.
|
||||
module PuppetStrings::Yard::Tags
|
||||
end
|
Loading…
Reference in New Issue