3
# Module doxygen.process
4
# Script to insert preamble for doxygen and regen API docs
10
# Module caffe2...caffe2.python.control_test
11
def insert(originalfile, first_line, description):
12
with open(originalfile) as f:
14
if f1.find(first_line) < 0:
15
docs = first_line + description + f1
16
with open("newfile.txt", "w") as f2:
19
os.rename("newfile.txt", originalfile)
21
print("already inserted")
24
# move up from /caffe2_root/doxygen
26
os.system("git checkout caffe2/contrib/.")
27
os.system("git checkout caffe2/distributed/.")
28
os.system("git checkout caffe2/experiments/.")
29
os.system("git checkout caffe2/python/.")
31
for root, dirs, files in os.walk("."):
35
and not file.endswith("_test.py")
36
and not file.endswith("__.py")
38
filepath = os.path.join(root, file)
39
print("filepath: " + filepath)
40
directory = os.path.dirname(filepath)[2:]
41
directory = directory.replace("/", ".")
42
print("directory: " + directory)
43
name = os.path.splitext(file)[0]
44
first_line = "## @package " + name
45
description = "\n# Module " + directory + "." + name + "\n"
46
print(first_line, description)
47
insert(filepath, first_line, description)
49
if os.path.exists("doxygen/doxygen-python"):
50
print("Looks like you ran this before, so we need to cleanup those old files...")
51
shutil.rmtree("doxygen/doxygen-python")
53
os.makedirs("doxygen/doxygen-python")
55
if os.path.exists("doxygen/doxygen-c"):
56
print("Looks like you ran this before, so we need to cleanup those old files...")
57
shutil.rmtree("doxygen/doxygen-c")
59
os.makedirs("doxygen/doxygen-c")
61
os.system("doxygen .Doxyfile-python")
62
os.system("doxygen .Doxyfile-c")