olddoc.git  about / heads / tags
olddoc - old-fashioned RDoc generator(s)
blob de5e2ae7ac57321680a06c98e273d6eefeb3235b 763 bytes (raw)
$ git show HEAD:lib/olddoc/merge.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
# Copyright (C) 2015-2016 all contributors <olddoc-public@80x24.org>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>

class Olddoc::Merge # :nodoc:
  def initialize(opts)
    @merge_html = opts["merge_html"] || {}
  end

  # FIXME: generate manpages directly from rdoc instead of relying on
  # pandoc to do it via markdown.
  def run
    @merge_html.each do |file, source|
      rdoc_html = "doc/#{file}.html"
      fragment = File.read(source)
      File.open(rdoc_html, "a+") { |fp|
        html = fp.read
        if html.sub!(%r{\s*<p>\s*olddoc_placeholder\s*</p>\s*}sm, fragment)
          fp.truncate(0)
          fp.write(html)
        else
          warn "olddoc_placeholder not found in #{rdoc_html}"
        end
      }
    end
  end
end

git clone https://80x24.org/olddoc.git