postProcessDoxygen.py
Go to the documentation of this file.
1#! /usr/bin/env python3
2
3import sys
4import os
5import datetime
6
7def main():
8 mypath = sys.argv[1]
9
10 print('Patching external links in doxygen docu')
11
12 # Patch <a href to use target _blank
13 htmlFiles = [os.path.join(mypath, f) for f in os.listdir(mypath) if (os.path.isfile(os.path.join(mypath, f)) and f.endswith('.html'))]
14
15 for f in htmlFiles:
16 data = open(f, 'r', encoding='utf-8').read()
17
18 data = data.replace('href="http', 'target="_blank" href="http')
19
20 open(f, 'w', encoding='utf-8').write(data)
21
22
23 print('Removing empty markdown source files')
24 [os.remove(os.path.join(mypath, f)) for f in os.listdir(mypath) if (os.path.isfile(os.path.join(mypath, f)) and f.endswith('8md.html'))]
25
26 print('Creating sitemap.xml')
27
28 htmlFiles = [f for f in os.listdir(mypath) if (os.path.isfile(os.path.join(mypath, f)) and f.endswith('.html') and not f.endswith('source.html'))]
29
30 xmlData = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
31
32 now = datetime.datetime.now()
33 time = now.strftime("%Y-%m-%dT%H:%M:%S+00:00")
34
35 xmlData += ' <url><loc>https://docs.cppinsights.io/%s</loc><lastmod>%s</lastmod><priority>1.00</priority></url>\n' %('', time)
36
37 for f in htmlFiles:
38 xmlData += ' <url><loc>https://docs.cppinsights.io/%s</loc><lastmod>%s</lastmod><priority>0.80</priority></url>\n' %(f, time)
39
40 xmlData += '</urlset>\n'
41
42 open(os.path.join(mypath,'sitemap.xml'), 'w', encoding='utf-8').write(xmlData)
43
44 return
45
46sys.exit(main())