internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: readthedocs/readthedocs.org

Issue:
Mkdocs version 0.11.1 has trailing slash bug with causes problems
On a local installation of RTD, latest master, using mkdocs, it looks like files are attempting to be served up with invalid path names:

`GET domain.com/docs/project-name/en/latest/queue-work-item`

Attempts to serve:

`[21/Apr/2015 09:18:13] INFO [core.views:470] Serving queue-work-itemindex.html for Project Name`

Notice, the name of the document and `index.html` are mangled without a path separator.

I believe the issue stems from `core/views.py` near line 457:

``` python
...
            and "font" not in filename
            and not "inv" in filename):
        filename += "index.html"
...

```

in this case, `filename` is `queue-work-item` so appending `index.html` results in a mangled path.



Discussion:
Actually, upon further inspection, it looks like the `filename` parameter, when referencing a folder, is not being passed correctly. One of the sections is being passed in `filename = communications/` however, the `queue-work-item` section is being passed in without a trailing `/`. 

This might be a mkdocs issue as the HTML files are sometimes without a trailing slash which is causing the problem. 

This is a bug with 0.11.1 mkdocs. Updating to 0.12.1 fixes the problem. PR will follow. I've re-titled the bug to correctly reflect the issue.


Resolving patch:
diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py
--- a/readthedocs/projects/tasks.py
+++ b/readthedocs/projects/tasks.py
@@ -331,7 +331,7 @@ def setup_environment(version):
     ret_dict['doc_builder'] = run(
         (
             '{cmd} install --use-wheel --find-links={wheeldir} -U {ignore_option} '
-            'sphinx==1.2.2 virtualenv==1.10.1 setuptools==1.1 docutils==0.11 mkdocs==0.11.1 mock==1.0.1 pillow==2.6.1'
+            'sphinx==1.2.2 virtualenv==1.10.1 setuptools==1.1 docutils==0.11 mkdocs==0.12.1 mock==1.0.1 pillow==2.6.1'
             ' readthedocs-sphinx-ext==0.4.4 sphinx-rtd-theme==0.1.6 '
         ).format(
             cmd=project.venv_bin(version=version.slug, bin='pip'),


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Use django-copyright to avoid outdated copyright notice like Copyright 2010-2013. 
[django-copyright](https://github.com/arteria/django-copyright/)
![screen shot 2014-12-08 at 23 52 36](https://cloud.githubusercontent.com/assets/113043/5349006/828c93cc-7f35-11e4-89b0-c65c9d6a1772.png)



Discussion:
Happily accept a PR adding this. Not a big priority now though :)


Resolving patch:
diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py
--- a/readthedocs/settings/base.py
+++ b/readthedocs/settings/base.py
@@ -177,7 +177,8 @@
     'django_gravatar',
     'rest_framework',
     'corsheaders',
-
+    'copyright',
+    
     # Celery bits
     'djcelery',
 
@@ -282,6 +283,8 @@
 
 GRAVATAR_DEFAULT_IMAGE = 'http://media.readthedocs.org/images/silhouette.png'
 
+COPY_START_YEAR = 2010
+
 LOG_FORMAT = "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s"
 
 RESTRUCTUREDTEXT_FILTER_SETTINGS = {


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Mkdocs missing config argument causes ValidationError
 I use RTFD service and faced this error in build process>>  mkdocs.config.base.ValidationError: The 'site_dir' can't be within the 'docs_dir'.

 I made indentation changes to a file after the previous passed build, but yet got the above error.



Discussion:
@shravantc Can you show me your config?

Basically, it sounds like you have something like this:

```
site_dir: docs/site
docs_dir: docs
```

If you do, it will get messy over time. You shouldn't put the site directory within the docs directory (or the other way around).

The documentation is hosted in the readthedocs online service and not a local deployment.
This  is the project : gluster.readthedocs.org

This is an error straight from mkdocs, it doesn't seem to be an issue with RTD -- closing this here.

This is actually an issue related to the ReadTheDocs integration. The issue is that `docs_dir` can [default to `.` ](https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/doc_builder/base.py#L85) and then the `site_dir` would be `site` and thus relative and within the docs dir. This is an issue because subsequent builds would copy the site dir into itself over and over with each build (MkDocs will copy everything in the docs dir as they are deemed to be static assets). As ReadTheDocs probably does this with a clean env it may not be a problem but in version 0.13, MkDocs stopped users doing this due to the problems people kept seeing.

The quick fix would be to move the `site_dir` outside the project directory here: https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/doc_builder/backends/mkdocs.py#L136

I'm not sure if that will cause problems however.

Okay, that makes sense. So given the configuration file of:
https://github.com/gluster/glusterdocs/blob/master/mkdocs.yml

the immediate fix would be to add an explicit `docs_dir`?

Is there any reason we need to be setting it in the first place?

I'm going to roll a quick MkDocs release to change this to a warning.

A docs_dir would be a fix, but in this case the Markdown is in the root of the repo. So the files would also need to be moved. Not ideal. I hadn't considered this use case which is common with RTD. Bug release coming in a few minutes.

[Fix in MkDocs](https://github.com/mkdocs/mkdocs/pull/581). Once it passes CI I'll merge and release 0.13.3.


Resolving patch:
diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py
--- a/readthedocs/projects/tasks.py
+++ b/readthedocs/projects/tasks.py
@@ -336,7 +336,7 @@ def setup_environment(version):
         'virtualenv==1.10.1',
         'setuptools==1.1',
         'docutils==0.11',
-        'mkdocs==0.13.2',
+        'mkdocs==0.13.3',
         'mock==1.0.1',
         'pillow==2.6.1',
         'readthedocs-sphinx-ext==0.4.4',


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Contents are not updated when using mkdocs (md)
# Steps to reproduce:

Visit http://coala.readthedocs.org/en/latest/
Compare the content listing with http://coala.readthedocs.org/en/latest/Getting_Involved/MAC_Hints/
# Actual results:

On the initial landing page the third navigation entry from the bottom is "Writing Commit Messages". On all other pages it is "Writing Good Commits". (Writing commit messages was the old page that doesn't exist anymore in the repository.)
# Expected results:

The entry should be "Writing Good Commits" in all cases.



Discussion:
Odd. Can you see any errors for the build on https://readthedocs.org/?

This is our latest build: https://readthedocs.org/builds/coala/2870604/

I do get some errors because readthedocs tries to install my python project with python 2 but none related to documentation creation. (I tried to turn that off without success.)

If you can't access that build info, here's the output: http://pastebin.com/SRUrysrv

oh this part might be the interesting one:

```
html
-----

Building documentation to directory: _build/html
Directory _build/html contains stale files. Use --clean to remove them.
```

@sils1297 Yeah, quite possibly.

@d0ugal let me know if you need anything else.

ReadTheDocs probably needs to be updated to pass in `--clean`. I am working on updating ReadTheDocs to use the new release of MkDocs, so if it isn't done before I get there I'll add that.

Do we just need to add --clean to our call?

Possibly yes, I wasn't sure how to try and reproduce this.

it certainly won't do any harm.


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
@@ -130,7 +130,7 @@ def build(self, **kwargs):
         #site_path = os.path.join(checkout_path, 'site')
         os.chdir(checkout_path)
         # Actual build
-        build_command = "{command} {builder} --site-dir={build_dir} --theme=readthedocs".format(
+        build_command = "{command} {builder} --clean --site-dir={build_dir} --theme=readthedocs".format(
             command=self.version.project.venv_bin(version=self.version.slug, bin='mkdocs'),
             builder=self.builder,
             build_dir=self.build_dir,


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
jinja2 exception - unexpected '}'
We didn't change anything in the documentation nor the mkdocs config file but the documentation is not built anymore. Here is the link to a failed build:

https://readthedocs.org/builds/mongooseim/3000853/

and the repo is cloned from here:

https://github.com/esl/MongooseIM



Discussion:
This is an issue that was resolved in MkDocs 0.14, I need to update ReadTheDocs.

You can work around it by adding this to your config. Basically, it is trying to discover extra templates in your documentation if we set the setting as blank it wont do that.

```
extra_templates:
```

0.14 turned this off by default, as although it was useful having it enabled caused some issues.

Thanks for the advice. This worked for me:

```
extra_templates: []
```


Resolving patch:
diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py
--- a/readthedocs/projects/tasks.py
+++ b/readthedocs/projects/tasks.py
@@ -334,7 +334,7 @@ def setup_environment(version):
         'virtualenv==1.10.1',
         'setuptools==1.1',
         'docutils==0.11',
-        'mkdocs==0.13.3',
+        'mkdocs==0.14.0',
         'mock==1.0.1',
         'pillow==2.6.1',
         'readthedocs-sphinx-ext==0.5.4',


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Pip install failing to install sphinx when PYTHON_HOME is set
If the env variable PYTHON_HOME exists, pip install is failing to install spinx into the virtualenv.



Discussion:

Resolving patch:
diff --git a/readthedocs/projects/utils.py b/readthedocs/projects/utils.py
--- a/readthedocs/projects/utils.py
+++ b/readthedocs/projects/utils.py
@@ -69,6 +69,10 @@ def run(*commands, **kwargs):
         del environment['DJANGO_SETTINGS_MODULE']
     if 'PYTHONPATH' in environment:
         del environment['PYTHONPATH']
+    # Remove PYTHONHOME env variable if set, otherwise pip install of requirements
+    # into virtualenv will install incorrectly
+    if 'PYTHONHOME' in environment:
+        del environment['PYTHONHOME']
     cwd = os.getcwd()
     if not commands:
         raise ValueError("run() requires one or more command-line strings")


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
setuptools being downgraded
This is a follow-on to #1426. With the newer virtualenv the requirements.txt processing does manage to complete, but the install target fails due to very old setuptools (1.1!) - the doc_builder target appears to be downgrading it to 1.1 in the middle. :(.

```
doc_builder
-----

Collecting sphinx==1.3.1
...
Collecting virtualenv==1.10.1
Collecting setuptools==1.1
...
  Found existing installation: setuptools 18.0.1
    Uninstalling setuptools-18.0.1:
      Successfully uninstalled setuptools-18.0.1
Successfully installed Jinja2-2.7.3 Markdown-2.6.2 PyYAML-3.11 Pygments-2.0.2 alabaster-0.7.6 babel-1.3 backports.ssl-match-hostname-3.4.0.2 certifi-2015.4.28 click-4.0 commonmark-0.5.4 docutils-0.11 livereload-2.4.0 markupsafe-0.23 mkdocs-0.14.0 mock-1.0.1 nilsimsa-0.3.7 pillow-2.6.1 pytz-2015.4 readthedocs-sphinx-ext-0.5.4 recommonmark-0.1.1 requests-2.7.0 setuptools-1.1 six-1.9.0 snowballstemmer-1.2.0 sphinx-1.3.1 sphinx-rtd-theme-0.1.8 tornado-4.2 virtualenv-1.10.1
```

This is from https://readthedocs.org/builds/mock/3074098/



Discussion:
And https://github.com/rtfd/readthedocs.org/blob/b4c6c7bcd750bd0751c7a151b485b22df932a435/readthedocs/projects/tasks.py#L335 seems to be the culprit. I don't know why setuptools 1.1 is being pinned - but its really rather old. In fact - https://github.com/rtfd/readthedocs.org/commit/d5d71c0d1e326a38ab607d2e688982e439b3c35e is where it was introduced.

Would a PR to bump that to 18 be acceptable?


Resolving patch:
diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py
--- a/readthedocs/projects/tasks.py
+++ b/readthedocs/projects/tasks.py
@@ -331,8 +331,8 @@ def setup_environment(version):
     requirements = ' '.join([
         'sphinx==1.3.1',
         'Pygments==2.0.2',
-        'virtualenv==1.10.1',
-        'setuptools==1.1',
+        'virtualenv==13.1.0',
+        'setuptools==18.0.1',
         'docutils==0.11',
         'mkdocs==0.14.0',
         'mock==1.0.1',


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Social Network Login Failure
When clicking on connect GitHub on the [social accounts page](https://readthedocs.org/accounts/social/connections/?) I get a message:

> An error occurred while attempting to login via your social network account.

There's a `?` in the url. Could that be a hint? Is it missing some request arguments? If I omit it, the bug persists.

Cheers!



Discussion:
I am having the same issue.

I do have 2 Factor Authentication enabled on GH, so maybe it's the response from that?

It's not that. I disabled 2 Factor Authentication and just tried again and it still failed.

As a workaround, I managed to manually import a GitHub repository by entering the repo url and adding Read The Docs as a service to notify of new commits in the repo's settings on GitHub. Explained [here](https://read-the-docs.readthedocs.org/en/latest/webhooks.html).

This is the Error in the URL:

```
The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application
```

If I attempt to link to github from `https://www.readthedocs.org` the redirect with the error sends me back to `https://readthedocs.org`

From the OAuth Flow it looks like:

```
&redirect_uri=http%3A%2F%2Freadthedocs.org%2Faccounts%2Fgithub%2Flogin%2Fcallback%2F
```

sans www is indeed the redirect_uri so the next question is, how is the app registered on github?

The plot thickens!

So using Charles, I got the GH Auth URL and indeed, the redirect_uri is the issue. It's set to `http://` which fails, but if I get a clean auth url and set the redirect_uri to be `https://` I get the GH auth screen for the RTD app. Now when I get redirected, I still get an error, but 1 problem at a time.  So I assume some ENV var for the app is probably set `http` and it should be set to `https`

More info.. It looks like it has to do with how `allauth`  is doing it's job:

https://github.com/pennersr/django-allauth/blob/8efc7e5ebb3326d467248de3350853407e3fc73b/allauth/account/app_settings.py#L42-L44

``` python
@property
    def DEFAULT_HTTP_PROTOCOL(self):
        return self._setting("DEFAULT_HTTP_PROTOCOL", "http")
```

where `self._setting` is:

``` python
def _setting(self, name, dflt):
        from django.conf import settings
        getter = getattr(settings,
                         'ALLAUTH_SETTING_GETTER',
                         lambda name, dflt: getattr(settings, name, dflt))
        return getter(self.prefix + name, dflt)
```

So my guess now is all the production app at `https://readthedocs.org` has to do to fix this issue is to set `DEFAULT_HTTP_PROTOCOL` in the django app's settings.


Resolving patch:
diff --git a/readthedocs/settings/postgres.py b/readthedocs/settings/postgres.py
--- a/readthedocs/settings/postgres.py
+++ b/readthedocs/settings/postgres.py
@@ -69,6 +69,9 @@
     'github': {'SCOPE': ['user:email', 'read:org', 'admin:repo_hook', 'repo:status']}
 }
 
+# allauth settings
+ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
+
 if not os.environ.get('DJANGO_SETTINGS_SKIP_LOCAL', False):
     try:
         from local_settings import *  # noqa


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Add import error handling
By registering an import hook we can trick projects whose modules are not able to be build and installed on the server that they exist. See http://www.python.org/dev/peps/pep-0302/



Discussion:
Here's a spike for the object we could import if the required one is missing, https://gist.github.com/1039121

I wonder if it would be easier if we just did this for known... rabbitholes to install like mysql - not for everything.

Its certainly a good idea to start with that as a known use case, but we're going to need to either register those import hooks or override `__import__`.

For what is worth, what I added to sphinx's conf.py file with my project to mock the modules that were causing problems is as follows:
https://gist.github.com/1167446

Note: I had to mock argparse also since readthedocs seems to use python2.6 at the moment.

@jcollado this works for me.  I'll try it with my original issue, and if it works there, I'll try to document it and then hopefully we can close it.

for posterity: http://docs.python.org/library/sys.html#sys.meta_path

bam!

Looks like this is harder than it appears, so I think documenting it in the FAQ is probably the right solution to this for now.


Resolving patch:
diff --git a/readthedocs/core/hacks.py b/readthedocs/core/hacks.py
deleted file mode 100644
--- a/readthedocs/core/hacks.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import imp
-import sys
-
-
-class ErrorlessImport(object):
-    def find_module(self, name, path):
-        try:
-            return imp.find_module(name, path)
-        except ImportError:
-            # raise
-            return FreeLoader()
-
-
-class Mock(object):
-    def __repr__(self):
-        return "<Silly Human, I'm not real>"
-
-    def __eq__(self, b):
-        return True
-
-    def __getattr__(self, *args, **kwargs):
-        return Mock()
-
-    def __call__(self, *args, **kwargs):
-        return Mock()
-
-
-class FreeLoader(object):
-    def load_module(self, fullname):
-        return Mock()
-
-
-def patch_meta_path():
-    FreeLoader._class = ErrorlessImport()
-    sys.meta_path += [FreeLoader._class]
-
-
-def unpatch_meta_path():
-    sys.meta_path.remove(FreeLoader._class)
-    # sys.meta_path = []


Test patch:
diff --git a/readthedocs/rtd_tests/tests/test_hacks.py b/readthedocs/rtd_tests/tests/test_hacks.py
deleted file mode 100644
--- a/readthedocs/rtd_tests/tests/test_hacks.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from django.test import TestCase
-from readthedocs.core import hacks
-
-
-class TestHacks(TestCase):
-    fixtures = ['eric.json', 'test_data.json']
-
-    def setUp(self):
-        hacks.patch_meta_path()
-
-    def tearDown(self):
-        hacks.unpatch_meta_path()
-
-    def test_hack_failed_import(self):
-        import boogy
-        self.assertTrue(str(boogy), "<Silly Human, I'm not real>")
-
-    #def test_hack_correct_import(self):
-        #import itertools
-        #self.assertFalse(str(itertools), "<Silly Human, I'm not real>")
Repository: readthedocs/readthedocs.org

Issue:
wrong link for "Edit on GitHub" of README.rst (if index.rst does not exist)
Currently, `doc_builder/base.py` will rename `README.rst` to `index.rst` if repo does not have `index.rst`. And this make the generated index.html finding `index.rst` as source. Then, it cause 404 when user click "Edit on GitHub". (repo only have `README.rst`)



Discussion:
Example: http://python-best-practices.readthedocs.org/en/latest/

I believe our servers will now serve README.html as an index file, so we can probably stop transforming the files and be good. 

@ericholscher I tried this in #1585, but it seems to be more complicated. See there for comments.


Resolving patch:
diff --git a/readthedocs/doc_builder/backends/sphinx.py b/readthedocs/doc_builder/backends/sphinx.py
--- a/readthedocs/doc_builder/backends/sphinx.py
+++ b/readthedocs/doc_builder/backends/sphinx.py
@@ -43,7 +43,7 @@ def __init__(self, *args, **kwargs):
             docs_dir = self.docs_dir()
             self.old_artifact_path = os.path.join(docs_dir, self.sphinx_build_dir)
 
-    def _write_config(self):
+    def _write_config(self, master_doc='index'):
         """
         Create ``conf.py`` if it doesn't exist.
         """
@@ -52,6 +52,7 @@ def _write_config(self):
                                          {'project': self.project,
                                           'version': self.version,
                                           'template_dir': TEMPLATE_DIR,
+                                          'master_doc': master_doc,
                                           })
         conf_file = os.path.join(docs_dir, 'conf.py')
         safe_write(conf_file, conf_template)
@@ -64,8 +65,8 @@ def append_conf(self, **kwargs):
         try:
             conf_py_path = self.version.get_conf_py_path()
         except ProjectImportError:
-            self._write_config()
-            self.create_index(extension='rst')
+            master_doc = self.create_index(extension='rst')
+            self._write_config(master_doc=master_doc)
 
         project = self.project
         # Open file for appending.
diff --git a/readthedocs/doc_builder/base.py b/readthedocs/doc_builder/base.py
--- a/readthedocs/doc_builder/base.py
+++ b/readthedocs/doc_builder/base.py
@@ -98,8 +98,7 @@ def create_index(self, extension='md', **kwargs):
         if not os.path.exists(index_filename):
             readme_filename = os.path.join(docs_dir, 'README.{ext}'.format(ext=extension))
             if os.path.exists(readme_filename):
-                os.system('mv {readme} {index}'.format(index=index_filename,
-                                                       readme=readme_filename))
+                return 'README'
             else:
                 index_file = open(index_filename, 'w+')
                 index_text = """
@@ -116,6 +115,7 @@ def create_index(self, extension='md', **kwargs):
 
                 index_file.write(index_text.format(dir=docs_dir, ext=extension))
                 index_file.close()
+        return 'index'
 
     def run(self, *args, **kwargs):
         '''Proxy run to build environment'''


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Uninformative error when branch name contains a dot
We were just experimenting with some docs stuff, and @minrk created a branch name with a dot (`.`) in it. Builds on this branch all failed, and the only error message in the logs was "top level build failure". It took us a while to work out that the branch name was the problem.

I don't think it's especially important to allow branch names with dots, but it would be nice to at least get an error that pointed us to the branch name.



Discussion:
Agreed, this could be an edge case bug that wasn't covered with some changes to branch name slugging.

Hm, I tried locally with the pypy project and built their `release-2.6.x` branch which worked.
@takluyver could you provide us with the branch you have problems with?

I think it was a docs project @minrk had set up with his fork of the ipython/ipython GH repo to experiment. He might have more details.

The branch name was 'conf.py-hacks' Pushing the same commit to a new branch 'target' resulted in a successful build.


Resolving patch:
diff --git a/readthedocs/builds/models.py b/readthedocs/builds/models.py
--- a/readthedocs/builds/models.py
+++ b/readthedocs/builds/models.py
@@ -184,10 +184,10 @@ def get_downloads(self, pretty=False):
         return data
 
     def get_conf_py_path(self):
-        conf_py_path = self.project.conf_file(self.slug)
-        conf_py_path = conf_py_path.replace(
-            self.project.checkout_path(self.slug), '')
-        return conf_py_path.replace('conf.py', '')
+        conf_py_path = self.project.conf_dir(self.slug)
+        checkout_prefix = self.project.checkout_path(self.slug)
+        conf_py_path = os.path.relpath(conf_py_path, checkout_prefix)
+        return conf_py_path
 
     def get_build_path(self):
         '''Return version build path if path exists, otherwise `None`'''
diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py
--- a/readthedocs/projects/models.py
+++ b/readthedocs/projects/models.py
@@ -597,7 +597,7 @@ def conf_file(self, version=LATEST):
     def conf_dir(self, version=LATEST):
         conf_file = self.conf_file(version)
         if conf_file:
-            return conf_file.replace('/conf.py', '')
+            return os.path.dirname(conf_file)
 
     @property
     def is_type_sphinx(self):


Test patch: