forked from AMReX-Astro/Castro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_api.py
More file actions
37 lines (26 loc) · 1.14 KB
/
Copy pathmake_api.py
File metadata and controls
37 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
This script rewrites the filelist.rst file autogenerated by breathe to organize
the files in the documentation's API into the same directory structure as their
counterparts in the ../Source directory.
Note that we assume here that there is only one level of subdirectories in the
../Source directory and that all the files we want to document are in those
subdirectories (i.e. not in subdirectories of those). If this is not the case,
then you may want to use os.walk(..) rather than os.listdir(..).
We are also not going to include cpp files - doxygen assumes that functions are
documented in the header files, so that's what we'll assume here as well.
"""
import os
import re
# directory of the source files
rootdir = "../Source"
filelist_path = "source/filelist.rst"
def strip_directives(filename, filepath, outpath):
"""
Read in file, remove all preprocessor directives and output
"""
r = re.compile(r"^#.*$\n")
with open(os.path.join(filepath, filename)) as infile:
txt = infile.read()
outtxt = re.sub(r, '', txt)
with open(os.path.join(outpath, filename), 'w') as outfile:
outfile.write(outtxt)