Skip to content

Commit 064a028

Browse files
committed
Merge branch 'master' into refactor-search-apiview
2 parents 029857c + 4c6fe4b commit 064a028

File tree

29 files changed

+552
-25
lines changed

29 files changed

+552
-25
lines changed

CHANGELOG.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
Version 5.1.1
2+
-------------
3+
4+
:Date: May 26, 2020
5+
6+
* `@stsewd <https://github.com/stsewd>`__: Search: show total_results from last query (`#7101 <https://github.com/readthedocs/readthedocs.org/pull/7101>`__)
7+
* `@humitos <https://github.com/humitos>`__: Add a tip in EmbedAPI to use Sphinx reference in section (`#7099 <https://github.com/readthedocs/readthedocs.org/pull/7099>`__)
8+
* `@ericholscher <https://github.com/ericholscher>`__: Release 5.1.0 (`#7098 <https://github.com/readthedocs/readthedocs.org/pull/7098>`__)
9+
* `@ericholscher <https://github.com/ericholscher>`__: Add a setting for storing pageviews (`#7097 <https://github.com/readthedocs/readthedocs.org/pull/7097>`__)
10+
* `@humitos <https://github.com/humitos>`__: Document Embed APIv2 endpoint (`#7095 <https://github.com/readthedocs/readthedocs.org/pull/7095>`__)
11+
* `@stsewd <https://github.com/stsewd>`__: Footer: Check for mkdocs doctype too (`#7094 <https://github.com/readthedocs/readthedocs.org/pull/7094>`__)
12+
* `@ericholscher <https://github.com/ericholscher>`__: Fix the unresolver not working properly with root paths (`#7093 <https://github.com/readthedocs/readthedocs.org/pull/7093>`__)
13+
* `@ericholscher <https://github.com/ericholscher>`__: Add a project-level configuration for PR builds (`#7090 <https://github.com/readthedocs/readthedocs.org/pull/7090>`__)
14+
* `@santos22 <https://github.com/santos22>`__: Fix tests ahead of django-dynamic-fixture update (`#7073 <https://github.com/readthedocs/readthedocs.org/pull/7073>`__)
15+
* `@ericholscher <https://github.com/ericholscher>`__: Add ability for users to set their own URLConf (`#6963 <https://github.com/readthedocs/readthedocs.org/pull/6963>`__)
16+
* `@dojutsu-user <https://github.com/dojutsu-user>`__: Store Pageviews in DB (`#6121 <https://github.com/readthedocs/readthedocs.org/pull/6121>`__)
17+
* `@humitos <https://github.com/humitos>`__: GitLab Integration (`#3327 <https://github.com/readthedocs/readthedocs.org/pull/3327>`__)
18+
119
Version 5.1.0
220
-------------
321

docs/api/v2.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,85 @@ Build detail
317317

318318
Some fields primarily used for UI elements in Read the Docs are omitted.
319319

320+
321+
Embed
322+
~~~~~
323+
324+
.. http:get:: /api/v2/embed/
325+
326+
Retrieve HTML-formatted content from documentation page or section.
327+
328+
**Example request**:
329+
330+
.. prompt:: bash $
331+
332+
curl https://readthedocs.org/api/v2/embed/?project=docs&version=latest&doc=features&path=features.html
333+
334+
or
335+
336+
.. prompt:: bash $
337+
338+
curl https://readthedocs.org/api/v2/embed/?url=https://docs.readthedocs.io/en/latest/features.html
339+
340+
**Example response**:
341+
342+
.. sourcecode:: js
343+
344+
{
345+
"content": [
346+
"<div class=\"section\" id=\"read-the-docs-features\">\n<h1>Read the Docs..."
347+
],
348+
"headers": [
349+
{
350+
"Read the Docs features": "#"
351+
},
352+
{
353+
"Automatic Documentation Deployment": "#automatic-documentation-deployment"
354+
},
355+
{
356+
"Custom Domains & White Labeling": "#custom-domains-white-labeling"
357+
},
358+
{
359+
"Versioned Documentation": "#versioned-documentation"
360+
},
361+
{
362+
"Downloadable Documentation": "#downloadable-documentation"
363+
},
364+
{
365+
"Full-Text Search": "#full-text-search"
366+
},
367+
{
368+
"Open Source and Customer Focused": "#open-source-and-customer-focused"
369+
}
370+
],
371+
"url": "https://docs.readthedocs.io/en/latest/features",
372+
"meta": {
373+
"project": "docs",
374+
"version": "latest",
375+
"doc": "features",
376+
"section": "read the docs features"
377+
}
378+
}
379+
380+
:>json string content: HTML content of the section.
381+
:>json object headers: section's headers in the document.
382+
:>json string url: URL of the document.
383+
:>json object meta: meta data of the requested section.
384+
385+
:query string project: Read the Docs project's slug.
386+
:query string doc: document to fetch content from.
387+
388+
:query string version: *optional* Read the Docs version's slug (default: ``latest``).
389+
:query string section: *optional* section within the document to fetch.
390+
:query string path: *optional* full path to the document including extension.
391+
392+
:query string url: full URL of the document (and section) to fetch content from.
393+
394+
.. note::
395+
396+
You can call this endpoint by sending at least ``project`` and ``doc`` *or* ``url`` attribute.
397+
398+
320399
Undocumented resources and endpoints
321400
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322401

