class Fern::Documentation::MarkdownGenerator
Constants
- TEMPLATE
Public Class Methods
new(analysis)
click to toggle source
# File lib/fern/documentation/markdown_generator.rb, line 46 def initialize(analysis) @analysis = analysis end
Public Instance Methods
generate()
click to toggle source
# File lib/fern/documentation/markdown_generator.rb, line 50 def generate params = build_params Mustache.render( TEMPLATE, verb: @analysis[:verb], path: @analysis[:path], controller: @analysis[:controller], action: @analysis[:action], doc: @analysis[:doc], has_parameters: params.present?, parameters: params, has_form: @analysis[:form].present?, form: @analysis[:form], presenter: @analysis[:presenter] ) end
Private Instance Methods
build_param(name, config)
click to toggle source
# File lib/fern/documentation/markdown_generator.rb, line 75 def build_param(name, config) constraints = config[:constraints] { name: name, type: config[:type], array: check(constraints[:array]), required: check(constraints[:required]), min: constraints[:min], max: constraints[:max], values: constraints[:values]&.join(', '), default: constraints[:default] } end
build_params()
click to toggle source
# File lib/fern/documentation/markdown_generator.rb, line 70 def build_params return if @analysis[:params].nil? @analysis[:params].map { |name, config| build_param(name, config) } end
check(val)
click to toggle source
# File lib/fern/documentation/markdown_generator.rb, line 89 def check(val) val ? '✓' : '' end