ATLAS Offline Software
Loading...
Searching...
No Matches
updateDocumentation.py
Go to the documentation of this file.
1# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2
3import os
4import re
5"""
6This is a tool which auto-generated documentation for all the python modules/executables which are included in the systematics-tools package.
7"""
8wdir=os.environ["SYSTTOOLSPATH"]
9pydir=wdir+"/local/bin"
10docdir=wdir+"/documentation"
11os.system("mkdir -p %s" % docdir)
12for pyfile in os.listdir(pydir):
13 if re.findall(".*py?",pyfile) != [pyfile]: continue
14 if not (".py" in pyfile and pyfile[-1]=='y'): continue
15 if ("updateDocumentation" in pyfile): continue
16 print('processing ', pyfile)
17 pymodule=pyfile.replace(".py","")
18 print("pydoc %s > %s/%s.doc" % (pymodule, docdir, pymodule))
19 os.system("pydoc %s > %s/%s.doc" % (pymodule, docdir, pymodule))
20 fin = open ("%s/%s.doc" %(docdir, pymodule), 'r')
21 fout = open ("%s/%s.md" %(docdir, pymodule), 'w')
22 inHeader=True
23 for line in fin.readlines():
24 countSpaces=0
25 lineOut=""
26 inPrefix=True
27 if "FUNCTIONS" in line: inHeader=False
28 for l in line:
29 if l==" " and inPrefix: countSpaces+=1
30 else:
31 lineOut+=l
32 inPrefix=False
33 line=lineOut
34 line=line.strip("\n")
35 line=line.strip("\r")
36 #if len(line)==0: continue
37 lout= line
38 if countSpaces==0 and len(line)>0:
39 lout= "# %s"%line
40 elif countSpaces==4 and not inHeader and len(line)>0:
41 lout= "## %s"%line
42 else:
43 pass
44 if "Help on module" in lout: lout ="Help on module %s" % pymodule
45 fout.write("%s\n" % lout)
void print(char *figname, TCanvas *c1)