Skip to content

Commit cf97522

Browse files
committed
Add feature flag
1 parent dc383d6 commit cf97522

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

readthedocs/doc_builder/backends/sphinx.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,22 @@ def get_config_params(self):
113113

114114
# Avoid hitting database and API if using Docker build environment
115115
if settings.DONT_HIT_API:
116-
versions = self.project.active_versions().filter(
117-
privacy_level=PUBLIC,
118-
)
116+
if self.project.has_feature(Feature.ALL_VERSIONS_IN_HTML_CONTEXT):
117+
versions = self.project.active_versions()
118+
else:
119+
versions = self.project.active_versions().filter(
120+
privacy_level=PUBLIC,
121+
)
119122
downloads = self.version.get_downloads(pretty=True)
120123
else:
121-
versions = [
122-
v
123-
for v in self.project.api_versions()
124-
if v.privacy_level == PUBLIC
125-
]
124+
if self.project.has_feature(Feature.ALL_VERSIONS_IN_HTML_CONTEXT):
125+
versions = self.project.api_versions()
126+
else:
127+
versions = [
128+
v
129+
for v in self.project.api_versions()
130+
if v.privacy_level == PUBLIC
131+
]
126132
downloads = api.version(self.version.pk).get()['downloads']
127133

128134
data = {

readthedocs/projects/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,7 @@ def add_features(sender, **kwargs):
14791479
EXTERNAL_VERSION_BUILD = 'external_version_build'
14801480
UPDATE_CONDA_STARTUP = 'update_conda_startup'
14811481
CONDA_APPEND_CORE_REQUIREMENTS = 'conda_append_core_requirements'
1482+
ALL_VERSIONS_IN_HTML_CONTEXT = 'all_versions_in_html_context'
14821483

14831484
FEATURES = (
14841485
(USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
@@ -1530,7 +1531,10 @@ def add_features(sender, **kwargs):
15301531
CONDA_APPEND_CORE_REQUIREMENTS,
15311532
_('Append Read the Docs core requirements to environment.yml file'),
15321533
),
1533-
1534+
(
1535+
ALL_VERSIONS_IN_HTML_CONTEXT,
1536+
_('Pass all versions (including private) into the html context when building with Sphinx'),
1537+
),
15341538
)
15351539

15361540
projects = models.ManyToManyField(

0 commit comments

Comments
 (0)