Skip to content

Commit

Permalink
Add sitemap (ros2#2261)
Browse files Browse the repository at this point in the history
* Add sitemap plugin

* Make sitemapindex

Signed-off-by: Audrow Nash <[email protected]>
  • Loading branch information
audrow authored Feb 1, 2022
1 parent 181dd9d commit fc8a4a5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ help:
multiversion: Makefile
sphinx-multiversion $(OPTS) "$(SOURCE)" build/html
@echo "<html><head><meta http-equiv=\"refresh\" content=\"0; url=galactic/index.html\" /></head></html>" > build/html/index.html
python3 make_sitemapindex.py

.PHONY: help Makefile multiversion
%: Makefile
Expand Down
11 changes: 10 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,16 @@

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
extensions = ['sphinx.ext.intersphinx', 'sphinx_tabs.tabs', 'sphinx_multiversion', 'sphinx_rtd_theme', 'sphinx.ext.ifconfig', 'sphinx_copybutton', 'sphinx.ext.graphviz']
extensions = [
'sphinx.ext.graphviz',
'sphinx.ext.ifconfig',
'sphinx.ext.intersphinx',
'sphinx_copybutton',
'sphinx_multiversion',
'sphinx_tabs.tabs',
'sphinx_rtd_theme',
'sphinx_sitemap',
]

# Intersphinx mapping

Expand Down
17 changes: 17 additions & 0 deletions make_sitemapindex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from xml.etree.ElementTree import Element, SubElement, ElementTree
from conf import distro_full_names, html_baseurl


def make_sitemapindex(sitemap_file):

sitemapindex = Element('sitemapindex')
sitemapindex.set('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9')
for distro in distro_full_names.keys():
node = SubElement(sitemapindex, 'sitemap')
SubElement(node, 'loc').text = f'{html_baseurl}/{distro}/sitemap.xml'

ElementTree(sitemapindex).write(sitemap_file, encoding='utf-8', xml_declaration=True)

if __name__ == '__main__':
sitemap_file = 'build/html/sitemap.xml'
make_sitemapindex(sitemap_file)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ sphinx
sphinx-copybutton
sphinx-multiversion
sphinx-rtd-theme
sphinx-sitemap
sphinx-tabs

0 comments on commit fc8a4a5

Please sign in to comment.