summaryrefslogtreecommitdiffstats
path: root/tool/makedocs.rb
blob: 56cb21565fa037ad1cbc239fa14cd662c7239c09 (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env ruby
#
#

require 'rb/insns2vm.rb'
insns = insns_def_new

{ # docs
  '/doc/yarvarch.ja' => :desc_ja,
  '/doc/yarvarch.en' => :desc_en,
}.each{|fn, s|
  fn = $srcdir + fn
  p fn
  open(fn, 'w'){|f|
    f.puts(insns.__send__(s))
  }
}

def chg ary
  if ary.empty?
    return ' '
  end
  
  ary.map{|e|
    if e[0] == '...'
      '...'
    else
      e.join(' ')
    end
    e[1]
  }.join(', ')
end

open($srcdir + '/doc/insnstbl.html', 'w'){|f|
  tbl = ''
  type = nil
  insns.each_with_index{|insn, i|
    c = insn.comm[:c]
    if type != c
      stype = c
      type  = c
    end
    
    tbl << "<tr>\n"
    tbl << "<td>#{stype}</td>"
    tbl << "<td>#{i}</td>"
    tbl << "<td>#{insn.name}</td>"
    tbl << "<td>#{chg insn.opes}</td>"
    tbl << "<td>#{chg insn.pops.reverse}</td>"
    tbl << "<td> =&gt; </td>"
    tbl << "<td>#{chg insn.rets.reverse}</td>"
    tbl << "</tr>\n"
  }
  f.puts ERB.new(File.read($srcdir + '/template/insnstbl.html')).result(binding)
}

begin
  system('t2n.bat --tmpl doc.tmpl ../doc/yarvarch.ja > ../doc/yarvarch.ja.html')
  system('t2n.bat --tmpl doc.tmpl ../doc/yarvarch.en > ../doc/yarvarch.en.html')
rescue
end