Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85db703

Browse files
committed
Tool to go around sphinx limitation during developpement
1 parent 9983091 commit 85db703

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tools/fixup_whats_new_pr.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
This tool is used during CI testing to make sure sphinx raise no error.
3+
4+
During development, we like to have whatsnew/pr/*.rst documents to track
5+
individual new features. Unfortunately they other either:
6+
- have no title (sphinx complains)
7+
- are not included in any toctree (sphinx complain)
8+
9+
This fix-them up by "inventing" a title, before building the docs. At release
10+
time, these title and files will anyway be rewritten into the actual release
11+
notes.
12+
"""
13+
14+
import glob
15+
16+
17+
def main():
18+
folder = 'docs/source/whatsnew/pr/'
19+
assert folder.endswith('/')
20+
files = glob.glob(folder+'*.rst')
21+
print(files)
22+
23+
for filename in files:
24+
print('Adding pseudo-title to:', filename)
25+
title = filename[:-4].split('/')[-1].replace('-', ' ').capitalize()
26+
27+
with open(filename) as f:
28+
data = f.read()
29+
if data and data.splitlines()[1].startswith('='):
30+
continue
31+
32+
with open(filename, 'w') as f:
33+
f.write(title+'\n')
34+
f.write('='* len(title)+'\n\n')
35+
f.write(data)
36+
37+
if __name__ == '__main__':
38+
main()
39+
40+
41+
42+
43+

0 commit comments

Comments
 (0)