We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Read The Docs TOC Footer Not Loading and Throwing Errors
## Details

If this issue is for a specific project or build, include the following: 
- Project: http://gobblin.readthedocs.org/en/readthedocs/
- Build #: latest

When loading the project page, the Chrome Inspect tool throws an error saying: `Failed to load resource: the server responded with a status of 404 (NOT FOUND) https://readthedocs.org//api/v2/footer_html/?callback=jQuery211025191313796…2Fcheckouts%2Freadthedocs%2Fgobblin-docs&source_suffix=.md&_=1456430887845`

and `Error loading Read the Docs footer $.ajax.error @ readthedocs-doc-embed.js:1`

I notice that the Read the Docs tab on the bottom left of the screen (at the bottom of the main TOC) is not loading. I'm guessing these are related, but any idea why this is happening? Is this a bug? Has anyone else seen this issue?

<img width="319" alt="screen shot 2016-02-25 at 12 11 20 pm" src="https://cloud.githubusercontent.com/assets/1282583/13332876/eb7d73ca-dbb8-11e5-9c54-7851873c9871.png">


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `readthedocs/doc_builder/backends/mkdocs.py`
Content:
```
1 import os
2 import logging
3 import json
4 import yaml
5 
6 from django.conf import settings
7 from django.template import Context, loader as template_loader
8 
9 from readthedocs.doc_builder.base import BaseBuilder
10 
11 log = logging.getLogger(__name__)
12 
13 TEMPLATE_DIR = '%s/readthedocs/templates/mkdocs/readthedocs' % settings.SITE_ROOT
14 OVERRIDE_TEMPLATE_DIR = '%s/readthedocs/templates/mkdocs/overrides' % settings.SITE_ROOT
15 
16 
17 class BaseMkdocs(BaseBuilder):
18 
19     """
20     Mkdocs builder
21     """
22     use_theme = True
23 
24     def __init__(self, *args, **kwargs):
25         super(BaseMkdocs, self).__init__(*args, **kwargs)
26         self.old_artifact_path = os.path.join(
27             self.version.project.checkout_path(self.version.slug),
28             self.build_dir)
29         self.root_path = self.version.project.checkout_path(self.version.slug)
30 
31     def append_conf(self, **kwargs):
32         """
33         Set mkdocs config values
34         """
35 
36         # Pull mkdocs config data
37         try:
38             user_config = yaml.safe_load(
39                 open(os.path.join(self.root_path, 'mkdocs.yml'), 'r')
40             )
41         except IOError:
42             user_config = {
43                 'site_name': self.version.project.name,
44             }
45 
46         # Handle custom docs dirs
47 
48         user_docs_dir = user_config.get('docs_dir')
49         if user_docs_dir:
50             user_docs_dir = os.path.join(self.root_path, user_docs_dir)
51         docs_dir = self.docs_dir(docs_dir=user_docs_dir)
52         self.create_index(extension='md')
53         user_config['docs_dir'] = docs_dir
54 
55         # Set mkdocs config values
56 
57         media_url = getattr(settings, 'MEDIA_URL', 'https://media.readthedocs.org')
58 
59         # Mkdocs needs a full domain here because it tries to link to local media files
60         if not media_url.startswith('http'):
61             media_url = 'http://localhost:8000' + media_url
62 
63         if 'extra_javascript' in user_config:
64             user_config['extra_javascript'].append('readthedocs-data.js')
65             user_config['extra_javascript'].append(
66                 'readthedocs-dynamic-include.js')
67             user_config['extra_javascript'].append(
68                 '%sjavascript/readthedocs-doc-embed.js' % media_url)
69         else:
70             user_config['extra_javascript'] = [
71                 'readthedocs-data.js',
72                 'readthedocs-dynamic-include.js',
73                 '%sjavascript/readthedocs-doc-embed.js' % media_url,
74             ]
75 
76         if 'extra_css' in user_config:
77             user_config['extra_css'].append(
78                 '%s/css/badge_only.css' % media_url)
79             user_config['extra_css'].append(
80                 '%s/css/readthedocs-doc-embed.css' % media_url)
81         else:
82             user_config['extra_css'] = [
83                 '%scss/badge_only.css' % media_url,
84                 '%scss/readthedocs-doc-embed.css' % media_url,
85             ]
86 
87         # Set our custom theme dir for mkdocs
88         if 'theme_dir' not in user_config and self.use_theme:
89             user_config['theme_dir'] = TEMPLATE_DIR
90 
91         yaml.dump(
92             user_config,
93             open(os.path.join(self.root_path, 'mkdocs.yml'), 'w')
94         )
95 
96         # RTD javascript writing
97 
98         # Will be available in the JavaScript as READTHEDOCS_DATA.
99         readthedocs_data = {
100             'project': self.version.project.slug,
101             'version': self.version.verbose_name,
102             'language': self.version.project.language,
103             'page': None,
104             'theme': "readthedocs",
105             'builder': "mkdocs",
106             'docroot': docs_dir,
107             'source_suffix': ".md",
108             'api_host': getattr(settings, 'SLUMBER_API_HOST', 'https://readthedocs.org'),
109             'commit': self.version.project.vcs_repo(self.version.slug).commit,
110         }
111         data_json = json.dumps(readthedocs_data, indent=4)
112         data_ctx = {
113             'data_json': data_json,
114             'current_version': readthedocs_data['version'],
115             'slug': readthedocs_data['project'],
116             'html_theme': readthedocs_data['theme'],
117             'pagename': None,
118         }
119         data_string = template_loader.get_template(
120             'doc_builder/data.js.tmpl'
121         ).render(data_ctx)
122 
123         data_file = open(os.path.join(self.root_path, docs_dir, 'readthedocs-data.js'), 'w+')
124         data_file.write(data_string)
125         data_file.write('''
126 READTHEDOCS_DATA["page"] = mkdocs_page_input_path.substr(
127     0, mkdocs_page_input_path.lastIndexOf(READTHEDOCS_DATA.source_suffix));
128 ''')
129         data_file.close()
130 
131         include_ctx = {
132             'global_analytics_code': getattr(settings, 'GLOBAL_ANALYTICS_CODE', 'UA-17997319-1'),
133             'user_analytics_code': self.version.project.analytics_code,
134         }
135         include_string = template_loader.get_template(
136             'doc_builder/include.js.tmpl'
137         ).render(include_ctx)
138         include_file = open(
139             os.path.join(self.root_path, docs_dir, 'readthedocs-dynamic-include.js'),
140             'w+'
141         )
142         include_file.write(include_string)
143         include_file.close()
144 
145     def build(self, **kwargs):
146         checkout_path = self.project.checkout_path(self.version.slug)
147         build_command = [
148             'python',
149             self.python_env.venv_bin(filename='mkdocs'),
150             self.builder,
151             '--clean',
152             '--site-dir', self.build_dir,
153         ]
154         if self.use_theme:
155             build_command.extend(['--theme', 'readthedocs'])
156         cmd_ret = self.run(
157             *build_command,
158             cwd=checkout_path,
159             bin_path=self.python_env.venv_bin()
160         )
161         return cmd_ret.successful
162 
163 
164 class MkdocsHTML(BaseMkdocs):
165     type = 'mkdocs'
166     builder = 'build'
167     build_dir = '_build/html'
168 
169 
170 class MkdocsJSON(BaseMkdocs):
171     type = 'mkdocs_json'
172     builder = 'json'
173     build_dir = '_build/json'
174     use_theme = False
175 
176     def build(self, **kwargs):
177         user_config = yaml.safe_load(
178             open(os.path.join(self.root_path, 'mkdocs.yml'), 'r')
179         )
180         if user_config['theme_dir'] == TEMPLATE_DIR:
181             del user_config['theme_dir']
182         yaml.dump(
183             user_config,
184             open(os.path.join(self.root_path, 'mkdocs.yml'), 'w')
185         )
186         super(MkdocsJSON, self).build(**kwargs)
187
```
--- 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/readthedocs/doc_builder/backends/mkdocs.py b/readthedocs/doc_builder/backends/mkdocs.py
--- a/readthedocs/doc_builder/backends/mkdocs.py
+++ b/readthedocs/doc_builder/backends/mkdocs.py
@@ -98,7 +98,7 @@
         # Will be available in the JavaScript as READTHEDOCS_DATA.
         readthedocs_data = {
             'project': self.version.project.slug,
-            'version': self.version.verbose_name,
+            'version': self.version.slug,
             'language': self.version.project.language,
             'page': None,
             'theme': "readthedocs",

{"golden_diff": "diff --git a/readthedocs/doc_builder/backends/mkdocs.py b/readthedocs/doc_builder/backends/mkdocs.py\n--- a/readthedocs/doc_builder/backends/mkdocs.py\n+++ b/readthedocs/doc_builder/backends/mkdocs.py\n@@ -98,7 +98,7 @@\n         # Will be available in the JavaScript as READTHEDOCS_DATA.\n         readthedocs_data = {\n             'project': self.version.project.slug,\n-            'version': self.version.verbose_name,\n+            'version': self.version.slug,\n             'language': self.version.project.language,\n             'page': None,\n             'theme': \"readthedocs\",\n", "issue": "Read The Docs TOC Footer Not Loading and Throwing Errors\n## Details\n\nIf this issue is for a specific project or build, include the following: \n- Project: http://gobblin.readthedocs.org/en/readthedocs/\n- Build #: latest\n\nWhen loading the project page, the Chrome Inspect tool throws an error saying: `Failed to load resource: the server responded with a status of 404 (NOT FOUND) https://readthedocs.org//api/v2/footer_html/?callback=jQuery211025191313796\u20262Fcheckouts%2Freadthedocs%2Fgobblin-docs&source_suffix=.md&_=1456430887845`\n\nand `Error loading Read the Docs footer $.ajax.error @ readthedocs-doc-embed.js:1`\n\nI notice that the Read the Docs tab on the bottom left of the screen (at the bottom of the main TOC) is not loading. I'm guessing these are related, but any idea why this is happening? Is this a bug? Has anyone else seen this issue?\n\n<img width=\"319\" alt=\"screen shot 2016-02-25 at 12 11 20 pm\" src=\"https://cloud.githubusercontent.com/assets/1282583/13332876/eb7d73ca-dbb8-11e5-9c54-7851873c9871.png\">\n\n", "before_files": [{"content": "import os\nimport logging\nimport json\nimport yaml\n\nfrom django.conf import settings\nfrom django.template import Context, loader as template_loader\n\nfrom readthedocs.doc_builder.base import BaseBuilder\n\nlog = logging.getLogger(__name__)\n\nTEMPLATE_DIR = '%s/readthedocs/templates/mkdocs/readthedocs' % settings.SITE_ROOT\nOVERRIDE_TEMPLATE_DIR = '%s/readthedocs/templates/mkdocs/overrides' % settings.SITE_ROOT\n\n\nclass BaseMkdocs(BaseBuilder):\n\n    \"\"\"\n    Mkdocs builder\n    \"\"\"\n    use_theme = True\n\n    def __init__(self, *args, **kwargs):\n        super(BaseMkdocs, self).__init__(*args, **kwargs)\n        self.old_artifact_path = os.path.join(\n            self.version.project.checkout_path(self.version.slug),\n            self.build_dir)\n        self.root_path = self.version.project.checkout_path(self.version.slug)\n\n    def append_conf(self, **kwargs):\n        \"\"\"\n        Set mkdocs config values\n        \"\"\"\n\n        # Pull mkdocs config data\n        try:\n            user_config = yaml.safe_load(\n                open(os.path.join(self.root_path, 'mkdocs.yml'), 'r')\n            )\n        except IOError:\n            user_config = {\n                'site_name': self.version.project.name,\n            }\n\n        # Handle custom docs dirs\n\n        user_docs_dir = user_config.get('docs_dir')\n        if user_docs_dir:\n            user_docs_dir = os.path.join(self.root_path, user_docs_dir)\n        docs_dir = self.docs_dir(docs_dir=user_docs_dir)\n        self.create_index(extension='md')\n        user_config['docs_dir'] = docs_dir\n\n        # Set mkdocs config values\n\n        media_url = getattr(settings, 'MEDIA_URL', 'https://media.readthedocs.org')\n\n        # Mkdocs needs a full domain here because it tries to link to local media files\n        if not media_url.startswith('http'):\n            media_url = 'http://localhost:8000' + media_url\n\n        if 'extra_javascript' in user_config:\n            user_config['extra_javascript'].append('readthedocs-data.js')\n            user_config['extra_javascript'].append(\n                'readthedocs-dynamic-include.js')\n            user_config['extra_javascript'].append(\n                '%sjavascript/readthedocs-doc-embed.js' % media_url)\n        else:\n            user_config['extra_javascript'] = [\n                'readthedocs-data.js',\n                'readthedocs-dynamic-include.js',\n                '%sjavascript/readthedocs-doc-embed.js' % media_url,\n            ]\n\n        if 'extra_css' in user_config:\n            user_config['extra_css'].append(\n                '%s/css/badge_only.css' % media_url)\n            user_config['extra_css'].append(\n                '%s/css/readthedocs-doc-embed.css' % media_url)\n        else:\n            user_config['extra_css'] = [\n                '%scss/badge_only.css' % media_url,\n                '%scss/readthedocs-doc-embed.css' % media_url,\n            ]\n\n        # Set our custom theme dir for mkdocs\n        if 'theme_dir' not in user_config and self.use_theme:\n            user_config['theme_dir'] = TEMPLATE_DIR\n\n        yaml.dump(\n            user_config,\n            open(os.path.join(self.root_path, 'mkdocs.yml'), 'w')\n        )\n\n        # RTD javascript writing\n\n        # Will be available in the JavaScript as READTHEDOCS_DATA.\n        readthedocs_data = {\n            'project': self.version.project.slug,\n            'version': self.version.verbose_name,\n            'language': self.version.project.language,\n            'page': None,\n            'theme': \"readthedocs\",\n            'builder': \"mkdocs\",\n            'docroot': docs_dir,\n            'source_suffix': \".md\",\n            'api_host': getattr(settings, 'SLUMBER_API_HOST', 'https://readthedocs.org'),\n            'commit': self.version.project.vcs_repo(self.version.slug).commit,\n        }\n        data_json = json.dumps(readthedocs_data, indent=4)\n        data_ctx = {\n            'data_json': data_json,\n            'current_version': readthedocs_data['version'],\n            'slug': readthedocs_data['project'],\n            'html_theme': readthedocs_data['theme'],\n            'pagename': None,\n        }\n        data_string = template_loader.get_template(\n            'doc_builder/data.js.tmpl'\n        ).render(data_ctx)\n\n        data_file = open(os.path.join(self.root_path, docs_dir, 'readthedocs-data.js'), 'w+')\n        data_file.write(data_string)\n        data_file.write('''\nREADTHEDOCS_DATA[\"page\"] = mkdocs_page_input_path.substr(\n    0, mkdocs_page_input_path.lastIndexOf(READTHEDOCS_DATA.source_suffix));\n''')\n        data_file.close()\n\n        include_ctx = {\n            'global_analytics_code': getattr(settings, 'GLOBAL_ANALYTICS_CODE', 'UA-17997319-1'),\n            'user_analytics_code': self.version.project.analytics_code,\n        }\n        include_string = template_loader.get_template(\n            'doc_builder/include.js.tmpl'\n        ).render(include_ctx)\n        include_file = open(\n            os.path.join(self.root_path, docs_dir, 'readthedocs-dynamic-include.js'),\n            'w+'\n        )\n        include_file.write(include_string)\n        include_file.close()\n\n    def build(self, **kwargs):\n        checkout_path = self.project.checkout_path(self.version.slug)\n        build_command = [\n            'python',\n            self.python_env.venv_bin(filename='mkdocs'),\n            self.builder,\n            '--clean',\n            '--site-dir', self.build_dir,\n        ]\n        if self.use_theme:\n            build_command.extend(['--theme', 'readthedocs'])\n        cmd_ret = self.run(\n            *build_command,\n            cwd=checkout_path,\n            bin_path=self.python_env.venv_bin()\n        )\n        return cmd_ret.successful\n\n\nclass MkdocsHTML(BaseMkdocs):\n    type = 'mkdocs'\n    builder = 'build'\n    build_dir = '_build/html'\n\n\nclass MkdocsJSON(BaseMkdocs):\n    type = 'mkdocs_json'\n    builder = 'json'\n    build_dir = '_build/json'\n    use_theme = False\n\n    def build(self, **kwargs):\n        user_config = yaml.safe_load(\n            open(os.path.join(self.root_path, 'mkdocs.yml'), 'r')\n        )\n        if user_config['theme_dir'] == TEMPLATE_DIR:\n            del user_config['theme_dir']\n        yaml.dump(\n            user_config,\n            open(os.path.join(self.root_path, 'mkdocs.yml'), 'w')\n        )\n        super(MkdocsJSON, self).build(**kwargs)\n", "path": "readthedocs/doc_builder/backends/mkdocs.py"}], "after_files": [{"content": "import os\nimport logging\nimport json\nimport yaml\n\nfrom django.conf import settings\nfrom django.template import Context, loader as template_loader\n\nfrom readthedocs.doc_builder.base import BaseBuilder\n\nlog = logging.getLogger(__name__)\n\nTEMPLATE_DIR = '%s/readthedocs/templates/mkdocs/readthedocs' % settings.SITE_ROOT\nOVERRIDE_TEMPLATE_DIR = '%s/readthedocs/templates/mkdocs/overrides' % settings.SITE_ROOT\n\n\nclass BaseMkdocs(BaseBuilder):\n\n    \"\"\"\n    Mkdocs builder\n    \"\"\"\n    use_theme = True\n\n    def __init__(self, *args, **kwargs):\n        super(BaseMkdocs, self).__init__(*args, **kwargs)\n        self.old_artifact_path = os.path.join(\n            self.version.project.checkout_path(self.version.slug),\n            self.build_dir)\n        self.root_path = self.version.project.checkout_path(self.version.slug)\n\n    def append_conf(self, **kwargs):\n        \"\"\"\n        Set mkdocs config values\n        \"\"\"\n\n        # Pull mkdocs config data\n        try:\n            user_config = yaml.safe_load(\n                open(os.path.join(self.root_path, 'mkdocs.yml'), 'r')\n            )\n        except IOError:\n            user_config = {\n                'site_name': self.version.project.name,\n            }\n\n        # Handle custom docs dirs\n\n        user_docs_dir = user_config.get('docs_dir')\n        if user_docs_dir:\n            user_docs_dir = os.path.join(self.root_path, user_docs_dir)\n        docs_dir = self.docs_dir(docs_dir=user_docs_dir)\n        self.create_index(extension='md')\n        user_config['docs_dir'] = docs_dir\n\n        # Set mkdocs config values\n\n        media_url = getattr(settings, 'MEDIA_URL', 'https://media.readthedocs.org')\n\n        # Mkdocs needs a full domain here because it tries to link to local media files\n        if not media_url.startswith('http'):\n            media_url = 'http://localhost:8000' + media_url\n\n        if 'extra_javascript' in user_config:\n            user_config['extra_javascript'].append('readthedocs-data.js')\n            user_config['extra_javascript'].append(\n                'readthedocs-dynamic-include.js')\n            user_config['extra_javascript'].append(\n                '%sjavascript/readthedocs-doc-embed.js' % media_url)\n        else:\n            user_config['extra_javascript'] = [\n                'readthedocs-data.js',\n                'readthedocs-dynamic-include.js',\n                '%sjavascript/readthedocs-doc-embed.js' % media_url,\n            ]\n\n        if 'extra_css' in user_config:\n            user_config['extra_css'].append(\n                '%s/css/badge_only.css' % media_url)\n            user_config['extra_css'].append(\n                '%s/css/readthedocs-doc-embed.css' % media_url)\n        else:\n            user_config['extra_css'] = [\n                '%scss/badge_only.css' % media_url,\n                '%scss/readthedocs-doc-embed.css' % media_url,\n            ]\n\n        # Set our custom theme dir for mkdocs\n        if 'theme_dir' not in user_config and self.use_theme:\n            user_config['theme_dir'] = TEMPLATE_DIR\n\n        yaml.dump(\n            user_config,\n            open(os.path.join(self.root_path, 'mkdocs.yml'), 'w')\n        )\n\n        # RTD javascript writing\n\n        # Will be available in the JavaScript as READTHEDOCS_DATA.\n        readthedocs_data = {\n            'project': self.version.project.slug,\n            'version': self.version.slug,\n            'language': self.version.project.language,\n            'page': None,\n            'theme': \"readthedocs\",\n            'builder': \"mkdocs\",\n            'docroot': docs_dir,\n            'source_suffix': \".md\",\n            'api_host': getattr(settings, 'SLUMBER_API_HOST', 'https://readthedocs.org'),\n            'commit': self.version.project.vcs_repo(self.version.slug).commit,\n        }\n        data_json = json.dumps(readthedocs_data, indent=4)\n        data_ctx = {\n            'data_json': data_json,\n            'current_version': readthedocs_data['version'],\n            'slug': readthedocs_data['project'],\n            'html_theme': readthedocs_data['theme'],\n            'pagename': None,\n        }\n        data_string = template_loader.get_template(\n            'doc_builder/data.js.tmpl'\n        ).render(data_ctx)\n\n        data_file = open(os.path.join(self.root_path, docs_dir, 'readthedocs-data.js'), 'w+')\n        data_file.write(data_string)\n        data_file.write('''\nREADTHEDOCS_DATA[\"page\"] = mkdocs_page_input_path.substr(\n    0, mkdocs_page_input_path.lastIndexOf(READTHEDOCS_DATA.source_suffix));\n''')\n        data_file.close()\n\n        include_ctx = {\n            'global_analytics_code': getattr(settings, 'GLOBAL_ANALYTICS_CODE', 'UA-17997319-1'),\n            'user_analytics_code': self.version.project.analytics_code,\n        }\n        include_string = template_loader.get_template(\n            'doc_builder/include.js.tmpl'\n        ).render(include_ctx)\n        include_file = open(\n            os.path.join(self.root_path, docs_dir, 'readthedocs-dynamic-include.js'),\n            'w+'\n        )\n        include_file.write(include_string)\n        include_file.close()\n\n    def build(self, **kwargs):\n        checkout_path = self.project.checkout_path(self.version.slug)\n        build_command = [\n            'python',\n            self.python_env.venv_bin(filename='mkdocs'),\n            self.builder,\n            '--clean',\n            '--site-dir', self.build_dir,\n        ]\n        if self.use_theme:\n            build_command.extend(['--theme', 'readthedocs'])\n        cmd_ret = self.run(\n            *build_command,\n            cwd=checkout_path,\n            bin_path=self.python_env.venv_bin()\n        )\n        return cmd_ret.successful\n\n\nclass MkdocsHTML(BaseMkdocs):\n    type = 'mkdocs'\n    builder = 'build'\n    build_dir = '_build/html'\n\n\nclass MkdocsJSON(BaseMkdocs):\n    type = 'mkdocs_json'\n    builder = 'json'\n    build_dir = '_build/json'\n    use_theme = False\n\n    def build(self, **kwargs):\n        user_config = yaml.safe_load(\n            open(os.path.join(self.root_path, 'mkdocs.yml'), 'r')\n        )\n        if user_config['theme_dir'] == TEMPLATE_DIR:\n            del user_config['theme_dir']\n        yaml.dump(\n            user_config,\n            open(os.path.join(self.root_path, 'mkdocs.yml'), 'w')\n        )\n        super(MkdocsJSON, self).build(**kwargs)\n", "path": "readthedocs/doc_builder/backends/mkdocs.py"}]}