olddoc.git  about / heads / tags
olddoc - old-fashioned RDoc generator(s)
blob bd712fba04a9aa5e06c0a5f032535319745085b9 935 bytes (raw)
$ git show HEAD:lib/olddoc/news_rdoc.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
27
28
29
30
31
32
33
34
35
 
# -*- encoding: utf-8 -*-
# Copyright (C) 2015-2016 all contributors <olddoc-public@80x24.org>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
#
require 'tempfile'

module Olddoc::NewsRdoc # :nodoc:
  include Olddoc::History

  def puts_tag(fp, tag)
    time = tag[:time].tr('T', ' ').gsub!(/:\d\dZ/, ' UTC')
    fp.puts "=== #{tag[:subject]} / #{time}"
    fp.puts ""

    fp.puts tag[:body].gsub(/^/smu, "  ").gsub(/[ \t]+$/smu, "")
    fp.puts ""
  end

  # generates a NEWS file in the top-level directory based on git tags
  def news_rdoc
    news = Tempfile.new('NEWS', '.')
    tags.each { |tag| puts_tag(news, tag) }
    File.open("LATEST", "wb") { |latest|
      if tags.empty?
        latest.puts "Currently unreleased"
        news.puts "No news yet."
      else
        puts_tag(latest, tags[0])
      end
    }
    news.chmod(0666 & ~File.umask)
    File.rename(news.path, 'NEWS')
    news.close!
  end
end

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