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

Issue:
Remove unused variable media_url_prefix
This code appears to no longer be in use. If you look at the template being rendered, `media_url_prefix` is never used.

https://github.com/rtfd/readthedocs.org/commit/35a942b71c047c2518f96bea9a2f9bdc0aa921d6#diff-4fcca638684a1c1611b72a6dd6f1119aR34



Discussion:

Resolving patch:
diff --git a/readthedocs/projects/views/public.py b/readthedocs/projects/views/public.py
--- a/readthedocs/projects/views/public.py
+++ b/readthedocs/projects/views/public.py
@@ -159,23 +159,12 @@ def project_downloads(request, project_slug):
         if data:
             version_data[version] = data
 
-    # in case the MEDIA_URL is a protocol relative URL we just assume
-    # we want http as the protcol, so that Dash is able to handle the URL
-    if settings.MEDIA_URL.startswith('//'):
-        media_url_prefix = u'http:'
-    # but in case we're in debug mode and the MEDIA_URL is just a path
-    # we prefix it with a hardcoded host name and protocol
-    elif settings.MEDIA_URL.startswith('/') and settings.DEBUG:
-        media_url_prefix = u'http://%s' % request.get_host()
-    else:
-        media_url_prefix = ''
     return render_to_response(
         'projects/project_downloads.html',
         {
             'project': project,
             'version_data': version_data,
             'versions': versions,
-            'media_url_prefix': media_url_prefix,
         },
         context_instance=RequestContext(request),
     )


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
[Suggestion] Use a link to the doc rather than the project for the badge
The Markdown snippet provided for the badge currently uses a link to the project page on ReadTheDocs. I think it might be more useful for people seeing the badge on the package if the link was actually pointing to the rendered doc. They are more likely to be interested in the documentation of the package rather than the config used to build it.
What do you think about this ?



Discussion:
The badge alternative text says `Documentation Status` so this was meant to display the status I guess. 

But for documentation status doesn't really mean much because it's unlikely somebody will break the documentation :)

:+1: 

I would like, given that the badge says `docs: latest`, that clicking on the badge would take me to the build artifacts associated with the `latest` label in ReadTheDocs.

The same would go for `docs: stable`, which would point to documentation associated with the latest tagged version.

I agree: the badge should link to the docs themselves.  No one but me is going to want to see the project page.

I'm a :+1: as well. However we need a decision by @ericholscher or @agjohnson here.

I think this makes sense, it is in line with our thoughts on redesigning what "failing" builds mean in the context of authorship and in consuming documentation. This was implemented as an author feature, but really should be a reader feature.


Resolving patch:
diff --git a/readthedocs/projects/views/public.py b/readthedocs/projects/views/public.py
--- a/readthedocs/projects/views/public.py
+++ b/readthedocs/projects/views/public.py
@@ -90,18 +90,17 @@ def get_context_data(self, **kwargs):
         if self.request.is_secure():
             protocol = 'https'
 
+        version_slug = project.get_default_version()
+
         context['badge_url'] = "%s://%s%s?version=%s" % (
             protocol,
             settings.PRODUCTION_DOMAIN,
             reverse('project_badge', args=[project.slug]),
             project.get_default_version(),
         )
-        context['site_url'] = "%s://%s%s?badge=%s" % (
-            protocol,
-            settings.PRODUCTION_DOMAIN,
-            reverse('projects_detail', args=[project.slug]),
-            project.get_default_version(),
-        )
+        context['site_url'] = "{url}?badge={version}".format(
+            url=project.get_docs_url(version_slug),
+            version=version_slug)
 
         return context
 


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Establish pip cache for docker containers
The containers aren't sharing the normal pip cache of `/home/docs/.cache/pip`, which also effects the wheel cache. We should explicitly specify a project-local pip cache dir to use, so that package install time can be reduced.

Raised in #1767 



Discussion:

Resolving patch:
diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py
--- a/readthedocs/projects/models.py
+++ b/readthedocs/projects/models.py
@@ -412,6 +412,11 @@ def checkout_path(self, version=LATEST):
     def venv_path(self, version=LATEST):
         return os.path.join(self.doc_path, 'envs', version)
 
+    @property
+    def pip_cache_path(self):
+        """Path to pip cache"""
+        return os.path.join(self.doc_path, '.cache', 'pip')
+
     #
     # Paths for symlinks in project doc_path.
     #
diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py
--- a/readthedocs/projects/tasks.py
+++ b/readthedocs/projects/tasks.py
@@ -261,6 +261,8 @@ def setup_environment(self):
             'install',
             '--use-wheel',
             '-U',
