Repository: readthedocs/readthedocs.org

Issue:
Documentation version selection broken with Mkdocs
If we switch versions from the options to release-3.7.0-1 on http://gluster.readthedocs.org/en/latest/
the resultant URL gets appended with "None" as in http://gluster.readthedocs.org/en/release-3.7.0-1/None/

also from any page, we cannot view the different versions of the documents, what I observed is the URL fired is mis matching the directory.

![image](https://cloud.githubusercontent.com/assets/10970993/8822127/d4c729ac-3080-11e5-9b3c-bbd2d1c36148.png)



Discussion:
For some reason it is adding a None to the end of the url. I am not sure why. I guess there is an issue getting the current path?

Yeah, so this line isn't working for some reason: https://github.com/mkdocs/mkdocs/blob/master/mkdocs/themes/readthedocs/base.html#L29

and actually, page title isn't the right thing to put there. We should be putting the URL. You can see it being used incorrectly when you change the version here: http://gluster.readthedocs.org/en/latest/Quick-Start-Guide/Terminologies/

I'm getting the same behavior on this site: http://vic.readthedocs.org/en/master/.

All the links under `Versions` and `On GitHub` send you to a url with the word "None" at the end.

@d0ugal I tried using https://github.com/mkdocs/mkdocs/commit/74031a084d776f45ad43568e334da2b89133986b of mkdocs, but it still appended `None` on the version select links. Is there anything that we need to adjust on the RTD end? 

@gregmuellegger Yeah, I think so. I just made the data available, I don't really know how it works on your end, but it looked like you were using the Title incorrectly as the URL so I added that.

I was planning to come and figure it out, but hadn't found the time yet :)

I tried to install the mkdocs master in the venv that is used for the rtd build, but the change didn't pick up. The base.html in the filesystem contains the change ... but the build doesn't seem to use it.

@d0ugal could there be any other path in RTD that is loading the mkdocs theme templates from except from the mkdocs package in the venv?

@d0ugal and @gregmuellegger - 

Can either of you give us an update on where this issue is at? We have live docs on RTD that are not working because of this bug.  If there is something I can do to help move this forward, let me know.  


Resolving patch:
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
@@ -122,7 +122,10 @@ def append_conf(self, **kwargs):
 
         data_file = open(os.path.join(self.root_path, docs_dir, 'readthedocs-data.js'), 'w+')
         data_file.write(data_string)
-        data_file.write('\nREADTHEDOCS_DATA["page"] = mkdocs_page_name')
+        data_file.write('''
+READTHEDOCS_DATA["page"] = mkdocs_page_input_path.substr(
+    0, mkdocs_page_input_path.lastIndexOf(READTHEDOCS_DATA.source_suffix));
+''')
         data_file.close()
 
         include_ctx = {
diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py
--- a/readthedocs/doc_builder/python_environments.py
+++ b/readthedocs/doc_builder/python_environments.py
@@ -101,7 +101,7 @@ def install_core_requirements(self):
             'Pygments==2.0.2',
             'setuptools==18.6.1',
             'docutils==0.12',
-            'mkdocs==0.14.0',
+            'mkdocs==0.15.0',
             'mock==1.0.1',
             'pillow==2.6.1',
             'readthedocs-sphinx-ext==0.5.4',
@@ -210,7 +210,7 @@ def install_core_requirements(self):
 
         # Install pip-only things.
         pip_requirements = [
-            'mkdocs==0.14.0',
+            'mkdocs==0.15.0',
             'readthedocs-sphinx-ext==0.5.4',
             'commonmark==0.5.4',
             'recommonmark==0.1.1',


Test patch: