2 # Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #################################################################################
23 # File: prepare_generating_doc.py
24 # Author: Anastasiya NIKOLAEVA, Open CASCADE S.A.S
26 #################################################################################
28 # Pre-process Python module for documentation generation by doxygen.
29 # The script removes the staff that should not appear in the resulting
32 # Current the script does:
33 # 1. remove Python documentation in triple double quotes (like """some_comments""")
35 # Usage: prepare_generating_doc.py [-o <output_file>] <input_file>
37 # If <output_file> is not specified, it is generated in the current directory.
39 ###############################################################################
43 def main(input_file, output_file = None):
47 infile = open(input_file, 'rb')
49 sys.exit("File %s is not found" % input_file)
52 if not output_file: output_file = os.path.basename(input_file)
56 outfile = open(output_file, 'wb')
58 sys.exit("File %s cannot be opened for write" % output_file)
66 for line in infile.readlines():
67 # 1. remove comments like """some_comments"""
69 n1 = line[(n+2):].find(b'"""')
70 if (n > -1) and (n1 > -1):
83 # write resulting line
88 # close input and output files
94 if __name__ == "__main__":
96 parser = argparse.ArgumentParser()
97 h = "Output file (if not specified, generated in the current directory)"
98 parser.add_argument("-o", "--output", dest="output",
99 action="store", default=None, metavar="file",
101 parser.add_argument('input_file')
102 args = parser.parse_args()
103 main( args.input_file, args.output )