docs/guides/autobuild-docs-for-pull-requests.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ Autobuild Documentation for Pull Requests
22
=========================================
33

44
Read the Docs allows autobuilding documentation for pull/merge requests for GitHub or GitLab projects.
5-
This feature is currently available under a :doc:`Feature Flag </guides/feature-flags>`.
6-
So, you can enable this feature by sending us an `email <mailto:[email protected]>`__ including your project URL.
5+
This feature is currently enabled for a subset of our projects while being rolled out.
6+
You can check to see if your project has it enabled by looking at the :guilabel:`Admin > Advanced settings` and look for :guilabel:`Build pull requests for this project`.
7+
We are rolling this feature out based on the projects age on Read the Docs,
8+
so older projects will get it first.
9+
You can also ask for this feature by sending us an `email <mailto:[email protected]>`__ including your project URL.
710

811
Features
912
--------

docs/guides/embedding-content.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,32 @@ from our own docs and will populate the content of it into the ``#help-container
7373
You can modify this example to subscribe to ``.onclick`` Javascript event,
7474
and show a modal when the user clicks in a "Help" link.
7575

76+
.. tip::
77+
78+
Take into account that if the title changes, your ``section`` argument will break.
79+
To avoid that, you can manually define Sphinx references above the sections you don't want to break.
80+
For example,
81+
82+
.. code-block:: rst
83+
:emphasize-lines: 3
84+
85+
.. in your .rst document file
86+
87+
.. _unbreakable-section-reference:
88+
89+
Creating an automation rule
90+
---------------------------
91+
92+
This is the text of the section.
93+
94+
To link to the section "Creating an automation rule" you can send ``section=unbreakable-section-reference``.
95+
If you change the title it won't break the embedded content because the label for that title will still be ``unbreakable-section-reference``.
96+
97+
Please, take a look at the Sphinx `:ref:` `role documentation`_ for more information about how to create references.
98+
99+
.. _role documentation: https://www.sphinx-doc.org/en/stable/usage/restructuredtext/roles.html#role-ref
100+
101+
76102
Calling the Embed API directly
77103
------------------------------
78104

readthedocs/api/v2/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Meta:
2727
'documentation_type',
2828
'users',
2929
'canonical_url',
30+
'urlconf',
3031
)
3132

3233

readthedocs/api/v2/views/integrations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ def handle_webhook(self):
412412
# Handle pull request events
413413
if all([
414414
self.project.has_feature(Feature.EXTERNAL_VERSION_BUILD),
415+
self.project.external_builds_enabled,
415416
event == GITHUB_PULL_REQUEST,
416417
action,
417418
]):
@@ -568,6 +569,7 @@ def handle_webhook(self):
568569

