From: vsr Date: Mon, 8 Apr 2013 05:18:37 +0000 (+0000) Subject: Improve documentation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=92e8a305977d1a1d0a4585d51d6475e6bc8b5691;p=modules%2Fyacs.git Improve documentation --- diff --git a/salome_adm/cmake_files/prepare_generating_doc.py b/salome_adm/cmake_files/prepare_generating_doc.py index decaa79d7..893f33b5a 100755 --- a/salome_adm/cmake_files/prepare_generating_doc.py +++ b/salome_adm/cmake_files/prepare_generating_doc.py @@ -18,59 +18,88 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# ... -# Usage: prepare_generating_doc.py -# ... -# 1. Remove Python documentation in triple double quotes (like """some_comments""") -# ... +################################################################################# +# +# File: prepare_generating_doc.py +# Author: Anastasiya NIKOLAEVA, Open CASCADE S.A.S +# +################################################################################# +# +# Pre-process Python module for documentation generation by doxygen. +# The script removes the staff that should not appear in the resulting +# documentation. +# +# Current the script does: +# 1. remove Python documentation in triple double quotes (like """some_comments""") +# +# Usage: prepare_generating_doc.py [-o ] +# +# If is not specified, it is generated in the current directory. +# +################################################################################# import os, sys, re -# check command line -if len( sys.argv ) < 2: - sys.exit("Usage: %s " % os.path.basename(sys.argv[0])) - -# open input file -try: - infile = open(sys.argv[1], 'rb') -except: - sys.exit("File %s is not found" % sys.argv[1]) - pass +def main(input_file, output_file = None): + + # open input file + try: + infile = open(input_file, 'rb') + except: + sys.exit("File %s is not found" % input_file) + pass -# open output file with the same name in current directory -try: - outfile = open(os.path.basename(sys.argv[1]), 'wb') -except: - sys.exit("File %s cannot be opened for write" % os.path.basename(sys.argv[1])) - pass + if not output_file: output_file = os.path.basename(input_file) + + # open output file + try: + outfile = open(output_file, 'wb') + except: + sys.exit("File %s cannot be opened for write" % output_file) + pass -# parse input file + # parse input file -isCom = False -isShift = False + isCom = False + isShift = False -for line in infile.readlines(): - # 1. remove comments like """some_comments""" - n = line.find('"""') - n1 = line[(n+2):].find('"""') - if (n > -1) and (n1 > -1): - continue - if isCom: - if n > -1: - isCom = False - pass - continue - else: - if n > -1: - isCom = True + for line in infile.readlines(): + # 1. remove comments like """some_comments""" + n = line.find('"""') + n1 = line[(n+2):].find('"""') + if (n > -1) and (n1 > -1): continue - pass + if isCom: + if n > -1: + isCom = False + pass + continue + else: + if n > -1: + isCom = True + continue + pass - # write resulting line - outfile.write(line) + # write resulting line + outfile.write(line) - pass # end of for + pass # end of for -# close input and output files -infile.close() -outfile.close() + # close input and output files + infile.close() + outfile.close() + + pass + +if __name__ == "__main__": + import optparse + parser = optparse.OptionParser(usage="%prog [options] input_file") + h = "Output file (if not specified, generated in the current directory)" + parser.add_option("-o", "--output", dest="output", + action="store", default=None, metavar="file", + help=h) + (options, args) = parser.parse_args() + + if len( args ) < 1: sys.exit("Input file is not specified") + main( args[0], options.output ) + pass