1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import os, sys, glob
- def get_filepaths(directory):
- """
- This function will generate the file names in a directory
- tree by walking the tree either top-down or bottom-up. For each
- directory in the tree rooted at directory top (including top itself),
- it yields a 3-tuple (dirpath, dirnames, filenames).
- """
- file_paths = []
-
- for root, directories, files in os.walk(directory):
- for filename in files:
-
- filepath = os.path.join(root, filename)
- file_paths.append(filepath)
- return file_paths
- if __name__ == '__main__':
- if len(sys.argv) != 2:
- print('Syntax: %s <path_of_header_files>' % sys.argv[0])
- exit(-1)
-
- fh = open('py_doc.h', 'w')
- fc = open('py_doc.cpp', 'w')
-
- base_path = sys.argv[1]
- full_file_paths = get_filepaths(base_path)
-
- for f in full_file_paths:
- if f.endswith(".h"):
- f_clean = f[len(base_path):]
- f_clean = f_clean.replace(base_path, "")
- f_clean = f_clean.replace(".h", "")
- f_clean = f_clean.replace("/", "_")
- f_clean = f_clean.replace("\\", "_")
- f_clean = f_clean.replace(" ", "_")
- f_clean = f_clean.replace(".", "_")
-
- tmp_string = f.replace("../include/", "libigl/")
- tmp_string = "See " + tmp_string + " for the documentation."
-
- h_string = "extern const char *__doc_" + f_clean + ";\n"
- cpp_string = "const char *__doc_" + f_clean + " = R\"igl_Qu8mg5v7(" + tmp_string + ")igl_Qu8mg5v7\";\n"
- fh.write(h_string)
- fc.write(cpp_string)
-
- fh.close()
- fc.close()
|