EGS Brachy
An egs++ user code for rapid brachytherapy calculations
Loading...
Searching...
No Matches
doc_utils.py
Go to the documentation of this file.
1import os
2
3def find_file_descriptions(dir_path, include_key=None):
4
5 items = []
6
7 for root, dirs, files in os.walk(dir_path):
8 for f in sorted(files):
9
10 f = os.path.relpath(os.path.join(root, f))
11 try:
12 contents = open(f, "r").read()
13 except:
14 continue
15
16
17 # exclude files that don't contain the include_key search string
18 if include_key is not None and include_key not in contents:
19 continue
20
21 comments = []
22 for l in contents.split("\n"):
23 if l[:2] == "##":
24 comments.append(l[2:])
25
26 description = "".join(comments) if comments else "_No description available_"
27 fname = os.path.split(f)[1]
28 description = """## %s\n**File Location:** %s\n\n%s\n""" % (fname, f.strip("./"), description)
29
30 items.append(description)
31
32 return "\n".join(items)
33
34
string join(const vector< string > &v, string delim)
Definition ginfo.cpp:56