1 ## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## Lesser General Public License for more details.
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
22 ## The script collects information about help documents in plugins
23 ## and prepares building of help documentation by sphinx
29 from xml.dom.minidom import parse
31 aBuildDir = sys.argv[1]
32 aSourcesDir = sys.argv[2]
33 aSrcPath = aSourcesDir + os.sep + "../../src"
35 aConfigPath = aSrcPath + os.sep + "Config/plugins.xml.in"
37 ## Find accessible plugins from plugins.xml configuration file
39 aDomObj = parse(aConfigPath)
40 aPluginsList = aDomObj.getElementsByTagName("plugin")
41 for plugin in aPluginsList:
42 aLibName = plugin.getAttribute("library")
44 aLibName = plugin.getAttribute("script")
47 aPluginDocDir = aSrcPath + os.sep + aLibName + os.sep + "doc"
48 aDocDist = aBuildDir + os.sep + aLibName
49 if os.path.exists(aPluginDocDir):
50 ## Copy all files to a building directory
51 if os.path.exists(aDocDist):
52 shutil.rmtree(aDocDist)
53 shutil.copytree(aPluginDocDir, aDocDist)
54 aPluginList.append(aLibName)
56 ## Modify index.rst file accordingly
57 aIndexFile = open(aSourcesDir + os.sep + "index.rst.in", 'r')
58 aIndexLines = aIndexFile.readlines()
61 ## Add list of plugins after toctree directive
62 aIndexLines.append('\n')
63 for aLibName in aPluginList:
64 aIndexLines.append(" " + aLibName + "/" + aLibName + ".rst\n")
66 aNewIndex = open(aBuildDir + os.sep + "index.rst", 'w')
67 aNewIndex.writelines(aIndexLines)