@@ -29,13 +29,13 @@ def self.generate(search_patterns = DEFAULT_SEARCH_PATTERNS, options = {})
2929 args << '--backtrace' if options [ :backtrace ]
3030 args << "-m#{ options [ :markup ] || 'markdown' } "
3131
32- if options [ :json ]
33- json_file = options [ :path ]
32+ if options [ :json ] || options [ :markdown ]
33+ file = options [ :path ]
3434 # Disable output and prevent stats/progress when writing to STDOUT
3535 args << '-n'
36- args << '-q' unless json_file
37- args << '--no-stats' unless json_file
38- args << '--no-progress' unless json_file
36+ args << '-q' unless file
37+ args << '--no-stats' unless file
38+ args << '--no-progress' unless file
3939 end
4040
4141 yard_args = options [ :yard_args ]
@@ -47,20 +47,25 @@ def self.generate(search_patterns = DEFAULT_SEARCH_PATTERNS, options = {})
4747
4848 # If outputting JSON, render the output
4949 if options [ :json ]
50- require 'puppet-strings/json'
51- PuppetStrings ::Json . render ( options [ :path ] )
50+ render_json ( options [ :path ] )
5251 end
5352
53+ # If outputting Markdown, render the output
5454 if options [ :markdown ]
55- require 'puppet-strings/markdown'
56- if options [ :stdout ]
57- PuppetStrings ::Markdown . generate ( 'stdout' )
58- else
59- PuppetStrings ::Markdown . generate ( options [ :path ] )
60- end
55+ render_markdown ( options [ :path ] )
6156 end
6257 end
6358
59+ def self . render_json ( path )
60+ require 'puppet-strings/json'
61+ PuppetStrings ::Json . render ( path )
62+ end
63+
64+ def self . render_markdown ( path )
65+ require 'puppet-strings/markdown'
66+ PuppetStrings ::Markdown . render ( path )
67+ end
68+
6469 # Runs the YARD documentation server.
6570 # @param [Array<String>] args The arguments to YARD.
6671 def self . run_server ( *args )
0 commit comments