Skip to content

Commit

Permalink
Fixes Apipie#544: Optional rdoc dependency (Apipie#683)
Browse files Browse the repository at this point in the history
Lazyloads rdoc for the defualt `Apipie::Markup::RDoc` to prevent errors on
require: `cannot load such file -- rdoc (LoadError)`.
  • Loading branch information
vkrizan authored and yoav-p6 committed Nov 6, 2020
1 parent 08edfb9 commit 84a13e3
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/apipie/markup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ module Markup

class RDoc

def initialize
require 'rdoc'
require 'rdoc/markup/to_html'
if Gem::Version.new(::RDoc::VERSION) < Gem::Version.new('4.0.0')
@rdoc ||= ::RDoc::Markup::ToHtml.new()
else
@rdoc ||= ::RDoc::Markup::ToHtml.new(::RDoc::Options.new)
end
end

def to_html(text)
@rdoc.convert(text)
rdoc.convert(text)
end

private

def rdoc
@rdoc ||= begin
require 'rdoc'
require 'rdoc/markup/to_html'
if Gem::Version.new(::RDoc::VERSION) < Gem::Version.new('4.0.0')
::RDoc::Markup::ToHtml.new()
else
::RDoc::Markup::ToHtml.new(::RDoc::Options.new)
end
end
end
end

class Markdown
Expand Down

0 comments on commit 84a13e3

Please sign in to comment.