Salome HOME
sat #18867 : pour les url des bases git : substitution des references par leur valeur...
[tools/sat.git] / commands / doc.py
index 42359e2700bd09316de0154f3a2edd5ff99142c9..0c9b44881b807698f208719607bd97816135b85d 100644 (file)
@@ -21,7 +21,7 @@ import src
 
 # Define all possible option for log command :  sat doc <options>
 parser = src.options.Options()
-parser.add_option('h', 'html', 'boolean', 'html', "Open sat html documentation in browser", None)
+parser.add_option('x', 'xml', 'boolean', 'xml', "Open sat xml/html documentation in browser (x as firefoX)", None)
 parser.add_option('p', 'pdf', 'boolean', 'pdf', "Open sat pdf documentation in viewer", False)
 parser.add_option('e', 'edit', 'boolean', 'edit', "edit/modify source dodumentation rst files", False)
 parser.add_option('c', 'compile', 'boolean', 'compile', "how to compile html/pdf doc", False)
@@ -36,8 +36,8 @@ def description():
 The doc command gives access to the sat documentation.
     
 example:
->> sat doc         # --html as default
->> sat doc --html
+>> sat doc         # --xml as default
+>> sat doc --xml
 >> sat doc --pdf
 """)
 
@@ -59,13 +59,27 @@ def run(args, runner, logger):
     logger.write("docdir %s\n" % docDir, 6)
     logger.write("options %s\n" % options, 6)
 
-    if options.html:
-        src.system.show_in_editor(runner.cfg.USER.browser, htmlFile, logger)
     if options.pdf:
+        if not os.path.isfile(pdfFile):
+            msg = "\npdf documentation not found. Please build it inside doc directory\n"\
+                  "(follow README instructions in doc directory)\n"
+            logger.error(msg)
+            return 1
         src.system.show_in_editor(runner.cfg.USER.pdf_viewer, pdfFile, logger)
-    if options.edit:
+
+    elif options.edit:
         src.system.show_in_editor(runner.cfg.USER.editor, rstFiles, logger)
         src.system.show_in_editor(runner.cfg.USER.editor, rstFilesCommands, logger)
-    if options.compile:
-        logger.write("How to comile documentation:\n%s" % open(readmeFile,"r").read(), 3)
+
+    elif options.compile:
+        logger.write("How to compile documentation:\n%s" % open(readmeFile,"r").read(), 3)
+
+    else:
+        if not os.path.isfile(htmlFile):
+            msg = "\nhtml documentation not found. Please build it inside doc directory\n"\
+                  "(follow README instructions in doc directory)\n"
+            logger.error(msg)
+            return 1
+        src.system.show_in_editor(runner.cfg.USER.browser, htmlFile, logger)
+
     return 0