12 """Returns the file name part of a path/file string."""
13 head, tail = os.path.split(path)
18 """Removes any instance of ::throw in a file that doxy2swig produces."""
32 data = data.replace(
'::throw',
'')
45 script_fullpath_name = os.path.realpath(__file__)
46 path_gnsstk_swig = os.path.dirname( script_fullpath_name )
47 (gnsstk_root, swig_dir) = os.path.split( path_gnsstk_swig )
50 xml_glob_pattern = os.path.sep.join((args.src_dir,
'xml',
'**',
'*.xml'))
51 xml_files = glob.glob( xml_glob_pattern, recursive=
True)
52 num_files = len( xml_files )
54 print(
'WARNING: No doxygen-xml files found, docstrings cannot be generated.')
58 path_gnsstk_swig_doc = args.dst_dir
59 if not os.path.exists( path_gnsstk_swig_doc ):
60 os.makedirs( path_gnsstk_swig_doc )
63 for f_xml
in xml_files:
64 (f, xml_ext) = os.path.splitext( f_xml )
66 output_file = path_gnsstk_swig_doc + os.path.sep + name_root +
'.i'
67 if (
'index' not in name_root):
71 print(
'Parsed ', f,
'to', output_file)
72 except Exception
as e:
73 print(
'ERROR:', f_xml,
'can not be parsed')
77 out_file = open(path_gnsstk_swig_doc + os.path.sep +
'doc.i',
'w')
78 out_file.write(
'// This is an AUTO-GENERATED file by docstring_generator.py.\n')
79 out_file.write(
'// Do not modify it unless you know what you are doing.\n')
80 doc_files = glob.glob(path_gnsstk_swig_doc + os.path.sep +
'*.i')
82 if 'doc.i' not in f_i:
83 out_file.write(
'%include ' + f_i +
'\n')
85 print(
'\nFinished with documentation.')
88 if __name__ ==
'__main__':
89 parser = argparse.ArgumentParser(description=
"""
90 GNSSTk python-swig binding documentation generator.
91 This reads every file in the $doc_dir/xml (where doxygen places its xml)
92 Then uses $gnsstk_root/swig/doxy2swig.py to create docstring output for a SWIG .i file.
93 These .i files are placed in $gnsstk_root/swig/doc.
94 Then doc.i is auto-generated to include all of these new files in the doc/ folder.
97 parser.add_argument(
"-d", default=0, dest=
"debug", action=
"count",
98 help=
"Increase the level of debug output.")
100 parser.add_argument(dest=
"src_dir",
101 help=
"Directory where the doxygen xml files are.")
103 parser.add_argument(dest=
"dst_dir",
104 help=
"Directory to write swig.i files to.")
106 args = parser.parse_args()