From 4f0ed5079119e1cbd96aab646d64833e02a71034 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Tue, 25 Oct 2016 13:33:41 +0200 Subject: [PATCH] add salome doc command --- bin/salomeContext.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bin/salomeContext.py b/bin/salomeContext.py index ac6f616bb..5769848f6 100644 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -51,6 +51,8 @@ Commands: Do not start a new one. test Run SALOME tests. info Display some information about SALOME. + doc Show online module documentation (if available). + Module names must be separated by blank characters. help Show this message. If no command is given, default to start. @@ -225,6 +227,7 @@ class SalomeContext: 'killall' : '_killAll', 'test' : '_runTests', 'info' : '_showInfo', + 'doc' : '_showDoc', 'help' : '_usage', 'coffee' : '_makeCoffee', 'car' : '_getCar', @@ -508,6 +511,30 @@ Available options are: self._runAppli(["--version"]) # + def _showDoc(self, args=None): + if args is None: + args = [] + + modules = args + if not modules: + print "Module(s) not provided to command: salome doc " + return + + appliPath = os.getenv("ABSOLUTE_APPLI_PATH") + if not appliPath: + raise SalomeContextException("Unable to find application path. Please check that the variable ABSOLUTE_APPLI_PATH is set.") + baseDir = os.path.join(appliPath, "share", "doc", "salome") + for module in modules: + docfile = os.path.join(baseDir, "gui", module.upper(), "index.html") + if not os.path.isfile(docfile): + docfile = os.path.join(baseDir, "tui", module.upper(), "index.html") + if not os.path.isfile(docfile): + docfile = os.path.join(baseDir, "dev", module.upper(), "index.html") + if os.path.isfile(docfile): + out, err = subprocess.Popen(["xdg-open", docfile]).communicate() + else: + print "Online documentation is not accessible for module:", module + def _usage(self, unused=None): usage() # -- 2.39.2