+            '--cache-dir',
+            self.project.pip_cache_path,
         ]
         if self.project.use_system_packages:
             # Other code expects sphinx-build to be installed inside the
@@ -294,6 +296,8 @@ def setup_environment(self):
                 self.project.venv_bin(version=self.version.slug, filename='pip'),
                 'install',
                 '--exists-action=w',
+                '--cache-dir',
+                self.project.pip_cache_path,
                 '-r{0}'.format(requirements_file_path),
                 cwd=checkout_path,
                 bin_path=self.project.venv_bin(version=self.version.slug)
@@ -309,6 +313,8 @@ def setup_environment(self):
                     self.project.venv_bin(version=self.version.slug, filename='pip'),
                     'install',
                     '--ignore-installed',
+                    '--cache-dir',
+                    self.project.pip_cache_path,
                     '.',
                     cwd=checkout_path,
                     bin_path=self.project.venv_bin(version=self.version.slug)


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
move to sphinx 1.3.5
sphinx 1.3.4 introduced this bug: https://github.com/sphinx-doc/sphinx/issues/2247
, which breaks builds of projects using definition lists containing regular expression like strings.

This was considered a high priority bug by the sphinx devs and was fixed with version 1.3.5.
Please move to the new version so that I can again build my docs.



Discussion:
Is this as simple as a one-character fix to change the sphinx version in requirements/pip.txt?  We are having the same problems on our project.  

You can specify a specific Sphinx version in your requirements file, and we'll install it over our default. 

Reopening this as we should test and change our dependencies for sphinx still. Anyone that requires the latest release should use an override though.

Thanks for reopening this.

While adding a working sphinx version to your requirements file is a workaround (thanks for pointing it out), I'd like to stress that this is a bug in just one specific version of sphinx so affected docs would build with any sphinx **except** 1.3.4.
Just conceptually I find it the wrong approach to tell people to adjust their repos because you are building their docs with buggy software. The right solution, IMO, is still to move on to v1.3.5 or, alternatively, go back to 1.3.3.
For the same reason I think this should not be classified as an enhancement, but as a bug fix.

@wm75 we just can't flip a switch and deploy it -- vetting and all that. 1.3.5 is our next target and it will be pinned as soon as we can verify the new release.

Sure, no problem waiting. The requirements file works for me for the time being.


