Skip to content

Commit fc8a4a5

Browse files
authored
Add sitemap (ros2#2261)
* Add sitemap plugin * Make sitemapindex Signed-off-by: Audrow Nash <[email protected]>
1 parent 181dd9d commit fc8a4a5

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ help:
1212
multiversion: Makefile
1313
sphinx-multiversion $(OPTS) "$(SOURCE)" build/html
1414
@echo "<html><head><meta http-equiv=\"refresh\" content=\"0; url=galactic/index.html\" /></head></html>" > build/html/index.html
15+
python3 make_sitemapindex.py
1516

1617
.PHONY: help Makefile multiversion
1718
%: Makefile

conf.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,16 @@
7373

7474
# Add any Sphinx extension module names here, as strings. They can be
7575
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
76-
extensions = ['sphinx.ext.intersphinx', 'sphinx_tabs.tabs', 'sphinx_multiversion', 'sphinx_rtd_theme', 'sphinx.ext.ifconfig', 'sphinx_copybutton', 'sphinx.ext.graphviz']
76+
extensions = [
77+
'sphinx.ext.graphviz',
78+
'sphinx.ext.ifconfig',
79+
'sphinx.ext.intersphinx',
80+
'sphinx_copybutton',
81+
'sphinx_multiversion',
82+
'sphinx_tabs.tabs',
83+
'sphinx_rtd_theme',
84+
'sphinx_sitemap',
85+
]
7786

7887
# Intersphinx mapping
7988

make_sitemapindex.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from xml.etree.ElementTree import Element, SubElement, ElementTree
2+
from conf import distro_full_names, html_baseurl
3+
4+
5+
def make_sitemapindex(sitemap_file):
6+
7+
sitemapindex = Element('sitemapindex')
8+
sitemapindex.set('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9')
9+
for distro in distro_full_names.keys():
10+
node = SubElement(sitemapindex, 'sitemap')
11+
SubElement(node, 'loc').text = f'{html_baseurl}/{distro}/sitemap.xml'
12+
13+
ElementTree(sitemapindex).write(sitemap_file, encoding='utf-8', xml_declaration=True)
14+
15+
if __name__ == '__main__':
16+
sitemap_file = 'build/html/sitemap.xml'
17+
make_sitemapindex(sitemap_file)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ sphinx
55
sphinx-copybutton
66
sphinx-multiversion
77
sphinx-rtd-theme
8+
sphinx-sitemap
89
sphinx-tabs

0 commit comments

Comments
 (0)