File: gen-man-md-doctest-stub.rb

package info (click to toggle)
libvcflib 1.0.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 49,628 kB
  • sloc: cpp: 39,244; perl: 474; python: 329; ruby: 285; sh: 247; ansic: 198; makefile: 131; javascript: 94; lisp: 57
file content (42 lines) | stat: -rwxr-xr-x 929 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
#!/usr/bin/env ruby
#
# Internal helper script to create a markdown file that can be used
# for testing and generating man pages using and erb template
#
# by Pjotr Prins (C) 2020

require 'erb'
require 'date'

VERSION=`cat ../VERSION`.strip

cmd = ARGV.shift
$stderr.print("--- Parsing the output of #{cmd} #{VERSION}\n")

out = `../build/#{cmd} -h 2>&1 `
$stderr.print out

$stderr.print("\n=========================================\n")

lines = out.split(/\n/)
l1 = lines.shift
descr = l1.gsub(/#{VERSION}\s+/,"")
descr = descr.sub(/vcflib/,"VCF")
l2 = lines.shift
l2.length ==0 or raise "Description <#{l2}> should be one line"

l3 = lines.shift
l3 = l3.sub(/..\/build\//,"")
usage_full = l3
usage = l3.sub(/usage:\s+/,"")

lines = lines.map { |x| x == "options:" ? "" : x }

options  = lines.join("\n")

d = DateTime.now

year = d.year

renderer = ERB.new(File.read('scripts/template.erb'))
print output = renderer.result()