File: .yard_gfm_support.rb

package info (click to toggle)
ruby-oauth2 2.0.17-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,608 kB
  • sloc: ruby: 5,441; javascript: 529; makefile: 4; sh: 4
file content (22 lines) | stat: -rw-r--r-- 895 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Gratefully and liberally taken from the MIT-licensed https://github.com/bensheldon/good_job/pull/113/files
require "kramdown"
require "kramdown-parser-gfm"

# Custom markup provider class that always renders Kramdown using GFM (Github Flavored Markdown).
# GFM is needed to render markdown tables and fenced code blocks in the README.
class KramdownGfmDocument < Kramdown::Document
  def initialize(source, options = {})
    options[:input] = "GFM" unless options.key?(:input)
    super(source, options)
  end
end

# Insert the new provider as the highest priority option for Markdown.
# See:
# - https://github.com/lsegal/yard/issues/1157
# - https://github.com/lsegal/yard/issues/1017
# - https://github.com/lsegal/yard/blob/main/lib/yard/templates/helpers/markup_helper.rb
YARD::Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS[:markdown].insert(
  0,
  {const: "KramdownGfmDocument"},
)