forked from facebookresearch/ParlAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostprocess_docs.py
28 lines (23 loc) · 1.11 KB
/
postprocess_docs.py
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
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
NEEDLE3 = '— ParlAI documentation</title>'
REPLACEMENT3 = """
— ParlAI Documentation</title>
<link rel="shortcut icon" type="image/png" href="/static/img/favicon-32x32.png" sizes="32x32"/>
<link rel="shortcut icon" type="image/png" href="/static/img/favicon-16x16.png" sizes="16x16"/>
<link rel="shortcut icon" type="image/png" href="/static/img/favicon-96x96.png" sizes="96x96"/>
""".strip() # noqa: E501
if __name__ == '__main__':
for root, _, files in os.walk("build/docs/"):
for file in files:
if file.endswith(".html"):
file_path = os.path.join(root, file)
print("Postprocessing ", file_path)
with open(file_path, 'r') as fin:
content = fin.read()
content = content.replace(NEEDLE3, REPLACEMENT3)
with open(file_path, 'w') as fout:
fout.write(content)