569570
if (
570571
self.project.has_feature(Feature.EXTERNAL_VERSION_BUILD) and
572+
self.project.external_builds_enabled and
571573
event == GITLAB_MERGE_REQUEST and action
572574
):
573575
if (

readthedocs/core/resolver.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def base_resolve_path(
6262
subproject_slug=None,
6363
subdomain=None,
6464
cname=None,
65+
urlconf=None,
6566
):
6667
"""Resolve a with nothing smart, just filling in the blanks."""
6768
# Only support `/docs/project' URLs outside our normal environment. Normally
@@ -79,6 +80,31 @@ def base_resolve_path(
7980
else:
8081
url += '{language}/{version_slug}/{filename}'
8182

83+
# Allow users to override their own URLConf
84+
# This logic could be cleaned up with a standard set of variable replacements
85+
if urlconf:
86+
url = urlconf
87+
url = url.replace(
88+
'$version',
89+
'{version_slug}',
90+
)
91+
url = url.replace(
92+
'$language',
93+
'{language}',
94+
)
95+
url = url.replace(
96+
'$filename',
97+
'{filename}',
98+
)
99+
url = url.replace(
100+
'$subproject',
101+
'{subproject_slug}',
102+
)
103+
if '$' in url:
104+
log.warning(
105+
'Unconverted variable in a resolver URLConf: url=%s', url
106+
)
107+
82108
return url.format(
83109
project_slug=project_slug,
84110
filename=filename,
@@ -97,6 +123,7 @@ def resolve_path(
97123
single_version=None,
98124
subdomain=None,
99125
cname=None,
126+
urlconf=None,
100127
):
101128
"""Resolve a URL with a subset of fields defined."""
102129
version_slug = version_slug or project.get_default_version()
@@ -122,6 +149,7 @@ def resolve_path(
122149
subproject_slug=subproject_slug,
123150
cname=cname,
124151
subdomain=subdomain,
152+
urlconf=urlconf or project.urlconf,
125153
)
126154

127155
def resolve_domain(self, project):

readthedocs/core/static-src/core/js/doc-embed/rtd-data.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ function get() {
5959

6060
$.extend(config, defaults, window.READTHEDOCS_DATA);
6161

62-
// Force to use new settings
63-
config.proxied_api_host = '/_';
62+
if (!("proxied_api_host" in config)) {
63+
// Use direct proxied API host
64+
config.proxied_api_host = '/_';
65+
}
6466

6567
return config;
6668
}

readthedocs/core/static/core/js/readthedocs-doc-embed.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readthedocs/doc_builder/backends/sphinx.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def build(self):
234234
build_command = [
235235
*self.get_sphinx_cmd(),
236236
'-T',
237+
*self.sphinx_parallel_arg(),
237238
]
238239
if self._force:
239240
build_command.append('-E')
@@ -270,6 +271,11 @@ def get_sphinx_cmd(self):
270271
self.python_env.venv_bin(filename='sphinx-build'),
271272
)
272273

274+
def sphinx_parallel_arg(self):
275+
if self.project.has_feature(Feature.SPHINX_PARALLEL):
276+
return ['-j', 'auto']
277+
return []
278+
273279
def venv_sphinx_supports_latexmk(self):
274280
"""
275281
Check if ``sphinx`` from the user's venv supports ``latexmk``.
@@ -448,6 +454,7 @@ def build(self):
448454
*self.get_sphinx_cmd(),
449455
'-b',
450456
'latex',
457+
*self.sphinx_parallel_arg(),
451458
'-D',
452459
'language={lang}'.format(lang=self.project.language),
453460
'-d',

readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ context = {
9797
'conf_py_path': '{{ conf_py_path }}',
9898
'api_host': '{{ api_host }}',
9999
'github_user': '{{ github_user }}',
100+
'proxied_api_host': '{{ project.proxied_api_host }}',
100101
'github_repo': '{{ github_repo }}',
101102
'github_version': '{{ github_version }}',
102103
'display_github': {{ display_github }},

readthedocs/projects/forms.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class Meta:
203203
'analytics_code',
204204
'show_version_warning',
205205
'single_version',
206+
'external_builds_enabled'
206207
)
207208
# These that can be set per-version using a config file.
208209
per_version_settings = (
@@ -259,6 +260,10 @@ def __init__(self, *args, **kwargs):
259260
else:
260261
self.fields['default_version'].widget.attrs['readonly'] = True
261262

263+
# Enable PR builder option on projects w/ feature flag
264+
if not self.instance.has_feature(Feature.EXTERNAL_VERSION_BUILD):
265+
self.fields.pop('external_builds_enabled')
266+
262267
def clean_conf_py_file(self):
263268
filename = self.cleaned_data.get('conf_py_file', '').strip()
264269
if filename and 'conf.py' not in filename:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.10 on 2020-05-21 22:18
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('projects', '0048_remove_version_privacy_field'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='project',
15+
name='external_builds_enabled',
16+
field=models.BooleanField(default=False, help_text='More information in <a href="https://docs.readthedocs.io/en/latest/guides/autobuild-docs-for-pull-requests.html">our docs</a>', null=True, verbose_name='Build pull requests for this project'),
17+
),
18+
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 2.2.10 on 2020-05-19 13:24
2+
3+
from django.db import migrations
4+
5+
6+
def migrate_features(apps, schema_editor):
7+
# Enable the PR builder for projects with the feature flag
8+
Feature = apps.get_model('projects', 'Feature')
9+
if Feature.objects.filter(feature_id='external_version_build').exists():
10+
for project in Feature.objects.get(feature_id='external_version_build').projects.all():
11+
project.external_builds_enabled = True
12+
project.save()
13+
14+
class Migration(migrations.Migration):
15+
16+
dependencies = [
17+
('projects', '0049_add_external_build_enabled'),
18+
]
19+
20+
operations = [
21+
migrations.RunPython(migrate_features),
22+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.10 on 2020-05-26 14:34
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('projects', '0050_migrate_external_builds'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='project',
15+
name='urlconf',
16+
field=models.CharField(default=None, help_text='Supports the following keys: $language, $version, $subproject, $filename. An example: `$language/$version/$filename`.', max_length=255, null=True, verbose_name='Documentation URL Configuration'),
17+
),
18+
]

0 commit comments

Comments
 (0)