diff --git a/bin/irpman b/bin/irpman index f102f6a..175af7a 100755 --- a/bin/irpman +++ b/bin/irpman @@ -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 diff --git a/src/create_man.py b/src/create_man.py index fe4ad7f..724c522 100644 --- a/src/create_man.py +++ b/src/create_man.py @@ -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: diff --git a/src/makefile.py b/src/makefile.py index 311b887..c638745 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -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() diff --git a/src/subroutine.py b/src/subroutine.py index c379892..5003310 100644 --- a/src/subroutine.py +++ b/src/subroutine.py @@ -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 diff --git a/src/subroutines.py b/src/subroutines.py index 5491e95..90edb68 100644 --- a/src/subroutines.py +++ b/src/subroutines.py @@ -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(): diff --git a/src/variable.py b/src/variable.py index 817aba9..b8418d5 100644 --- a/src/variable.py +++ b/src/variable.py @@ -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__: diff --git a/src/version.py b/src/version.py index 08d6483..a19185e 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.3.4" +version = "1.3.5"