From fe91ea603530e6180b21c338a7834894d63800aa Mon Sep 17 00:00:00 2001 From: Alessandro Caproni Date: Wed, 6 Dec 2017 12:54:43 +0100 Subject: [PATCH] Generate the index.html with links to scripts and modules --- Tools/src/python/IASApiDocs/PydocBuilder.py | 63 +++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/Tools/src/python/IASApiDocs/PydocBuilder.py b/Tools/src/python/IASApiDocs/PydocBuilder.py index c2be912a5..bda4983f7 100644 --- a/Tools/src/python/IASApiDocs/PydocBuilder.py +++ b/Tools/src/python/IASApiDocs/PydocBuilder.py @@ -10,6 +10,7 @@ import os import shutil from subprocess import call +from glob import glob from IASApiDocs.DocGenerator import DocGenerator class PydocBuilder(DocGenerator): @@ -45,6 +46,67 @@ def getPythonFilesInFolder(self,folder): return ret + def buildIndex(self,folder): + """ + Build the index.thm file needed by github web server. + + The index will simply list the generated html files + + @param folder: the folder containing html files to index + """ + print "Generating index in",folder + + htmlFilePaths = glob(folder+"/*.html") + htmlFiles = [] + for f in htmlFilePaths: + parts = f.split("/") + fileName = parts[len(parts)-1] + htmlFiles.append(fileName) + htmlFiles.sort() + + # Look for python modules that can be taken from + # file names having 2 dots like IASApiDocs.DocGenerator.html + pyModules = [] + for f in htmlFiles: + parts = f.split(".") + if (len(parts)>2): + if (parts[0] not in pyModules): + pyModules.append(parts[0]) + pyModules.sort() + print "Python modules",pyModules + + msg = "\n\n" + msg += "\t

IAS python API

\n" + msg += "\t

Scripts

\n" + msg += "\t\n" + + msg += "\t

Modules

\n" + for m in pyModules: + msg +="\t\t

"+m+"

\n" + msg += "\t\t\n" + + msg+= "\n" + + text_file = open(folder+"/index.html", "w") + text_file.write(msg) + text_file.close() + + print folder+"/index.html written" + def buildPydocs(self): """ Build the pydocs @@ -78,5 +140,6 @@ def buildPydocs(self): print "Changing folder back to",oldWD os.chdir(oldWD) + self.buildIndex(self.dstFolder) return ret \ No newline at end of file