mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-12-22 04:13:33 +01:00
Added rst generation in man directory
This commit is contained in:
parent
03e3117a73
commit
f9c0bff633
@ -1,9 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.append("../src")
|
|
||||||
import version
|
|
||||||
|
|
||||||
|
|
||||||
import setuptools
|
import setuptools
|
||||||
|
|
||||||
with open("../README.md", "r") as fh:
|
with open("../README.md", "r") as fh:
|
||||||
@ -11,7 +7,7 @@ with open("../README.md", "r") as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name = 'irpf90',
|
name = 'irpf90',
|
||||||
version = version.version,
|
version = '1.7.4-2',
|
||||||
scripts = ["irpf90", "irpman", "irpf90_indent"],
|
scripts = ["irpf90", "irpman", "irpf90_indent"],
|
||||||
author = 'Anthony Scemama',
|
author = 'Anthony Scemama',
|
||||||
author_email = 'scemama@irsamc.ups-tlse.fr',
|
author_email = 'scemama@irsamc.ups-tlse.fr',
|
||||||
|
@ -34,6 +34,7 @@ from util import *
|
|||||||
|
|
||||||
|
|
||||||
def do_print_short(file,var):
|
def do_print_short(file,var):
|
||||||
|
"""Makes a short print, as in irpf90_entities"""
|
||||||
assert type(var) == Variable
|
assert type(var) == Variable
|
||||||
print >>file, "%s : %s :: %s %s"%( \
|
print >>file, "%s : %s :: %s %s"%( \
|
||||||
var.line.filename[0].ljust(35),
|
var.line.filename[0].ljust(35),
|
||||||
@ -100,6 +101,75 @@ def do_print(var):
|
|||||||
print >>file, ".br"
|
print >>file, ".br"
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
def do_print_rst(var):
|
||||||
|
"""Print providers in a format suitable for sphinx"""
|
||||||
|
assert type(var) == Variable
|
||||||
|
filename = var.line.filename[0]
|
||||||
|
name = var.name
|
||||||
|
file = open("%s%s.rst"%(mandir,var.name), "w")
|
||||||
|
print >>file, ".. c:var:: %s\n"%(var.name.lower())
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " File : :file:`"+filename+"`"
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " .. code:: fortran"
|
||||||
|
print >>file, ""
|
||||||
|
if var.same_as != var.name:
|
||||||
|
var = variables[var.same_as]
|
||||||
|
for v in [var.name] + var.others:
|
||||||
|
name = v
|
||||||
|
v = variables[v]
|
||||||
|
Type = v.type
|
||||||
|
dim = build_dim(v.dim)
|
||||||
|
print >>file, " %s\t:: %s\t%s"%(Type,name,dim)
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, ""
|
||||||
|
|
||||||
|
if var.doc != []:
|
||||||
|
d = []
|
||||||
|
for text in var.doc:
|
||||||
|
text_old = None
|
||||||
|
while text_old != text:
|
||||||
|
text_old = text
|
||||||
|
text = text.replace("$",":math:`",1).replace("$","` ",1)
|
||||||
|
d.append(text)
|
||||||
|
loop = True
|
||||||
|
while loop:
|
||||||
|
maxlen=0
|
||||||
|
for l in d:
|
||||||
|
ll = len(l)
|
||||||
|
maxlen = max(ll,maxlen)
|
||||||
|
if ll > 0 and l[0] != ' ':
|
||||||
|
loop = False
|
||||||
|
break
|
||||||
|
loop = loop and maxlen > 0
|
||||||
|
if loop:
|
||||||
|
d = [ l[1:] for l in d ]
|
||||||
|
for line in d:
|
||||||
|
print >>file, " "+line
|
||||||
|
print >>file, ""
|
||||||
|
if var.needs != []:
|
||||||
|
var.needs.sort()
|
||||||
|
print >>file, " Needs:"
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " .. hlist::"
|
||||||
|
print >>file, " :columns: 3"
|
||||||
|
print >>file, ""
|
||||||
|
for v in var.needs:
|
||||||
|
print >>file, " * :c:data:`%s`"%(variables[v].same_as.lower(),)
|
||||||
|
print >>file, ""
|
||||||
|
if var.needed_by != []:
|
||||||
|
var.needed_by.sort()
|
||||||
|
print >>file, " Needed by:"
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " .. hlist::"
|
||||||
|
print >>file, " :columns: 3"
|
||||||
|
print >>file, ""
|
||||||
|
for v in var.needed_by:
|
||||||
|
print >>file, " * :c:data:`%s`"%(variables[v].same_as.lower(),)
|
||||||
|
print >>file, ""
|
||||||
|
file.close()
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def process_declaration_subroutine(file, sub):
|
def process_declaration_subroutine(file, sub):
|
||||||
print >>file, sub.line.text.split('!')[0].strip()
|
print >>file, sub.line.text.split('!')[0].strip()
|
||||||
@ -145,6 +215,84 @@ def do_print_subroutines(sub):
|
|||||||
print >>file, ".br"
|
print >>file, ".br"
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
def do_print_subroutines_rst(sub):
|
||||||
|
"""Print subroutines in a format suitable for sphinx"""
|
||||||
|
assert type(sub) == Sub
|
||||||
|
filename = sub.line.filename
|
||||||
|
name = sub.name
|
||||||
|
file = open("%s%s.rst"%(mandir,sub.name), "w")
|
||||||
|
print >>file, ".. c:function:: %s:\n"%(sub.name.lower())
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " File : :file:`"+filename+"`"
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " .. code:: fortran"
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " "+sub.line.text.split('!')[0].strip()
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, ""
|
||||||
|
if sub.doc != []:
|
||||||
|
d = list(sub.doc)
|
||||||
|
loop = True
|
||||||
|
while loop:
|
||||||
|
maxlen=0
|
||||||
|
for l in d:
|
||||||
|
ll = len(l)
|
||||||
|
maxlen = max(ll,maxlen)
|
||||||
|
if ll > 0 and l[0] != ' ':
|
||||||
|
loop = False
|
||||||
|
break
|
||||||
|
loop = loop and maxlen > 0
|
||||||
|
if loop:
|
||||||
|
d = [ l[1:] for l in d ]
|
||||||
|
for l in d:
|
||||||
|
print >>file, " "+l
|
||||||
|
print >>file, ""
|
||||||
|
if sub.needs != []:
|
||||||
|
sub.needs.sort()
|
||||||
|
print >>file, " Needs:"
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " .. hlist::"
|
||||||
|
print >>file, " :columns: 3"
|
||||||
|
print >>file, ""
|
||||||
|
for v in sub.needs:
|
||||||
|
print >>file, " * :c:data:`%s`"%(variables[v].same_as.lower(),)
|
||||||
|
print >>file, ""
|
||||||
|
if sub.called_by != []:
|
||||||
|
sub.called_by.sort()
|
||||||
|
print >>file, " Called by:"
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " .. hlist::"
|
||||||
|
print >>file, " :columns: 3"
|
||||||
|
print >>file, ""
|
||||||
|
for v in sub.called_by:
|
||||||
|
if v in subroutines:
|
||||||
|
print >>file, " * :c:func:`%s`"%(v.lower(),)
|
||||||
|
elif v in variables:
|
||||||
|
print >>file, " * :c:data:`%s`"%(variables[v.lower()].same_as.lower(),)
|
||||||
|
print >>file, ""
|
||||||
|
if sub.calls != []:
|
||||||
|
sub.calls.sort()
|
||||||
|
print >>file, " Calls:"
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " .. hlist::"
|
||||||
|
print >>file, " :columns: 3"
|
||||||
|
print >>file, ""
|
||||||
|
for v in sub.calls:
|
||||||
|
print >>file, " * :c:func:`%s`"%(v.lower(),)
|
||||||
|
print >>file, ""
|
||||||
|
if sub.touches != []:
|
||||||
|
sub.touches.sort()
|
||||||
|
print >>file, " Touches:"
|
||||||
|
print >>file, ""
|
||||||
|
print >>file, " .. hlist::"
|
||||||
|
print >>file, " :columns: 3"
|
||||||
|
print >>file, ""
|
||||||
|
for v in sub.touches:
|
||||||
|
print >>file, " * :c:data:`%s`"%(variables[v.lower()].same_as.lower(),)
|
||||||
|
print >>file, ""
|
||||||
|
file.close()
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def run():
|
def run():
|
||||||
import parsed_text
|
import parsed_text
|
||||||
@ -153,8 +301,10 @@ def run():
|
|||||||
if pid1 == 0:
|
if pid1 == 0:
|
||||||
for v in variables.values():
|
for v in variables.values():
|
||||||
do_print(v)
|
do_print(v)
|
||||||
|
do_print_rst(v)
|
||||||
for s in subroutines.values():
|
for s in subroutines.values():
|
||||||
do_print_subroutines(s)
|
do_print_subroutines(s)
|
||||||
|
do_print_subroutines_rst(s)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
pid2 = os.fork()
|
pid2 = os.fork()
|
||||||
@ -166,13 +316,11 @@ def run():
|
|||||||
for v in l:
|
for v in l:
|
||||||
do_print_short(file,variables[v])
|
do_print_short(file,variables[v])
|
||||||
line = variables[v].line
|
line = variables[v].line
|
||||||
# tags.append( '%s\t%s\t/%s/;"\n'%(v,line.filename[0],line.text.split('!')[0].strip()) )
|
|
||||||
tags.append( '%s\t%s\t%d\n'%(v,line.filename[0],line.i) )
|
tags.append( '%s\t%s\t%d\n'%(v,line.filename[0],line.i) )
|
||||||
file.close()
|
file.close()
|
||||||
l = subroutines.keys()
|
l = subroutines.keys()
|
||||||
for v in l:
|
for v in l:
|
||||||
line = subroutines[v].line
|
line = subroutines[v].line
|
||||||
# tags.append('%s\t%s\t/%s/;"\n'%(v,line.filename,line.text.split('!')[0].strip()))
|
|
||||||
tags.append('%s\t%s\t%d\n'%(v,line.filename,line.i))
|
tags.append('%s\t%s\t%d\n'%(v,line.filename,line.i))
|
||||||
tags.sort()
|
tags.sort()
|
||||||
file = open("tags","w")
|
file = open("tags","w")
|
||||||
|
@ -1 +1 @@
|
|||||||
version = "1.7.4"
|
version = "1.7.5"
|
||||||
|
Loading…
Reference in New Issue
Block a user