From fa1a0118ead6dcb2f9f6dc2058af132ee9f2e7a3 Mon Sep 17 00:00:00 2001 From: akl Date: Fri, 5 Apr 2013 11:32:50 +0000 Subject: [PATCH] Remove documentation in triple double quotes in Python script to avoid it in generated pages. --- .../cmake_files/prepare_generating_doc.py | 43 +++++-------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/salome_adm/cmake_files/prepare_generating_doc.py b/salome_adm/cmake_files/prepare_generating_doc.py index ccd178144..decaa79d7 100755 --- a/salome_adm/cmake_files/prepare_generating_doc.py +++ b/salome_adm/cmake_files/prepare_generating_doc.py @@ -19,32 +19,29 @@ # # ... -# Usage: prepare_generating_doc.py +# Usage: prepare_generating_doc.py # ... -# 1. myClassDC is replaced by myClass -# 2. all methods of myClassDC become global methods of Python package -# ... -# myClass is passed as command line argument +# 1. Remove Python documentation in triple double quotes (like """some_comments""") # ... import os, sys, re # check command line -if len( sys.argv ) < 4: - sys.exit("Usage: %s " % os.path.basename(sys.argv[0])) +if len( sys.argv ) < 2: + sys.exit("Usage: %s " % os.path.basename(sys.argv[0])) # open input file try: - infile = open(sys.argv[2], 'rb') + infile = open(sys.argv[1], 'rb') except: - sys.exit("File %s is not found" % sys.argv[2]) + sys.exit("File %s is not found" % sys.argv[1]) pass -# open output file +# open output file with the same name in current directory try: - outfile = open(sys.argv[1], 'wb') + outfile = open(os.path.basename(sys.argv[1]), 'wb') except: - sys.exit("File %s cannot be opened for write" % sys.argv[1]) + sys.exit("File %s cannot be opened for write" % os.path.basename(sys.argv[1])) pass # parse input file @@ -53,20 +50,7 @@ isCom = False isShift = False for line in infile.readlines(): - dc_class = sys.argv[3] - dc_class_dc = dc_class+'DC' - - if isShift and ( re.match('^class\s+', line) or re.match('^def\s+', line) ): - # stop shifting lines as soon as myClassDC definition is over - isShift = False - pass - if re.match('class\s+%s' % dc_class_dc, line): - # start shifting lines - isShift = True - # omit this line (to remove myClassDC from the package) - continue - - # process documentation + # 1. remove comments like """some_comments""" n = line.find('"""') n1 = line[(n+2):].find('"""') if (n > -1) and (n1 > -1): @@ -82,13 +66,6 @@ for line in infile.readlines(): continue pass - # replacements - if isShift: - line = re.sub(r'^\s+#', '#', line) - line = re.sub(r'^\s+def', 'def', line) - pass - line = re.sub(dc_class_dc, dc_class, line) - # write resulting line outfile.write(line) -- 2.39.2