Resolving patch:
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
@@ -97,7 +97,7 @@ def setup_base(self):
 
     def install_core_requirements(self):
         requirements = [
-            'sphinx==1.3.4',
+            'sphinx==1.3.5',
             'Pygments==2.0.2',
             'setuptools==18.6.1',
             'docutils==0.12',
@@ -187,7 +187,7 @@ def install_core_requirements(self):
 
         # Use conda for requirements it packages
         requirements = [
-            'sphinx==1.3.1',
+            'sphinx==1.3.5',
             'Pygments==2.0.2',
             'docutils==0.12',
             'mock',


Test patch:
Repository: readthedocs/readthedocs.org

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">



Discussion:
For reference my `mkdocs.yml` file is here: https://github.com/linkedin/gobblin/blob/readTheDocs/mkdocs.yml

The docs are checked into the following branch of this GitHub Project: https://github.com/linkedin/gobblin/tree/readTheDocs and are under the folder `gobblin-docs`

The ReadTheDocs Admin Page is here: https://readthedocs.org/projects/gobblin/
The ReadTheDocs Home Page is here: http://gobblin.readthedocs.org/en/readthedocs/

For some reason, the URL requested includes an incorrect version slug of: `&version=readTheDocs`. It should be the version slug, ie:`&version=readthedocs`. This seems like whatever Mkdocs is using here is incorrect.

Seems this is where it is wrong:
https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/doc_builder/backends/mkdocs.py#L101

Thanks a ton for the investigation @agjohnson 

Should I go ahead and open an Issue on the Mkdocs GitHub?

If the change is as simple as `'version': self.version.verbose_name,` to `'version': self.version.slug,` I can create the PR too

A PR would be :100: I believe that change should be enough. I don't use Mkdocs and haven't tested this however.


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
@@ -98,7 +98,7 @@ def append_conf(self, **kwargs):
         # 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",


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
allow users to pick if package should be installed with pip
## Details

There is a system-wide config for whether "install this package" should mean `pip install .` or `setup.py install`. It would be useful for packages to be able to specify, at least in the `setup.py install` case that's on the official deployment, that `pip install .` should be used for their package.



Discussion:
This might be worth exploring as part of our push to move configuration into a top-level `readthedoc.yaml` configuration file.

Leaving this open here, it might move to the readthedocs-build repo however.


Resolving patch:
diff --git a/readthedocs/doc_builder/config.py b/readthedocs/doc_builder/config.py
--- a/readthedocs/doc_builder/config.py
+++ b/readthedocs/doc_builder/config.py
@@ -23,8 +23,17 @@ def __init__(self, version, yaml_config):
         self._project = version.project
         self._yaml_config = yaml_config
 
+    @property
+    def pip_install(self):
+        if 'pip_install' in self._yaml_config.get('python', {}):
+            return self._yaml_config['python']['pip_install']
+        else:
+            return False
+
     @property
     def install_project(self):
+        if self.pip_install:
+            return True
         if 'setup_py_install' in self._yaml_config.get('python', {}):
             return self._yaml_config['python']['setup_py_install']
         else:
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
@@ -43,7 +43,7 @@ def delete_existing_build_dir(self):
     def install_package(self):
         setup_path = os.path.join(self.checkout_path, 'setup.py')
         if os.path.isfile(setup_path) and self.config.install_project:
-            if getattr(settings, 'USE_PIP_INSTALL', False):
+            if self.config.pip_install or getattr(settings, 'USE_PIP_INSTALL', False):
                 self.build_env.run(
                     'python',
                     self.venv_bin(filename='pip'),


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Increment Pygements release to support Python 3.5 syntax
Hello,

Read the Docs offers the option to build docs with Python 2.x or 3.x, which is great.

Python 3.5 introduced some new syntax, namely the `await` and `async` keywords. Since Read the Docs runs Python 3.4, code samples that use this syntax cannot be parsed and thus aren't syntax-highlighted. See the first block on [this page](http://aiohttp.readthedocs.org/en/v0.19.0/web.html) for example.

Have you considered making it possible to pick a specific Python version, perhaps among 2.7, 3.4, 3.5? Alternatively, do you have a rough idea of when you'll upgrade the platform to 3.5?

Thanks! 



Discussion:
I appear to have incorrectly assumed that it was related to the version of Python running Sphinx.

Apparently the next release of Pygments (for which there's no ETA) should solve the problem.

https://bitbucket.org/birkenfeld/pygments-main/issues/1154/please-make-next-release

Regarding the Python version selection: we haven't yet, though the ability to use arbitrary versions of Python might be a good future feature.

The real issue seems to be a pending Pygments release, we'll pin the next release to come out.

Pygments 2.1 was releaseed mid-January, unblocking this issue.

Is it just a matter of bumping Pygments to 2.1.3 in `requirements/pip.txt`?

You'll need to update the requirements in:
https://github.com/rtfd/readthedocs.org/blob/42ab9d198494d5cf9fe320ac217d837bf480c73f/readthedocs/doc_builder/python_environments.py


Resolving patch:
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
@@ -98,7 +98,7 @@ def setup_base(self):
     def install_core_requirements(self):
         requirements = [
             'sphinx==1.3.5',
-            'Pygments==2.0.2',
+            'Pygments==2.1.3',
             'setuptools==20.1.1',
             'docutils==0.12',
             'mkdocs==0.15.0',
@@ -189,7 +189,7 @@ def install_core_requirements(self):
         # Use conda for requirements it packages
         requirements = [
             'sphinx==1.3.5',
-            'Pygments==2.0.2',
+            'Pygments==2.1.3',
             'docutils==0.12',
             'mock',
             'pillow==3.0.0',


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
"IOError: [Errno 26] Text file busy" during build.
## Details
- Project URL: https://github.com/xmlrunner/unittest-xml-reporting
- Build URL (if applicable): https://readthedocs.org/projects/unittest-xml-reporting/builds/4052270/
- Read the Docs username (if applicable): dnozay
## Excepted Result

Build should have passed (e.g. https://readthedocs.org/projects/unittest-xml-reporting/builds/4052269/)
## Actual Result

`IOError` raised during `python -mvirtualenv --no-site-packages /home/docs/checkouts/readthedocs.org/user_builds/unittest-xml-reporting/envs/latest`



Discussion:

Resolving patch:
diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py
--- a/readthedocs/projects/tasks.py
+++ b/readthedocs/projects/tasks.py
@@ -297,11 +297,15 @@ def setup_environment(self):
         """
         self.build_env.update_build(state=BUILD_STATE_INSTALLING)
 
-        self.python_env.delete_existing_build_dir()
-        self.python_env.setup_base()
-        self.python_env.install_core_requirements()
-        self.python_env.install_user_requirements()
-        self.python_env.install_package()
+        with self.project.repo_nonblockinglock(
+                version=self.version,
+                max_lock_age=getattr(settings, 'REPO_LOCK_SECONDS', 30)):
+
+            self.python_env.delete_existing_build_dir()
+            self.python_env.setup_base()
+            self.python_env.install_core_requirements()
+            self.python_env.install_user_requirements()
+            self.python_env.install_package()
 
     def build_docs(self):
         """Wrapper to all build functions


Test patch:
Repository: readthedocs/readthedocs.org

Issue:
Tags are not saved when creating a new project
## Details
- Project URL: N/A (affects all new projects)
- Build URL (if applicable): N/A
- Read the Docs username (if applicable): N/A
### Steps
1. Go to https://readthedocs.org/dashboard/import/manual
2. Select any project to import
3. Check the "Edit advanced project options" option
4. Enter the following in the `Tags` field:
   
   `foo, bar, foo bar`
5. Complete remaining required fields and submit the form
## Expected Result

On https://readthedocs.org/projects/YOUR_PROJECT_NAME, three tags are listed:

`foo`, `bar`, and `"foo bar"`.
## Actual Result

No tags are listed. Tags appear after adding them again on: 

https://readthedocs.org/dashboard/YOUR_PROJECT_NAME/edit



Discussion:

Resolving patch:
diff --git a/readthedocs/projects/views/private.py b/readthedocs/projects/views/private.py
--- a/readthedocs/projects/views/private.py
+++ b/readthedocs/projects/views/private.py
@@ -251,13 +251,18 @@ def done(self, form_list, **kwargs):
         other side effects for now, by signalling a save without commit. Then,
         finish by added the members to the project and saving.
         """
+        form_data = self.get_all_cleaned_data()
+        extra_fields = ProjectExtraForm.Meta.fields
         # expect the first form
         basics_form = form_list[0]
         # Save the basics form to create the project instance, then alter
         # attributes directly from other forms
         project = basics_form.save()
-        for form in form_list[1:]:
-            for (field, value) in form.cleaned_data.items():
+        tags = form_data.pop('tags', [])
+        for tag in tags:
+            project.tags.add(tag)
+        for field, value in form_data.items():
+            if field in extra_fields:
                 setattr(project, field, value)
         basic_only = True
         project.save()


Test patch:
diff --git a/readthedocs/rtd_tests/tests/test_project_views.py b/readthedocs/rtd_tests/tests/test_project_views.py
--- a/readthedocs/rtd_tests/tests/test_project_views.py
+++ b/readthedocs/rtd_tests/tests/test_project_views.py
@@ -116,6 +116,7 @@ def setUp(self):
             'description': 'Describe foobar',
             'language': 'en',
             'documentation_type': 'sphinx',
+            'tags': 'foo, bar, baz',
         }
 
     def test_form_pass(self):
@@ -129,6 +130,11 @@ def test_form_pass(self):
         self.assertIsNotNone(proj)
         data = self.step_data['basics']
         del data['advanced']
+        del self.step_data['extra']['tags']
+        self.assertItemsEqual(
+            [tag.name for tag in proj.tags.all()],
+            [u'bar', u'baz', u'foo']
+        )
         data.update(self.step_data['extra'])
         for (key, val) in data.items():
             self.assertEqual(getattr(proj, key), val)
Repository: readthedocs/readthedocs.org

Issue:
MkDocs's media url shouldn't be hardcode with media_url = 'http://localhost:8000' + media_url
In file `readthedocs.org/readthedocs/doc_builder/backends/mkdocs.py`:

``` python
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
```

Can u please to replace it with `SITE_URL` as the follows:

``` python
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 = getattr(settings, 'SITE_URL', None) + media_url
```



Discussion:
The `MEDIA_URL` was defined in  `readthedocs/settings/base.py` at line 169,

``` python
165    # Assets and media
166    STATIC_ROOT = os.path.join(SITE_ROOT, 'media/static/')
167    STATIC_URL = '/static/'
168    MEDIA_ROOT = os.path.join(SITE_ROOT, 'media/')
169    MEDIA_URL = '/media/'
```

However, in file `readthedocs/doc_builder/backends/mkdocs.py` at line 61, it appends  `http://localhost:8000` as a prefix to the `media_url`,

``` python
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
```

The hard coded domain should be replaced with `PRODUCTION_DOMAIN` setting, as a domain seems to be required here, as per the note above.


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
@@ -58,7 +58,8 @@ def append_conf(self, **kwargs):
 
         # Mkdocs needs a full domain here because it tries to link to local media files
         if not media_url.startswith('http'):
-            media_url = 'http://localhost:8000' + media_url
+            domain = getattr(settings, 'PRODUCTION_DOMAIN')
+            media_url = 'http://{}/{}'.format(domain, media_url)
 
         if 'extra_javascript' in user_config:
             user_config['extra_javascript'].append('readthedocs-data.js')


Test patch: