We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add the ROS distro version above the fold
With #1150 we have the new versioning tabs which are moderately small and compact, but that makes it hard to tell what version you're looking at. Having a subtitle or other content at the top to know what version you're looking at at the top would be valuable. It could likely go in as a subtitle under ros2_documentation or elsewhere near the top of the left menu.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conf.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 #
3 # rosindex documentation build configuration file, created by
4 # sphinx-quickstart on Tue Oct  2 16:34:57 2018.
5 #
6 # This file is execfile()d with the current directory set to its
7 # containing dir.
8 #
9 # Note that not all possible configuration values are present in this
10 # autogenerated file.
11 #
12 # All configuration values have a default; values that are commented out
13 # serve to show the default.
14 
15 # If extensions (or modules to document with autodoc) are in another directory,
16 # add these directories to sys.path here. If the directory is relative to the
17 # documentation root, use os.path.abspath to make it absolute, like shown here.
18 #
19 
20 import itertools
21 import os
22 import sys
23 import time
24 
25 from docutils.parsers.rst import Directive
26 
27 sys.path.append(os.path.abspath('./sphinx-multiversion'))
28 
29 
30 # The suffix(es) of source filenames.
31 # You can specify multiple suffix as a list of string:
32 #
33 # The master toctree document.
34 master_doc = 'index'
35 
36 # The default role
37 default_role = 'any'
38 
39 # The set of warnings to suppress.
40 suppress_warnings = ['image.nonlocal_uri']
41 
42 # General information about the project.
43 project = 'ros2 documentation'
44 author = 'Open Robotics'
45 copyright = '{}, {}'.format(time.strftime('%Y'), author)
46 
47 # The version info for the project you're documenting, acts as replacement for
48 # |version| and |release|, also used in various other places throughout the
49 # built documents.
50 #
51 # The short X.Y version.
52 version = u''
53 # The full version, including alpha/beta/rc tags.
54 release = u''
55 
56 # Define the default role to use for links
57 default_role = 'any'
58 
59 # The language for content autogenerated by Sphinx. Refer to documentation
60 # for a list of supported languages.
61 #
62 # This is also used if you do content translation via gettext catalogs.
63 # Usually you set "language" from the command line for these cases.
64 language = None
65 
66 # List of patterns, relative to source directory, that match files and
67 # directories to ignore when looking for source files.
68 # This patterns also effect to html_static_path and html_extra_path
69 exclude_patterns = ['**/_*.rst']
70 
71 # The name of the Pygments (syntax highlighting) style to use.
72 pygments_style = 'sphinx'
73 
74 # Add any Sphinx extension module names here, as strings. They can be
75 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
76 extensions = ['sphinx.ext.intersphinx', 'sphinx_tabs.tabs', 'sphinx_multiversion', 'sphinx_rtd_theme']
77 
78 # Intersphinx mapping
79 
80 intersphinx_mapping = {
81     'catkin_pkg':    ('http://docs.ros.org/en/independent/api/catkin_pkg/html', None),
82     'jenkins_tools': ('http://docs.ros.org/en/independent/api/jenkins_tools/html', None),
83     'rosdep':        ('http://docs.ros.org/en/independent/api/rosdep/html', None),
84     'rosdistro':     ('http://docs.ros.org/en/independent/api/rosdistro/html', None),
85     'rosinstall':    ('http://docs.ros.org/en/independent/api/rosinstall/html', None),
86     'rospkg':        ('http://docs.ros.org/en/independent/api/rospkg/html', None),
87     'vcstools':      ('http://docs.ros.org/en/independent/api/vcstools/html', None)
88 }
89 
90 # -- Options for HTML output ----------------------------------------------
91 
92 # The theme to use for HTML and HTML Help pages.  See the documentation for
93 # a list of builtin themes.
94 #
95 html_theme = 'sphinx_rtd_theme'
96 html_theme_options = {
97     'collapse_navigation': False,
98     'sticky_navigation': True,
99     'navigation_depth': -1,
100 }
101 
102 html_context = {
103     'display_github': True,
104     'github_user': 'ros2',
105     'github_repo': 'ros2_documentation',
106     'github_version': 'rolling/source/',  # Will be overridden when building multiversion
107 }
108 
109 templates_path = [
110     "source/_templates",
111 ]
112 
113 # smv_tag_whitelist = None
114 
115 smv_branch_whitelist = r'^(rolling|foxy|eloquent|dashing|crystal)$'
116 
117 
118 smv_released_pattern = r'^refs/(heads|remotes/[^/]+)/(foxy|eloquent|dashing|crystal).*$'
119 smv_remote_whitelist = r'^(origin)$'
120 smv_latest_version = 'foxy'
121 
122 
123 
124 html_favicon = 'favicon.ico'
125 
126 # Add any paths that contain custom static files (such as style sheets) here,
127 # relative to this directory. They are copied after the builtin static files,
128 # so a file named "default.css" will overwrite the builtin "default.css".
129 # html_static_path = ['_static']
130 
131 # Drop any source link suffix
132 html_sourcelink_suffix = ''
133 
134 # -- Options for HTMLHelp output ------------------------------------------
135 
136 # Output file base name for HTML help builder.
137 htmlhelp_basename = 'ros2_docsdoc'
138 
139 html_baseurl = 'https://docs.ros.org/en'
140 
141 class RedirectFrom(Directive):
142 
143     has_content = True
144     template_name = 'layout.html'
145     redirections = {}
146 
147     @classmethod
148     def register(cls, app):
149         app.connect('html-collect-pages', cls.generate)
150         app.add_directive('redirect-from', cls)
151         return app
152 
153     @classmethod
154     def generate(cls, app):
155         from sphinx.builders.html import StandaloneHTMLBuilder
156         if not isinstance(app.builder, StandaloneHTMLBuilder):
157             return
158 
159         redirect_html_fragment = """
160             <link rel="canonical" href="{base_url}/{url}" />
161             <meta http-equiv="refresh" content="0; url={url}" />
162             <script>
163                 window.location.href = '{url}';
164             </script>
165         """
166         redirections = {
167             os.path.splitext(os.path.relpath(
168                 document_path, app.srcdir
169             ))[0]: redirect_urls
170             for document_path, redirect_urls in cls.redirections.items()
171         }
172         redirection_conflict = next((
173             (canon_1, canon_2, redirs_1.intersection(redirs_2))
174             for (canon_1, redirs_1), (canon_2, redirs_2)
175             in itertools.combinations(redirections.items(), 2)
176             if redirs_1.intersection(redirs_2)
177         ), None)
178         if redirection_conflict:
179             canonical_url_1, canonical_url_2 = redirection_conflict[:2]
180             conflicting_redirect_urls = redirection_conflict[-1]
181             raise RuntimeError(
182                 'Documents {} and {} define conflicting redirects: {}'.format(
183                     canonical_url_1, canonical_url_2, conflicting_redirect_urls
184                 )
185             )
186         all_canonical_urls = set(redirections.keys())
187         all_redirect_urls = {
188             redirect_url
189             for redirect_urls in redirections.values()
190             for redirect_url in redirect_urls
191         }
192         conflicting_urls = all_canonical_urls.intersection(all_redirect_urls)
193         if conflicting_urls:
194             raise RuntimeError(
195                 'Some redirects conflict with existing documents: {}'.format(
196                     conflicting_urls
197                 )
198             )
199 
200         for canonical_url, redirect_urls in redirections.items():
201             for redirect_url in redirect_urls:
202                 context = {
203                     'canonical_url': os.path.relpath(
204                         canonical_url, redirect_url
205                     ),
206                     'title': os.path.basename(redirect_url),
207                     'metatags': redirect_html_fragment.format(
208                         base_url=app.config.html_baseurl,
209                         url=app.builder.get_relative_uri(
210                             redirect_url, canonical_url
211                         )
212                     )
213                 }
214                 yield (redirect_url, context, cls.template_name)
215 
216     def run(self):
217         document_path = self.state.document.current_source
218         if document_path not in RedirectFrom.redirections:
219             RedirectFrom.redirections[document_path] = set()
220         RedirectFrom.redirections[document_path].update(self.content)
221         return []
222 
223 
224 def make_router(origin, destination):
225     def _missing_reference(app, env, node, contnode):
226         from docutils import nodes
227         from docutils.utils import relative_path
228         from sphinx.util import docname_join
229 
230         doctarget = docname_join(node['refdoc'], node['reftarget'])
231         if doctarget.startswith(origin):
232             routed_doctarget = doctarget.replace(origin, destination)
233             if routed_doctarget in env.all_docs:
234                 newnode = nodes.reference(
235                     '', contnode.astext(), internal=True
236                 )
237                 newnode['refuri'] = app.builder.get_relative_uri(
238                     node['refdoc'], routed_doctarget
239                 )
240                 return newnode
241     return _missing_reference
242 
243 def smv_rewrite_baseurl(app, config):
244     # When using Sphinx multiversion, there is no way at initial configuration time
245     # to determine the distribution we are currently targeting (conf.py is read before
246     # external defines are setup, and environment variables aren't passed through to
247     # conf.py).  Instead, hook into the 'config-inited' event which is late enough
248     # to rewrite the html_baseurl with the current version.
249     if app.config.smv_current_version != '':
250         app.config.html_baseurl = app.config.html_baseurl + '/' + app.config.smv_current_version
251 
252 def github_link_rewrite_branch(app, pagename, templatename, context, doctree):
253     if app.config.smv_current_version != '':
254         context['github_version'] = app.config.smv_current_version + '/source/'
255 
256 def setup(app):
257     app.connect('config-inited', smv_rewrite_baseurl)
258     app.connect('html-page-context', github_link_rewrite_branch)
259     RedirectFrom.register(app)
260
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/conf.py b/conf.py
--- a/conf.py
+++ b/conf.py
@@ -40,7 +40,7 @@
 suppress_warnings = ['image.nonlocal_uri']
 
 # General information about the project.
