10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-11-19 04:22:23 +01:00
irpf90/src/create_man.py

84 lines
2.2 KiB
Python
Raw Normal View History

2009-09-06 00:47:20 +02:00
#!/usr/bin/python
from variable import Variable
from variables import variables
from irpf90_t import *
2009-09-08 16:00:46 +02:00
from util import *
2009-09-06 00:47:20 +02:00
def do_print_short(file,var):
assert isinstance(var,Variable)
print >>file, "%s : %s :: %s %s"%( \
2009-09-16 15:59:13 +02:00
var.line.filename[0],
2009-09-06 00:47:20 +02:00
var.type,
var.name,
2009-09-08 16:00:46 +02:00
build_dim(var.dim) )
2009-09-06 00:47:20 +02:00
######################################################################
def process_doc(file,line):
assert isinstance(line,str)
line = line.strip()
if line == "":
line = ".br"
print >>file, line
######################################################################
def process_deps(file,l):
assert isinstance(l,list)
for v in l:
print >>file, "%s\n.br"%(v,)
######################################################################
def process_types(file,var):
assert isinstance(var,Variable)
2009-09-07 18:02:06 +02:00
vars = [var.name] + var.others
2009-09-06 00:47:20 +02:00
for var in vars:
name = var
var = variables[var]
type = var.type
2009-09-08 16:00:46 +02:00
dim = build_dim(var.dim)
2009-09-06 00:47:20 +02:00
print >>file, "%s\t:: %s\t%s"%(type,name,dim)
######################################################################
def do_print(var):
assert isinstance(var,Variable)
2009-09-16 15:59:13 +02:00
filename = var.line.filename[0]
2009-09-06 00:47:20 +02:00
name = var.name
file = open("%s%s.l"%(mandir,var.name), "w")
print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name)
2009-09-07 18:02:06 +02:00
if var.same_as != var.name:
2009-09-06 00:47:20 +02:00
var = variables[var.same_as]
print >>file, ".SH Declaration"
print >>file, ".nf"
process_types(file,var)
print >>file, ".ni"
if var.doc != []:
print >>file, ".SH Description"
for l in var.doc:
process_doc(file,l)
print >>file, ".SH File\n.P"
print >>file, filename
if var.needs != []:
2009-09-16 15:59:13 +02:00
var.needs.sort()
2009-09-06 00:47:20 +02:00
print >>file, ".SH Needs"
process_deps(file,var.needs)
if var.needed_by != []:
2009-09-16 15:59:13 +02:00
var.needed_by.sort()
2009-09-06 00:47:20 +02:00
print >>file, ".SH Needed by"
process_deps(file,var.needed_by)
file.close()
######################################################################
def run():
2009-09-07 18:02:06 +02:00
import parsed_text
2009-09-06 00:47:20 +02:00
file = open("irpf90_entities","w")
for v in variables.keys():
do_print_short(file,variables[v])
file.close()
for v in variables.keys():
do_print(variables[v])
######################################################################
if __name__ == '__main__':
run()