class Dox::Printers::DocumentPrinter
Public Class Methods
new(output)
click to toggle source
Calls superclass method
Dox::Printers::BasePrinter::new
# File lib/dox/printers/document_printer.rb, line 4 def initialize(output) super(body) @output = output end
Public Instance Methods
print(passed_examples)
click to toggle source
# File lib/dox/printers/document_printer.rb, line 9 def print(passed_examples) spec['paths'] = {} spec['tags'] = [] spec['x-tagGroups'] = [] passed_examples.sort.each do |_, resource_group| group_printer.print(resource_group) end order_groups @output.puts(JSON.pretty_generate(spec)) end
Private Instance Methods
acquire_desc(path)
click to toggle source
# File lib/dox/printers/document_printer.rb, line 40 def acquire_desc(path) read_file(path) end
adjust_description(description)
click to toggle source
# File lib/dox/printers/document_printer.rb, line 36 def adjust_description(description) description.end_with?('.md') ? acquire_desc(description) : description end
body()
click to toggle source
# File lib/dox/printers/document_printer.rb, line 25 def body { openapi: Dox.config.openapi_version || '3.0.0', info: { title: Dox.config.title || 'API Documentation', description: adjust_description(Dox.config.header_description || ''), version: Dox.config.api_version || '1.0' } } end
group_printer()
click to toggle source
# File lib/dox/printers/document_printer.rb, line 44 def group_printer @group_printer ||= ResourceGroupPrinter.new(spec) end
order_groups()
click to toggle source
# File lib/dox/printers/document_printer.rb, line 48 def order_groups return if (Dox.config.groups_order || []).empty? spec['x-tagGroups'] = spec['x-tagGroups'].sort_by do |tag| Dox.config.groups_order.index(tag[:name]) || 100 end end