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

Added support of documentation of subroutines and functions

This commit is contained in:
Anthony Scemama 2014-03-13 14:44:47 +01:00
parent e74ffd8e7a
commit 67e6def151
7 changed files with 80 additions and 6 deletions

View File

@ -33,14 +33,14 @@ case "$0" in
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "`cat irpf90_entities | cut -d':' -f 4 | cut -d ' ' -f 2`" -- "$cur" ) )
COMPREPLY=( $(compgen -W "`cat tags | cut -d' ' -f 1`" -- "$cur" ) )
} && complete -F _irpman_complete irpman
;;
*)
if [[ -z $1 ]] ; then
echo "To activate auto-completion in bash:"
echo "source $(which irpman)"
echo "source " $0
else
python $(dirname $0)/../src/irpman.py $1
fi

View File

@ -27,6 +27,7 @@
from variable import Variable
from variables import variables
from subroutine import Sub
from subroutines import subroutines
from irpf90_t import *
from util import *
@ -94,6 +95,46 @@ def do_print(var):
process_deps(file,var.needed_by)
file.close()
######################################################################
def process_declaration_subroutine(file, sub):
print >>file, sub.line.text.split('!')[0].strip()
# for line in sub.text:
######################################################################
def do_print_subroutines(sub):
assert type(sub) == Sub
filename = sub.line.filename
name = sub.name
file = open("%s%s.l"%(mandir,sub.name), "w")
print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name)
print >>file, ".SH Declaration"
print >>file, ".nf"
process_declaration_subroutine(file,sub)
print >>file, ".ni"
if sub.doc != []:
print >>file, ".SH Description"
for l in sub.doc:
process_doc(file,l)
print >>file, ".SH File\n.P"
print >>file, filename
if sub.needs != []:
sub.needs.sort()
print >>file, ".SH Needs"
process_deps(file,sub.needs)
if sub.called_by != []:
sub.called_by.sort()
print >>file, ".SH Called by"
process_deps(file,sub.called_by)
if sub.calls != []:
sub.calls.sort()
print >>file, ".SH Calls"
process_deps(file,sub.calls)
if sub.touches != []:
sub.touches.sort()
print >>file, ".SH Touches"
process_deps(file,sub.touches)
file.close()
######################################################################
def run():
import parsed_text
@ -101,6 +142,8 @@ def run():
if os.fork() == 0:
for v in variables.values():
do_print(v)
for s in subroutines.values():
do_print_subroutines(s)
sys.exit(0)
if os.fork() == 0:

View File

@ -53,9 +53,9 @@ LIB=
include irpf90.make
irpf90.make: $(wildcard *.irp.f)
irpf90.make: $(filter-out %s%%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile
\t$(IRPF90)
"""
"""%(irpdir)
file.write(t)
file.close()

View File

@ -37,6 +37,7 @@ class Sub(object):
assert len(text) > 0
assert type(text[0]) in [Subroutine, Function]
self.text = text
self.called_by = []
############################################################
def name(self):
@ -114,7 +115,7 @@ class Sub(object):
buffer = filter(lambda x: type(x) == Call,self.text)
self._calls = []
for line in buffer:
sub = line.text.split('(',1)[0].split()[1]
sub = line.text.split('(',1)[0].split()[1].lower()
self._calls.append(sub)
self._calls = make_single(self._calls)
return self._calls

View File

@ -25,7 +25,10 @@
# scemama@irsamc.ups-tlse.fr
from util import *
from subroutine import *
from variables import variables
from variable import Variable
from irpf90_t import *
def create_subroutines():
@ -47,7 +50,22 @@ def create_subroutines():
inside = False
return result
def create_called_by(subs,vars):
for s in subs.values() + vars.values():
if type(s) == Variable and s.same_as != s.name:
continue
for x in s.calls:
try:
subs[x].called_by.append(s.name)
except KeyError:
pass
for s in subs.values():
s.called_by = make_single(s.called_by)
s.called_by.sort()
subroutines = create_subroutines()
create_called_by(subroutines,variables)
if __name__ == '__main__':
for v in subroutines.keys():

View File

@ -130,6 +130,18 @@ class Variable(object):
return self._includes
includes = property(includes)
############################################################
def calls(self):
if '_calls' not in self.__dict__:
self._calls = []
text = self.text
for line in filter(lambda x: type(x) == Call,text):
sub = line.text.split('(',1)[0].split()[1].lower()
self._calls.append(sub)
make_single(self._calls)
return self._calls
calls=property(fget=calls)
############################################################
def others(self):
if '_others' not in self.__dict__:

View File

@ -1 +1 @@
version = "1.3.4"
version = "1.3.5"