We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Update instructions for checking out develop, release and rolling (master) branches
Due to the release of rolling, and galactic being branched off rolling, there are some instructions that require updating in [Maintaining-a-Source-Checkout.rst](https://github.com/ros2/ros2_documentation/blob/rolling/source/Installation/Maintaining-a-Source-Checkout.rst) . We must clarify between the different type of checkouts.

See [this conversation](https://github.com/ros2/ros2_documentation/pull/1693#discussion_r657035616)  for details.

--- 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 = 'ROS 2 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|galactic|foxy|eloquent|dashing|crystal)$'
116 
117 
118 smv_released_pattern = r'^refs/(heads|remotes/[^/]+)/(galactic|foxy|eloquent|dashing|crystal).*$'
119 smv_remote_whitelist = r'^(origin)$'
120 smv_latest_version = 'galactic'
121 smv_eol_versions = ['crystal', 'dashing', 'eloquent']
122 
123 distro_full_names = {
124     'crystal': 'Crystal Clemmys',
125     'dashing': 'Dashing Diademata',
126     'eloquent': 'Eloquent Elusor',
127     'foxy': 'Foxy Fitzroy',
128     'galactic': 'Galactic Geochelone',
129     'rolling': 'Rolling Ridley',
130 }
131 
132 # These default values will be overridden when building multiversion
133 macros = {
134     'DISTRO': 'rolling',
135     'DISTRO_TITLE': 'Rolling',
136     'DISTRO_TITLE_FULL': 'Rolling Ridley',
137     'REPOS_FILE_BRANCH': 'master',
138 }
139 
140 html_favicon = 'favicon.ico'
141 
142 # Add any paths that contain custom static files (such as style sheets) here,
143 # relative to this directory. They are copied after the builtin static files,
144 # so a file named "default.css" will overwrite the builtin "default.css".
145 # html_static_path = ['_static']
146 
147 # Drop any source link suffix
148 html_sourcelink_suffix = ''
149 
150 # -- Options for HTMLHelp output ------------------------------------------
151 
152 # Output file base name for HTML help builder.
153 htmlhelp_basename = 'ros2_docsdoc'
154 
155 html_baseurl = 'https://docs.ros.org/en'
156 
157 class RedirectFrom(Directive):
158 
159     has_content = True
160     template_name = 'layout.html'
161     redirections = {}
162 
163     @classmethod
164     def register(cls, app):
165         app.connect('html-collect-pages', cls.generate)
166         app.add_directive('redirect-from', cls)
167         return app
168 
169     @classmethod
170     def generate(cls, app):
171         from sphinx.builders.html import StandaloneHTMLBuilder
172         if not isinstance(app.builder, StandaloneHTMLBuilder):
173             return
174 
175         redirect_html_fragment = """
176             <link rel="canonical" href="{base_url}/{url}" />
177             <meta http-equiv="refresh" content="0; url={url}" />
178             <script>
179                 window.location.href = '{url}';
180             </script>
181         """
182         redirections = {
183             os.path.splitext(os.path.relpath(
184                 document_path, app.srcdir
185             ))[0]: redirect_urls
186             for document_path, redirect_urls in cls.redirections.items()
187         }
188         redirection_conflict = next((
189             (canon_1, canon_2, redirs_1.intersection(redirs_2))
190             for (canon_1, redirs_1), (canon_2, redirs_2)
191             in itertools.combinations(redirections.items(), 2)
192             if redirs_1.intersection(redirs_2)
193         ), None)
194         if redirection_conflict:
195             canonical_url_1, canonical_url_2 = redirection_conflict[:2]
196             conflicting_redirect_urls = redirection_conflict[-1]
197             raise RuntimeError(
198                 'Documents {} and {} define conflicting redirects: {}'.format(
199                     canonical_url_1, canonical_url_2, conflicting_redirect_urls
200                 )
201             )
202         all_canonical_urls = set(redirections.keys())
203         all_redirect_urls = {
204             redirect_url
205             for redirect_urls in redirections.values()
206             for redirect_url in redirect_urls
207         }
208         conflicting_urls = all_canonical_urls.intersection(all_redirect_urls)
209         if conflicting_urls:
210             raise RuntimeError(
211                 'Some redirects conflict with existing documents: {}'.format(
212                     conflicting_urls
213                 )
214             )
215 
216         for canonical_url, redirect_urls in redirections.items():
217             for redirect_url in redirect_urls:
218                 context = {
219                     'canonical_url': os.path.relpath(
220                         canonical_url, redirect_url
221                     ),
222                     'title': os.path.basename(redirect_url),
223                     'metatags': redirect_html_fragment.format(
224                         base_url=app.config.html_baseurl,
225                         url=app.builder.get_relative_uri(
226                             redirect_url, canonical_url
227                         )
228                     )
229                 }
230                 yield (redirect_url, context, cls.template_name)
231 
232     def run(self):
233         document_path = self.state.document.current_source
234         if document_path not in RedirectFrom.redirections:
235             RedirectFrom.redirections[document_path] = set()
236         RedirectFrom.redirections[document_path].update(self.content)
237         return []
238 
239 
240 def make_router(origin, destination):
241     def _missing_reference(app, env, node, contnode):
242         from docutils import nodes
243         from docutils.utils import relative_path
244         from sphinx.util import docname_join
245 
246         doctarget = docname_join(node['refdoc'], node['reftarget'])
247         if doctarget.startswith(origin):
248             routed_doctarget = doctarget.replace(origin, destination)
249             if routed_doctarget in env.all_docs:
250                 newnode = nodes.reference(
251                     '', contnode.astext(), internal=True
252                 )
253                 newnode['refuri'] = app.builder.get_relative_uri(
254                     node['refdoc'], routed_doctarget
255                 )
256                 return newnode
257     return _missing_reference
258 
259 def smv_rewrite_configs(app, config):
260     # When using Sphinx multiversion, there is no way at initial configuration time
261     # to determine the distribution we are currently targeting (conf.py is read before
262     # external defines are setup, and environment variables aren't passed through to
263     # conf.py).  Instead, hook into the 'config-inited' event which is late enough
264     # to rewrite the various configuration items with the current version.
265     if app.config.smv_current_version != '':
266         app.config.html_baseurl = app.config.html_baseurl + '/' + app.config.smv_current_version
267         app.config.project = 'ROS 2 Documentation: ' + app.config.smv_current_version.title()
268 
269         if app.config.smv_current_version not in ['rolling']:
270             app.config.html_logo = 'source/Releases/' + app.config.smv_current_version + '-small.png'
271 
272         # Override default values
273         distro = app.config.smv_current_version
274         app.config.macros = {
275             'DISTRO': distro,
276             'DISTRO_TITLE': distro.title(),
277             'DISTRO_TITLE_FULL': distro_full_names[distro],
278             'REPOS_FILE_BRANCH' : 'master' if distro == 'rolling' else distro,
279         }
280 
281 def github_link_rewrite_branch(app, pagename, templatename, context, doctree):
282     if app.config.smv_current_version != '':
283         context['github_version'] = app.config.smv_current_version + '/source/'
284         context['eol_versions'] = app.config.smv_eol_versions
285 
286 def expand_macros(app, docname, source):
287     result = source[0]
288     for key, value in app.config.macros.items():
289         result = result.replace(f'{{{key}}}', value)
290     source[0] = result
291 
292 def setup(app):
293     app.connect('config-inited', smv_rewrite_configs)
294     app.connect('html-page-context', github_link_rewrite_branch)
295     app.connect('source-read', expand_macros)
296     app.add_config_value('smv_eol_versions', [], 'html')
297     app.add_config_value('macros', {}, True)
298     RedirectFrom.register(app)
299
```
--- 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
@@ -73,7 +73,7 @@
 
 # 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']
+extensions = ['sphinx.ext.intersphinx', 'sphinx_tabs.tabs', 'sphinx_multiversion', 'sphinx_rtd_theme', 'sphinx.ext.ifconfig']
 
 # Intersphinx mapping

{"golden_diff": "diff --git a/conf.py b/conf.py\n--- a/conf.py\n+++ b/conf.py\n@@ -73,7 +73,7 @@\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\n-extensions = ['sphinx.ext.intersphinx', 'sphinx_tabs.tabs', 'sphinx_multiversion', 'sphinx_rtd_theme']\n+extensions = ['sphinx.ext.intersphinx', 'sphinx_tabs.tabs', 'sphinx_multiversion', 'sphinx_rtd_theme', 'sphinx.ext.ifconfig']\n \n # Intersphinx mapping\n", "issue": "Update instructions for checking out develop, release and rolling (master) branches\nDue to the release of rolling, and galactic being branched off rolling, there are some instructions that require updating in [Maintaining-a-Source-Checkout.rst](https://github.com/ros2/ros2_documentation/blob/rolling/source/Installation/Maintaining-a-Source-Checkout.rst) . We must clarify between the different type of checkouts.\r\n\r\nSee [this conversation](https://github.com/ros2/ros2_documentation/pull/1693#discussion_r657035616)  for details.\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 = '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|galactic|foxy|eloquent|dashing|crystal)$'\n\n\nsmv_released_pattern = r'^refs/(heads|remotes/[^/]+)/(galactic|foxy|eloquent|dashing|crystal).*$'\nsmv_remote_whitelist = r'^(origin)$'\nsmv_latest_version = 'galactic'\nsmv_eol_versions = ['crystal', 'dashing', 'eloquent']\n\ndistro_full_names = {\n    'crystal': 'Crystal Clemmys',\n    'dashing': 'Dashing Diademata',\n    'eloquent': 'Eloquent Elusor',\n    'foxy': 'Foxy Fitzroy',\n    'galactic': 'Galactic Geochelone',\n    'rolling': 'Rolling Ridley',\n}\n\n# These default values will be overridden when building multiversion\nmacros = {\n    'DISTRO': 'rolling',\n    'DISTRO_TITLE': 'Rolling',\n    'DISTRO_TITLE_FULL': 'Rolling Ridley',\n    'REPOS_FILE_BRANCH': 'master',\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_configs(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 various configuration items 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        if app.config.smv_current_version not in ['rolling']:\n            app.config.html_logo = 'source/Releases/' + app.config.smv_current_version + '-small.png'\n\n        # Override default values\n        distro = app.config.smv_current_version\n        app.config.macros = {\n            'DISTRO': distro,\n            'DISTRO_TITLE': distro.title(),\n            'DISTRO_TITLE_FULL': distro_full_names[distro],\n            'REPOS_FILE_BRANCH' : 'master' if distro == 'rolling' else distro,\n        }\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        context['eol_versions'] = app.config.smv_eol_versions\n\ndef expand_macros(app, docname, source):\n    result = source[0]\n    for key, value in app.config.macros.items():\n        result = result.replace(f'{{{key}}}', value)\n    source[0] = result\n\ndef setup(app):\n    app.connect('config-inited', smv_rewrite_configs)\n    app.connect('html-page-context', github_link_rewrite_branch)\n    app.connect('source-read', expand_macros)\n    app.add_config_value('smv_eol_versions', [], 'html')\n    app.add_config_value('macros', {}, True)\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', 'sphinx.ext.ifconfig']\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|galactic|foxy|eloquent|dashing|crystal)$'\n\n\nsmv_released_pattern = r'^refs/(heads|remotes/[^/]+)/(galactic|foxy|eloquent|dashing|crystal).*$'\nsmv_remote_whitelist = r'^(origin)$'\nsmv_latest_version = 'galactic'\nsmv_eol_versions = ['crystal', 'dashing', 'eloquent']\n\ndistro_full_names = {\n    'crystal': 'Crystal Clemmys',\n    'dashing': 'Dashing Diademata',\n    'eloquent': 'Eloquent Elusor',\n    'foxy': 'Foxy Fitzroy',\n    'galactic': 'Galactic Geochelone',\n    'rolling': 'Rolling Ridley',\n}\n\n# These default values will be overridden when building multiversion\nmacros = {\n    'DISTRO': 'rolling',\n    'DISTRO_TITLE': 'Rolling',\n    'DISTRO_TITLE_FULL': 'Rolling Ridley',\n    'REPOS_FILE_BRANCH': 'master',\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_configs(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 various configuration items 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        if app.config.smv_current_version not in ['rolling']:\n            app.config.html_logo = 'source/Releases/' + app.config.smv_current_version + '-small.png'\n\n        # Override default values\n        distro = app.config.smv_current_version\n        app.config.macros = {\n            'DISTRO': distro,\n            'DISTRO_TITLE': distro.title(),\n            'DISTRO_TITLE_FULL': distro_full_names[distro],\n            'REPOS_FILE_BRANCH' : 'master' if distro == 'rolling' else distro,\n        }\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        context['eol_versions'] = app.config.smv_eol_versions\n\ndef expand_macros(app, docname, source):\n    result = source[0]\n    for key, value in app.config.macros.items():\n        result = result.replace(f'{{{key}}}', value)\n    source[0] = result\n\ndef setup(app):\n    app.connect('config-inited', smv_rewrite_configs)\n    app.connect('html-page-context', github_link_rewrite_branch)\n    app.connect('source-read', expand_macros)\n    app.add_config_value('smv_eol_versions', [], 'html')\n    app.add_config_value('macros', {}, True)\n    RedirectFrom.register(app)\n", "path": "conf.py"}]}