Skip to content

Commit 9883fcd

Browse files
authored
Merge branch 'master' into humitos/document-share-sphinx-doctree-flag
2 parents 37ea719 + d3fdb3b commit 9883fcd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+700
-57
lines changed
Loading

docs/api/v3.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ Version detail
394394
"ref": "19.0.2",
395395
"built": true,
396396
"active": true,
397+
"hidden": false,
397398
"type": "tag",
398399
"last_build": "{BUILD}",
399400
"downloads": {
@@ -460,7 +461,8 @@ Version update
460461
.. sourcecode:: json
461462

462463
{
463-
"active": true
464+
"active": true,
465+
"hidden": false
464466
}
465467

466468
:statuscode 204: Updated successfully

docs/guides/feature-flags.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Feature Flags
44
Read the Docs offers some additional flag settings which can be only be configured by the site admin.
55
These are optional settings and you might not need it for every project.
66
By default, these flags are disabled for every project.
7-
A separate request can be made by opening an issue on our `github`_ to enable
7+
A separate request can be made by `contacting us via email`_ to enable
88
or disable one or more of these featured flags for a particular project.
99

10-
.. _github: https://github.com/readthedocs/readthedocs.org
10+
.. _contacting us via email: mailto:support@readthedocs.org
1111

1212
Available Flags
1313
---------------

docs/guides/hiding-a-version.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Hide a Version and Keep its Docs Online
2+
=======================================
3+
4+
If you manage a project with a lot of versions,
5+
the version (flyout) menu of your docs can be easily overwhelmed and hard to navigate.
6+
7+
.. figure:: /_static/images/guides/flyout-overwhelmed.png
8+
:align: center
9+
10+
Overwhelmed flyout menu
11+
12+
You can deactivate the version to remove its docs,
13+
but removing its docs isn't always an option.
14+
To not list a version in the flyout menu while keeping its docs online, you can mark it as hidden.
15+
Go to the :guilabel:`Versions` tab of your project, click on :guilabel:`Edit` and mark the ``Hidden`` option.
16+
17+
Users that have a link to your old version will still be able to see your docs.
18+
And new users can see all your versions (including hidden versions) in the versions tab of your project at ``https://readthedocs.org/projects/<your-project>/versions/``
19+
20+
Check the docs about :ref:`versions' states <versions:States>` for more information.

docs/guides/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ These guides will help you customize or tune aspects of Read the Docs.
3636
autobuild-docs-for-pull-requests
3737
build-notifications
3838
build-using-too-many-resources
39-
technical-docs-seo-guide
4039
canonical
4140
conda
4241
environment-variables
4342
feature-flags
4443
google-analytics
44+
hiding-a-version
4545
searching-with-readthedocs
4646
sitemaps
4747
specifying-dependencies
48+
technical-docs-seo-guide
4849
wipe-environment
4950

5051

docs/versions.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,53 @@ they will be redirected to the **Default version**.
5858
This defaults to **latest**,
5959
but could also point to your latest released version.
6060

61+
States
62+
------
63+
64+
States define the visibility of a version across the site.
65+
You can change the states of a version from the :guilabel:`Versions` tab of your project.
66+
67+
Active
68+
~~~~~~
69+
70+
- **Active**
71+
72+
- Docs for this version are visible
73+
- Builds can be triggered for this version
74+
75+
- **Inactive**
76+
77+
- Docs for this version aren't visible
78+
- Builds can't be triggered for this version
79+
80+
When you deactivate a version, its docs are removed.
81+
82+
Hidden
83+
~~~~~~
84+
85+
- **Not hidden and Active**
86+
87+
- This version is listed on the version (flyout) menu on the docs site
88+
- This version is shown in search results on the docs site
89+
90+
- **Hidden and Active**
91+
92+
- This version isn't listed on the version (flyout) menu on the docs site
93+
- This version isn't show in search results from another version on the docs site
94+
(like on search results from a superproject)
95+
96+
Hiding a version doesn't make it private,
97+
any user with a link to its docs would be able to see it.
98+
This is useful when:
99+
100+
- You no longer support a version, but you don't want to remove its docs.
101+
- You have a work in progress version and don't want to publish its docs just yet.
102+
103+
.. note::
104+
105+
Active versions that are hidden will be listed as ``Disallow: /path/to/version/``
106+
in the default `robots.txt file <https://www.robotstxt.org/>`__ created by Read the Docs.
107+
61108
Version warning
62109
---------------
63110

readthedocs/api/v2/views/footer_views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def _get_active_versions_sorted(self):
127127
project = self._get_project()
128128
versions = project.ordered_active_versions(
129129
user=self.request.user,
130+
include_hidden=False,
130131
)
131132
return versions
132133

readthedocs/api/v3/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ class Meta:
220220
'ref',
221221
'built',
222222
'active',
223+
'hidden',
223224
'type',
224225
'downloads',
225226
'urls',

readthedocs/api/v3/tests/responses/projects-detail.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"active_versions": [
33
{
44
"active": true,
5+
"hidden": false,
56
"built": true,
67
"downloads": {
78
"epub": "https://project.readthedocs.io/_/downloads/en/v1.0/epub/",

readthedocs/api/v3/tests/responses/projects-versions-builds-list_POST.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"triggered": true,
7373
"version": {
7474
"active": true,
75+
"hidden": false,
7576
"built": true,
7677
"downloads": {
7778
"epub": "https://project.readthedocs.io/_/downloads/en/v1.0/epub/",

readthedocs/api/v3/tests/responses/projects-versions-detail.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"active": true,
3+
"hidden": false,
34
"built": true,
45
"downloads": {
56
"epub": "https://project.readthedocs.io/_/downloads/en/v1.0/epub/",

readthedocs/builds/forms.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import re
44
import textwrap
55

6+
from crispy_forms.helper import FormHelper
7+
from crispy_forms.layout import HTML, Fieldset, Layout
68
from django import forms
9+
from django.template.loader import render_to_string
710
from django.utils.translation import ugettext_lazy as _
811

912
from readthedocs.builds.constants import (
@@ -22,7 +25,36 @@ class VersionForm(HideProtectedLevelMixin, forms.ModelForm):
2225

2326
class Meta:
2427
model = Version
25-
fields = ['active', 'privacy_level']
28+
states_fields = ['active', 'hidden']
29+
privacy_fields = ['privacy_level']
30+
fields = (
31+
*states_fields,
32+
*privacy_fields,
33+
)
34+
35+
def __init__(self, *args, **kwargs):
36+
super().__init__(*args, **kwargs)
37+
38+
# TODO: remove when this field is no-nullable
39+
self.fields['hidden'].widget = forms.CheckboxInput()
40+
self.fields['hidden'].empty_value = False
41+
42+
self.helper = FormHelper()
43+
self.helper.layout = Layout(
44+
Fieldset(
45+
_('States'),
46+
HTML(render_to_string('projects/project_version_states_help_text.html')),
47+
*self.Meta.states_fields,
48+
),
49+
Fieldset(
50+
_('Privacy'),
51+
*self.Meta.privacy_fields,
52+
),
53+
HTML(render_to_string(
54+
'projects/project_version_submit.html',
55+
context={'version': self.instance},
56+
)),
57+
)
2658

2759
def clean_active(self):
2860
active = self.cleaned_data['active']
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.11 on 2020-03-18 01:47
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('builds', '0017_builds_deterministic_order_index'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='version',
15+
name='hidden',
16+
field=models.BooleanField(null=True, default=False, help_text='Hide this version from the version (flyout) menu and search results?', verbose_name='Hidden'),
17+
),
18+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Django 2.2.11 on 2020-03-18 18:27
2+
3+
from django.db import migrations
4+
5+
6+
def forwards_func(apps, schema_editor):
7+
"""Migrate all protected versions to be hidden."""
8+
Version = apps.get_model('builds', 'Version')
9+
Version.objects.filter(privacy_level='protected').update(hidden=True)
10+
11+
12+
class Migration(migrations.Migration):
13+
14+
dependencies = [
15+
('builds', '0018_add_hidden_field_to_version'),
16+
]
17+
18+
operations = [
19+
migrations.RunPython(forwards_func),
20+
]

readthedocs/builds/models.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
MEDIA_TYPES,
7979
PRIVACY_CHOICES,
8080
SPHINX,
81+
SPHINX_HTMLDIR,
82+
SPHINX_SINGLEHTML,
8183
)
8284
from readthedocs.projects.models import APIProject, Project
8385
from readthedocs.projects.version_handling import determine_stable_version
@@ -136,6 +138,13 @@ class Version(models.Model):
136138
default=settings.DEFAULT_VERSION_PRIVACY_LEVEL,
137139
help_text=_('Level of privacy for this Version.'),
138140
)
141+
hidden = models.BooleanField(
142+
_('Hidden'),
143+
# To avoid downtime during deploy, remove later.
144+
null=True,
145+
default=False,
146+
help_text=_('Hide this version from the version (flyout) menu and search results?')
147+
)
139148
machine = models.BooleanField(_('Machine Created'), default=False)
140149

141150
# Whether the latest successful build for this version contains certain media types
@@ -361,6 +370,10 @@ def supports_wipe(self):
361370
"""Return True if version is not external."""
362371
return not self.type == EXTERNAL
363372

373+
@property
374+
def is_sphinx_type(self):
375+
return self.documentation_type in {SPHINX, SPHINX_HTMLDIR, SPHINX_SINGLEHTML}
376+
364377
def get_subdomain_url(self):
365378
external = self.type == EXTERNAL
366379
return self.project.get_docs_url(

readthedocs/builds/querysets.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ def _add_user_repos(self, queryset, user):
2424
queryset = user_queryset | queryset
2525
return queryset
2626

27-
def public(self, user=None, project=None, only_active=True):
27+
def public(self, user=None, project=None, only_active=True, include_hidden=True):
2828
queryset = self.filter(privacy_level=constants.PUBLIC)
2929
if user:
3030
queryset = self._add_user_repos(queryset, user)
3131
if project:
3232
queryset = queryset.filter(project=project)
3333
if only_active:
3434
queryset = queryset.filter(active=True)
35+
if not include_hidden:
36+
queryset = queryset.filter(hidden=False)
3537
return queryset.distinct()
3638

3739
def protected(self, user=None, project=None, only_active=True):

readthedocs/doc_builder/backends/mkdocs.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
import yaml
1212
from django.conf import settings
1313
from django.template import loader as template_loader
14-
from readthedocs.projects.constants import MKDOCS_HTML, MKDOCS
1514

1615
from readthedocs.doc_builder.base import BaseBuilder
1716
from readthedocs.doc_builder.exceptions import MkDocsYAMLParseError
17+
from readthedocs.projects.constants import MKDOCS, MKDOCS_HTML
1818
from readthedocs.projects.models import Feature
1919

2020

@@ -314,17 +314,12 @@ def get_theme_name(self, mkdocs_config):
314314

315315

316316
class MkdocsHTML(BaseMkdocs):
317+
317318
type = 'mkdocs'
318319
builder = 'build'
319320
build_dir = '_build/html'
320321

321322

322-
class MkdocsJSON(BaseMkdocs):
323-
type = 'mkdocs_json'
324-
builder = 'json'
325-
build_dir = '_build/json'
326-
327-
328323
class SafeLoaderIgnoreUnknown(yaml.SafeLoader): # pylint: disable=too-many-ancestors
329324

330325
"""

readthedocs/doc_builder/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
'memory': '7g',
5151
'time': 1800,
5252
})
53+
elif total_memory > 7000:
54+
# This is to catch AWS instances that actually only have 7.5G memory
55+
DOCKER_LIMITS.update({
56+
'memory': '6g',
57+
'time': 1800,
58+
})
5359
elif total_memory > 4000:
5460
DOCKER_LIMITS.update({
5561
'memory': '3g',

readthedocs/doc_builder/loader.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Lookup tables for builders and backends."""
42
from importlib import import_module
53

@@ -21,7 +19,6 @@
2119
'sphinx_singlehtmllocalmedia': sphinx.LocalMediaBuilder,
2220
# Other markup
2321
'mkdocs': mkdocs.MkdocsHTML,
24-
'mkdocs_json': mkdocs.MkdocsJSON,
2522
}
2623

2724

0 commit comments

Comments
 (0)