-project = 'ros2 documentation'
+project = 'ROS 2 documentation'
 author = 'Open Robotics'
 copyright = '{}, {}'.format(time.strftime('%Y'), author)
 
@@ -248,6 +248,7 @@
     # to rewrite the html_baseurl with the current version.
     if app.config.smv_current_version != '':
         app.config.html_baseurl = app.config.html_baseurl + '/' + app.config.smv_current_version
+        app.config.project = 'ROS 2 Documentation: ' + app.config.smv_current_version.title()
 
 def github_link_rewrite_branch(app, pagename, templatename, context, doctree):
     if app.config.smv_current_version != '':

{"golden_diff": "diff --git a/conf.py b/conf.py\n--- a/conf.py\n+++ b/conf.py\n@@ -40,7 +40,7 @@\n suppress_warnings = ['image.nonlocal_uri']\n \n # General information about the project.\n-project = 'ros2 documentation'\n+project = 'ROS 2 documentation'\n author = 'Open Robotics'\n copyright = '{}, {}'.format(time.strftime('%Y'), author)\n \n@@ -248,6 +248,7 @@\n     # to rewrite the html_baseurl with the current version.\n     if app.config.smv_current_version != '':\n         app.config.html_baseurl = app.config.html_baseurl + '/' + app.config.smv_current_version\n+        app.config.project = 'ROS 2 Documentation: ' + app.config.smv_current_version.title()\n \n def github_link_rewrite_branch(app, pagename, templatename, context, doctree):\n     if app.config.smv_current_version != '':\n", "issue": "Add the ROS distro version above the fold\nWith #1150 we have the new versioning tabs which are moderately small and compact, but that makes it hard to tell what version you're looking at. Having a subtitle or other content at the top to know what version you're looking at at the top would be valuable. It could likely go in as a subtitle under ros2_documentation or elsewhere near the top of the left menu.\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# rosindex documentation build configuration file, created by\n# sphinx-quickstart on Tue Oct  2 16:34:57 2018.\n#\n# This file is execfile()d with the current directory set to its\n# containing dir.\n#\n# Note that not all possible configuration values are present in this\n# autogenerated file.\n#\n# All configuration values have a default; values that are commented out\n# serve to show the default.\n\n# If extensions (or modules to document with autodoc) are in another directory,\n# add these directories to sys.path here. If the directory is relative to the\n# documentation root, use os.path.abspath to make it absolute, like shown here.\n#\n\nimport itertools\nimport os\nimport sys\nimport time\n\nfrom docutils.parsers.rst import Directive\n\nsys.path.append(os.path.abspath('./sphinx-multiversion'))\n\n\n# The suffix(es) of source filenames.\n# You can specify multiple suffix as a list of string:\n#\n# The master toctree document.\nmaster_doc = 'index'\n\n# The default role\ndefault_role = 'any'\n\n# The set of warnings to suppress.\nsuppress_warnings = ['image.nonlocal_uri']\n\n# General information about the project.\nproject = 'ros2 documentation'\nauthor = 'Open Robotics'\ncopyright = '{}, {}'.format(time.strftime('%Y'), author)\n\n# The version info for the project you're documenting, acts as replacement for\n# |version| and |release|, also used in various other places throughout the\n# built documents.\n#\n# The short X.Y version.\nversion = u''\n# The full version, including alpha/beta/rc tags.\nrelease = u''\n\n# Define the default role to use for links\ndefault_role = 'any'\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n#\n# This is also used if you do content translation via gettext catalogs.\n# Usually you set \"language\" from the command line for these cases.\nlanguage = None\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\n# This patterns also effect to html_static_path and html_extra_path\nexclude_patterns = ['**/_*.rst']\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = 'sphinx'\n\n# Add any Sphinx extension module names here, as strings. They can be\n# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom\nextensions = ['sphinx.ext.intersphinx', 'sphinx_tabs.tabs', 'sphinx_multiversion', 'sphinx_rtd_theme']\n\n# Intersphinx mapping\n\nintersphinx_mapping = {\n    'catkin_pkg':    ('http://docs.ros.org/en/independent/api/catkin_pkg/html', None),\n    'jenkins_tools': ('http://docs.ros.org/en/independent/api/jenkins_tools/html', None),\n    'rosdep':        ('http://docs.ros.org/en/independent/api/rosdep/html', None),\n    'rosdistro':     ('http://docs.ros.org/en/independent/api/rosdistro/html', None),\n    'rosinstall':    ('http://docs.ros.org/en/independent/api/rosinstall/html', None),\n    'rospkg':        ('http://docs.ros.org/en/independent/api/rospkg/html', None),\n    'vcstools':      ('http://docs.ros.org/en/independent/api/vcstools/html', None)\n}\n\n# -- Options for HTML output ----------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.  See the documentation for\n# a list of builtin themes.\n#\nhtml_theme = 'sphinx_rtd_theme'\nhtml_theme_options = {\n    'collapse_navigation': False,\n    'sticky_navigation': True,\n    'navigation_depth': -1,\n}\n\nhtml_context = {\n    'display_github': True,\n    'github_user': 'ros2',\n    'github_repo': 'ros2_documentation',\n    'github_version': 'rolling/source/',  # Will be overridden when building multiversion\n}\n\ntemplates_path = [\n    \"source/_templates\",\n]\n\n# smv_tag_whitelist = None\n\nsmv_branch_whitelist = r'^(rolling|foxy|eloquent|dashing|crystal)$'\n\n\nsmv_released_pattern = r'^refs/(heads|remotes/[^/]+)/(foxy|eloquent|dashing|crystal).*$'\nsmv_remote_whitelist = r'^(origin)$'\nsmv_latest_version = 'foxy'\n\n\n\nhtml_favicon = 'favicon.ico'\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\n# html_static_path = ['_static']\n\n# Drop any source link suffix\nhtml_sourcelink_suffix = ''\n\n# -- Options for HTMLHelp output ------------------------------------------\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = 'ros2_docsdoc'\n\nhtml_baseurl = 'https://docs.ros.org/en'\n\nclass RedirectFrom(Directive):\n\n    has_content = True\n    template_name = 'layout.html'\n    redirections = {}\n\n    @classmethod\n    def register(cls, app):\n        app.connect('html-collect-pages', cls.generate)\n        app.add_directive('redirect-from', cls)\n        return app\n\n    @classmethod\n    def generate(cls, app):\n        from sphinx.builders.html import StandaloneHTMLBuilder\n        if not isinstance(app.builder, StandaloneHTMLBuilder):\n            return\n\n        redirect_html_fragment = \"\"\"\n            <link rel=\"canonical\" href=\"{base_url}/{url}\" />\n            <meta http-equiv=\"refresh\" content=\"0; url={url}\" />\n            <script>\n                window.location.href = '{url}';\n            </script>\n        \"\"\"\n        redirections = {\n            os.path.splitext(os.path.relpath(\n                document_path, app.srcdir\n            ))[0]: redirect_urls\n            for document_path, redirect_urls in cls.redirections.items()\n        }\n        redirection_conflict = next((\n            (canon_1, canon_2, redirs_1.intersection(redirs_2))\n            for (canon_1, redirs_1), (canon_2, redirs_2)\n            in itertools.combinations(redirections.items(), 2)\n            if redirs_1.intersection(redirs_2)\n        ), None)\n        if redirection_conflict:\n            canonical_url_1, canonical_url_2 = redirection_conflict[:2]\n            conflicting_redirect_urls = redirection_conflict[-1]\n            raise RuntimeError(\n                'Documents {} and {} define conflicting redirects: {}'.format(\n                    canonical_url_1, canonical_url_2, conflicting_redirect_urls\n                )\n            )\n        all_canonical_urls = set(redirections.keys())\n        all_redirect_urls = {\n            redirect_url\n            for redirect_urls in redirections.values()\n            for redirect_url in redirect_urls\n        }\n        conflicting_urls = all_canonical_urls.intersection(all_redirect_urls)\n        if conflicting_urls:\n            raise RuntimeError(\n                'Some redirects conflict with existing documents: {}'.format(\n                    conflicting_urls\n                )\n            )\n\n        for canonical_url, redirect_urls in redirections.items():\n            for redirect_url in redirect_urls:\n                context = {\n                    'canonical_url': os.path.relpath(\n                        canonical_url, redirect_url\n                    ),\n                    'title': os.path.basename(redirect_url),\n                    'metatags': redirect_html_fragment.format(\n                        base_url=app.config.html_baseurl,\n                        url=app.builder.get_relative_uri(\n                            redirect_url, canonical_url\n                        )\n                    )\n                }\n                yield (redirect_url, context, cls.template_name)\n\n    def run(self):\n        document_path = self.state.document.current_source\n        if document_path not in RedirectFrom.redirections:\n            RedirectFrom.redirections[document_path] = set()\n        RedirectFrom.redirections[document_path].update(self.content)\n        return []\n\n\ndef make_router(origin, destination):\n    def _missing_reference(app, env, node, contnode):\n        from docutils import nodes\n        from docutils.utils import relative_path\n        from sphinx.util import docname_join\n\n        doctarget = docname_join(node['refdoc'], node['reftarget'])\n        if doctarget.startswith(origin):\n            routed_doctarget = doctarget.replace(origin, destination)\n            if routed_doctarget in env.all_docs:\n                newnode = nodes.reference(\n                    '', contnode.astext(), internal=True\n                )\n                newnode['refuri'] = app.builder.get_relative_uri(\n                    node['refdoc'], routed_doctarget\n                )\n                return newnode\n    return _missing_reference\n\ndef smv_rewrite_baseurl(app, config):\n    # When using Sphinx multiversion, there is no way at initial configuration time\n    # to determine the distribution we are currently targeting (conf.py is read before\n    # external defines are setup, and environment variables aren't passed through to\n    # conf.py).  Instead, hook into the 'config-inited' event which is late enough\n    # to rewrite the html_baseurl with the current version.\n    if app.config.smv_current_version != '':\n        app.config.html_baseurl = app.config.html_baseurl + '/' + app.config.smv_current_version\n\ndef github_link_rewrite_branch(app, pagename, templatename, context, doctree):\n    if app.config.smv_current_version != '':\n        context['github_version'] = app.config.smv_current_version + '/source/'\n\ndef setup(app):\n    app.connect('config-inited', smv_rewrite_baseurl)\n    app.connect('html-page-context', github_link_rewrite_branch)\n    RedirectFrom.register(app)\n", "path": "conf.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# rosindex documentation build configuration file, created by\n# sphinx-quickstart on Tue Oct  2 16:34:57 2018.\n#\n# This file is execfile()d with the current directory set to its\n# containing dir.\n#\n# Note that not all possible configuration values are present in this\n# autogenerated file.\n#\n# All configuration values have a default; values that are commented out\n# serve to show the default.\n\n# If extensions (or modules to document with autodoc) are in another directory,\n# add these directories to sys.path here. If the directory is relative to the\n# documentation root, use os.path.abspath to make it absolute, like shown here.\n#\n\nimport itertools\nimport os\nimport sys\nimport time\n\nfrom docutils.parsers.rst import Directive\n\nsys.path.append(os.path.abspath('./sphinx-multiversion'))\n\n\n# The suffix(es) of source filenames.\n# You can specify multiple suffix as a list of string:\n#\n# The master toctree document.\nmaster_doc = 'index'\n\n# The default role\ndefault_role = 'any'\n\n# The set of warnings to suppress.\nsuppress_warnings = ['image.nonlocal_uri']\n\n# General information about the project.\nproject = 'ROS 2 documentation'\nauthor = 'Open Robotics'\ncopyright = '{}, {}'.format(time.strftime('%Y'), author)\n\n# The version info for the project you're documenting, acts as replacement for\n# |version| and |release|, also used in various other places throughout the\n# built documents.\n#\n# The short X.Y version.\nversion = u''\n# The full version, including alpha/beta/rc tags.\nrelease = u''\n\n# Define the default role to use for links\ndefault_role = 'any'\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n#\n# This is also used if you do content translation via gettext catalogs.\n# Usually you set \"language\" from the command line for these cases.\nlanguage = None\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\n# This patterns also effect to html_static_path and html_extra_path\nexclude_patterns = ['**/_*.rst']\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = 'sphinx'\n\n# Add any Sphinx extension module names here, as strings. They can be\n# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom\nextensions = ['sphinx.ext.intersphinx', 'sphinx_tabs.tabs', 'sphinx_multiversion', 'sphinx_rtd_theme']\n\n# Intersphinx mapping\n\nintersphinx_mapping = {\n    'catkin_pkg':    ('http://docs.ros.org/en/independent/api/catkin_pkg/html', None),\n    'jenkins_tools': ('http://docs.ros.org/en/independent/api/jenkins_tools/html', None),\n    'rosdep':        ('http://docs.ros.org/en/independent/api/rosdep/html', None),\n    'rosdistro':     ('http://docs.ros.org/en/independent/api/rosdistro/html', None),\n    'rosinstall':    ('http://docs.ros.org/en/independent/api/rosinstall/html', None),\n    'rospkg':        ('http://docs.ros.org/en/independent/api/rospkg/html', None),\n    'vcstools':      ('http://docs.ros.org/en/independent/api/vcstools/html', None)\n}\n\n# -- Options for HTML output ----------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.  See the documentation for\n# a list of builtin themes.\n#\nhtml_theme = 'sphinx_rtd_theme'\nhtml_theme_options = {\n    'collapse_navigation': False,\n    'sticky_navigation': True,\n    'navigation_depth': -1,\n}\n\nhtml_context = {\n    'display_github': True,\n    'github_user': 'ros2',\n    'github_repo': 'ros2_documentation',\n    'github_version': 'rolling/source/',  # Will be overridden when building multiversion\n}\n\ntemplates_path = [\n    \"source/_templates\",\n]\n\n# smv_tag_whitelist = None\n\nsmv_branch_whitelist = r'^(rolling|foxy|eloquent|dashing|crystal)$'\n\n\nsmv_released_pattern = r'^refs/(heads|remotes/[^/]+)/(foxy|eloquent|dashing|crystal).*$'\nsmv_remote_whitelist = r'^(origin)$'\nsmv_latest_version = 'foxy'\n\n\n\nhtml_favicon = 'favicon.ico'\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\n# html_static_path = ['_static']\n\n# Drop any source link suffix\nhtml_sourcelink_suffix = ''\n\n# -- Options for HTMLHelp output ------------------------------------------\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = 'ros2_docsdoc'\n\nhtml_baseurl = 'https://docs.ros.org/en'\n\nclass RedirectFrom(Directive):\n\n    has_content = True\n    template_name = 'layout.html'\n    redirections = {}\n\n    @classmethod\n    def register(cls, app):\n        app.connect('html-collect-pages', cls.generate)\n        app.add_directive('redirect-from', cls)\n        return app\n\n    @classmethod\n    def generate(cls, app):\n        from sphinx.builders.html import StandaloneHTMLBuilder\n        if not isinstance(app.builder, StandaloneHTMLBuilder):\n            return\n\n        redirect_html_fragment = \"\"\"\n            <link rel=\"canonical\" href=\"{base_url}/{url}\" />\n            <meta http-equiv=\"refresh\" content=\"0; url={url}\" />\n            <script>\n                window.location.href = '{url}';\n            </script>\n        \"\"\"\n        redirections = {\n            os.path.splitext(os.path.relpath(\n                document_path, app.srcdir\n            ))[0]: redirect_urls\n            for document_path, redirect_urls in cls.redirections.items()\n        }\n        redirection_conflict = next((\n            (canon_1, canon_2, redirs_1.intersection(redirs_2))\n            for (canon_1, redirs_1), (canon_2, redirs_2)\n            in itertools.combinations(redirections.items(), 2)\n            if redirs_1.intersection(redirs_2)\n        ), None)\n        if redirection_conflict:\n            canonical_url_1, canonical_url_2 = redirection_conflict[:2]\n            conflicting_redirect_urls = redirection_conflict[-1]\n            raise RuntimeError(\n                'Documents {} and {} define conflicting redirects: {}'.format(\n                    canonical_url_1, canonical_url_2, conflicting_redirect_urls\n                )\n            )\n        all_canonical_urls = set(redirections.keys())\n        all_redirect_urls = {\n            redirect_url\n            for redirect_urls in redirections.values()\n            for redirect_url in redirect_urls\n        }\n        conflicting_urls = all_canonical_urls.intersection(all_redirect_urls)\n        if conflicting_urls:\n            raise RuntimeError(\n                'Some redirects conflict with existing documents: {}'.format(\n                    conflicting_urls\n                )\n            )\n\n        for canonical_url, redirect_urls in redirections.items():\n            for redirect_url in redirect_urls:\n                context = {\n                    'canonical_url': os.path.relpath(\n                        canonical_url, redirect_url\n                    ),\n                    'title': os.path.basename(redirect_url),\n                    'metatags': redirect_html_fragment.format(\n                        base_url=app.config.html_baseurl,\n                        url=app.builder.get_relative_uri(\n                            redirect_url, canonical_url\n                        )\n                    )\n                }\n                yield (redirect_url, context, cls.template_name)\n\n    def run(self):\n        document_path = self.state.document.current_source\n        if document_path not in RedirectFrom.redirections:\n            RedirectFrom.redirections[document_path] = set()\n        RedirectFrom.redirections[document_path].update(self.content)\n        return []\n\n\ndef make_router(origin, destination):\n    def _missing_reference(app, env, node, contnode):\n        from docutils import nodes\n        from docutils.utils import relative_path\n        from sphinx.util import docname_join\n\n        doctarget = docname_join(node['refdoc'], node['reftarget'])\n        if doctarget.startswith(origin):\n            routed_doctarget = doctarget.replace(origin, destination)\n            if routed_doctarget in env.all_docs:\n                newnode = nodes.reference(\n                    '', contnode.astext(), internal=True\n                )\n                newnode['refuri'] = app.builder.get_relative_uri(\n                    node['refdoc'], routed_doctarget\n                )\n                return newnode\n    return _missing_reference\n\ndef smv_rewrite_baseurl(app, config):\n    # When using Sphinx multiversion, there is no way at initial configuration time\n    # to determine the distribution we are currently targeting (conf.py is read before\n    # external defines are setup, and environment variables aren't passed through to\n    # conf.py).  Instead, hook into the 'config-inited' event which is late enough\n    # to rewrite the html_baseurl with the current version.\n    if app.config.smv_current_version != '':\n        app.config.html_baseurl = app.config.html_baseurl + '/' + app.config.smv_current_version\n        app.config.project = 'ROS 2 Documentation: ' + app.config.smv_current_version.title()\n\ndef github_link_rewrite_branch(app, pagename, templatename, context, doctree):\n    if app.config.smv_current_version != '':\n        context['github_version'] = app.config.smv_current_version + '/source/'\n\ndef setup(app):\n    app.connect('config-inited', smv_rewrite_baseurl)\n    app.connect('html-page-context', github_link_rewrite_branch)\n    RedirectFrom.register(app)\n", "path": "conf.py"}]}