Skip to content

Commit 422f919

Browse files
committed
Add feature flags to disable server side search
1 parent 9802ad0 commit 422f919

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

readthedocs/doc_builder/backends/mkdocs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ def generate_rtd_data(self, docs_dir, mkdocs_config):
253253
'commit': self.version.project.vcs_repo(self.version.slug).commit,
254254
'global_analytics_code': settings.GLOBAL_ANALYTICS_CODE,
255255
'user_analytics_code': analytics_code,
256+
'features': {
257+
'docsearch_disabled': (
258+
self.project.has_feature(Feature.DISABLE_SERVER_SIDE_SEARCH)
259+
and not self.project.has_feature(Feature.ENABLE_MKDOCS_SERVER_SIDE_SEARCH)
260+
)
261+
},
256262
}
257263

258264
data_ctx = {

readthedocs/doc_builder/backends/sphinx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def get_config_params(self):
181181
'dont_overwrite_sphinx_context': self.project.has_feature(
182182
Feature.DONT_OVERWRITE_SPHINX_CONTEXT,
183183
),
184+
'docsearch_disabled': self.project.has_feature(Feature.DISABLE_SERVER_SIDE_SEARCH),
184185
}
185186

186187
finalize_sphinx_context_data.send(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ context = {
113113
'new_theme': (html_theme == "sphinx_rtd_theme"),
114114
'source_suffix': SUFFIX,
115115
'ad_free': {% if project.show_advertising %}False{% else %}True{% endif %},
116+
'docsearch_disabled': {{ docsearch_disabled }},
116117
'user_analytics_code': '{{ project.analytics_code|default_if_none:'' }}',
117118
'global_analytics_code': '{{ settings.GLOBAL_ANALYTICS_CODE }}',
118119
'commit': {% if project.repo_type == 'git' %}'{{ commit|slice:"8" }}'{% else %}'{{ commit }}'{% endif %},

readthedocs/projects/models.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,8 @@ def add_features(sender, **kwargs):
15841584
CACHED_ENVIRONMENT = 'cached_environment'
15851585
CELERY_ROUTER = 'celery_router'
15861586
LIMIT_CONCURRENT_BUILDS = 'limit_concurrent_builds'
1587+
DISABLE_SERVER_SIDE_SEARCH = 'disable_server_side_search'
1588+
ENABLE_MKDOCS_SERVER_SIDE_SEARCH = 'enable_mkdocs_server_side_search'
15871589

15881590
FEATURES = (
15891591
(USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
@@ -1662,7 +1664,15 @@ def add_features(sender, **kwargs):
16621664
LIMIT_CONCURRENT_BUILDS,
16631665
_('Limit the amount of concurrent builds'),
16641666
),
1665-
)
1667+
(
1668+
DISABLE_SERVER_SIDE_SEARCH,
1669+
_('Disable server side search'),
1670+
),
1671+
(
1672+
ENABLE_MKDOCS_SERVER_SIDE_SEARCH,
1673+
_('Enable server side search for MkDocs projects'),
1674+
),
1675+
),
16661676

16671677
projects = models.ManyToManyField(
16681678
Project,

0 commit comments

Comments
 (0)