class Rspec::Usecases::Generator::MarkdownGenerator

Markdown generator can build a markdown documentation file based on the document content

Public Instance Methods

generate() click to toggle source

rubocop:enable Metrics/AbcSize

# File lib/rspec/usecases/generator/markdown_generator.rb, line 28
def generate
  print_document_header
  print_groups(document.groups)
end
run() click to toggle source

rubocop:disable Metrics/AbcSize

# File lib/rspec/usecases/generator/markdown_generator.rb, line 11
def run
  @key_width = 30
  @indent_size = 0

  generate

  print_output if options.printable?

  return unless options.writable?

  write_file(options.file)
  prettier_file(options.file) if options.prettier?

  open_file_in_vscode(options.file) if options.openable?
end

Private Instance Methods

bullet(title) click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 126
def bullet(title)
  write_line("- #{title}") if title != ''
end
h1(title) click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 102
def h1(title)
  write_line("# #{title}") if title != ''
end
h2(title) click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 106
def h2(title)
  write_line("## #{title}") if title != ''
end
h3(title) click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 110
def h3(title)
  write_line("### #{title}") if title != ''
end
h4(title) click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 114
def h4(title)
  write_line("#### #{title}") if title != ''
end
h5(title) click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 118
def h5(title)
  write_line("##### #{title}") if title != ''
end
h6(title) click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 122
def h6(title)
  write_line("###### #{title}") if title != ''
end
hr() click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 130
def hr
  write_line '---'
end
print_contents(usecase) click to toggle source
print_document_header() click to toggle source
print_groups(groups) click to toggle source
print_summary(usecase) click to toggle source
print_usage(usecase) click to toggle source
print_usecase(usecase) click to toggle source
render_code(content) click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 90
def render_code(content)
  h4 content.title
  # write_line content.note if content.note
  render_code_block(content.source, content.code_type) unless content.source == ''
end
render_code_block(source, code_type) click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 96
def render_code_block(source, code_type)
  write_line "```#{code_type}"
  write_line source
  write_line '```'
end
render_outcome(content) click to toggle source
# File lib/rspec/usecases/generator/markdown_generator.rb, line 85
def render_outcome(content)
  bullet content.title
  write_line content.note if content.note
end