10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-12-21 11:53:32 +01:00

Added create man pages

This commit is contained in:
Anthony Scemama 2009-09-06 00:47:20 +02:00
parent 414d47a6e1
commit 9df8d96cb6
3 changed files with 99 additions and 7 deletions

83
src/create_man.py Normal file
View File

@ -0,0 +1,83 @@
#!/usr/bin/python
from variable import Variable
from variables import variables
from irpf90_t import *
def do_size(l):
if l == []: return ""
else: return "(%s)"%(",".join(l))
def do_print_short(file,var):
assert isinstance(var,Variable)
print >>file, "%s : %s :: %s %s"%( \
var.line.filename,
var.type,
var.name,
do_size(var.dim) )
######################################################################
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)
vars = var.others
vars.insert(0,var.name)
for var in vars:
name = var
var = variables[var]
type = var.type
dim = do_size(var.dim)
print >>file, "%s\t:: %s\t%s"%(type,name,dim)
######################################################################
def do_print(var):
assert isinstance(var,Variable)
filename = var.line.filename
name = var.name
file = open("%s%s.l"%(mandir,var.name), "w")
print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name)
if var.same_as is not None:
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 != []:
print >>file, ".SH Needs"
process_deps(file,var.needs)
if var.needed_by != []:
print >>file, ".SH Needed by"
process_deps(file,var.needed_by)
file.close()
######################################################################
def run():
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()

View File

@ -44,7 +44,6 @@ def get_parsed_text():
main_result = []
for filename, text in preprocessed_text:
result = []
varlist = []
for line in filter(
lambda x: type(x) not in [ Doc, Begin_doc, End_doc ],
text):
@ -64,14 +63,11 @@ def get_parsed_text():
Subroutine,
Function,
End,
End_provider,
]:
result.append( ([],line) )
elif type(line) in [End, End_provider]:
result.append( ([],line) )
varlist = []
elif isinstance(line,Provide):
l = line.text.split()[1:]
varlist += l
result.append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) )
elif isinstance(line,Call):
sub = find_subroutine_in_line(line)
@ -121,9 +117,15 @@ def get_parsed_text():
return ([],Simple_line(line.i," %s_is_built = .True."%(x,),line.filename))
result += map( fun, main_vars[:-1] )
result += [ ([],Provide_all(line.i,"! <<< END TOUCH",line.filename)) ]
elif type(line) in [ Begin_provider, Cont_provider ]:
buffer = map(strip,line.text.replace(']','').split(','))
assert len(buffer) > 1
v = buffer[1].lower()
variable_list = find_variables_in_line(line)
variable_list.remove(v)
result.append( (variable_list,line) )
else:
l = find_variables_in_line(line)
varlist += l
result.append( (l,line) )
main_result.append( (filename, result) )
return main_result

View File

@ -144,10 +144,17 @@ class Variable(object):
############################################################
def needs(self):
if '_needs' not in self.__dict__:
self._needs = None
self._needs = []
return self._needs
needs = property(needs)
############################################################
def needed_by(self):
if '_needed_by' not in self.__dict__:
self._needed_by = []
return self._needed_by
needed_by = property(needed_by)
############################################################
def header(self):
if '_header' not in self.__dict__: