diff --git a/readthedocs/api/v2/views/footer_views.py b/readthedocs/api/v2/views/footer_views.py index e5f78ffdf0b..a513a05e287 100644 --- a/readthedocs/api/v2/views/footer_views.py +++ b/readthedocs/api/v2/views/footer_views.py @@ -155,6 +155,7 @@ def _get_context(self): page_slug = self.request.GET.get('page', '') path = '' + # TODO: review custom logic based con `documentation_type` if page_slug and page_slug != 'index': if version.documentation_type in {SPHINX_HTMLDIR, MKDOCS}: path = re.sub('/index$', '', page_slug) + '/' diff --git a/readthedocs/builds/models.py b/readthedocs/builds/models.py index 8a092a6173a..1e589ed5304 100644 --- a/readthedocs/builds/models.py +++ b/readthedocs/builds/models.py @@ -352,7 +352,7 @@ def commit_name(self): # By now we must have handled all special versions. if self.slug in NON_REPOSITORY_VERSIONS: - raise Exception('All special versions must be handled by now.') + raise Exception("All special versions must be handled by now.") # noqa if self.type in (BRANCH, TAG): # If this version is a branch or a tag, the verbose_name will @@ -407,7 +407,7 @@ def get_absolute_url(self): external=external, ) - def delete(self, *args, **kwargs): # pylint: disable=arguments-differ + def delete(self, *args, **kwargs): from readthedocs.projects.tasks.utils import clean_project_resources log.info('Removing files for version.', version_slug=self.slug) clean_project_resources(self.project, self) @@ -475,6 +475,8 @@ def is_editable(self): @property def is_sphinx_type(self): + # TODO: this method should no be required anymore. + # I'm not removing it yet because there may be places still using it. return self.documentation_type in {SPHINX, SPHINX_HTMLDIR, SPHINX_SINGLEHTML} @property @@ -699,7 +701,7 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **valid_attributes) - def save(self, *args, **kwargs): # pylint: disable=arguments-differ + def save(self, *args, **kwargs): return 0 @@ -1378,7 +1380,7 @@ def move(self, steps): self.save() return True - def delete(self, *args, **kwargs): # pylint: disable=arguments-differ + def delete(self, *args, **kwargs): """Override method to update the other priorities after delete.""" current_priority = self.priority project = self.project @@ -1473,7 +1475,6 @@ def get_edit_url(self): class AutomationRuleMatch(TimeStampedModel): - ACTIONS_PAST_TENSE = { VersionAutomationRule.ACTIVATE_VERSION_ACTION: _("Version activated"), VersionAutomationRule.HIDE_VERSION_ACTION: _("Version hidden"), diff --git a/readthedocs/doc_builder/director.py b/readthedocs/doc_builder/director.py index a6e4d3169a0..36b1595c8cd 100644 --- a/readthedocs/doc_builder/director.py +++ b/readthedocs/doc_builder/director.py @@ -441,10 +441,6 @@ def run_build_commands(self): if not os.path.exists(html_output_path): raise BuildUserError(BuildUserError.BUILD_COMMANDS_WITHOUT_OUTPUT) - # Update the `Version.documentation_type` to match the doctype defined - # by the config file. When using `build.commands` it will be `GENERIC` - self.data.version.documentation_type = self.data.config.doctype - # Mark this version to inject the new js client when serving it via El Proxito self.data.version.addons = True @@ -696,10 +692,6 @@ def get_build_env_vars(self): return env - def is_type_sphinx(self): - """Is documentation type Sphinx.""" - return "sphinx" in self.data.config.doctype - def store_readthedocs_build_yaml(self): # load YAML from user yaml_path = os.path.join( diff --git a/readthedocs/embed/views.py b/readthedocs/embed/views.py index 98c3535881b..7ea43dba47f 100644 --- a/readthedocs/embed/views.py +++ b/readthedocs/embed/views.py @@ -145,6 +145,11 @@ def do_embed(*, project, version, doc=None, path=None, section=None, url=None): content = None headers = None + # TODO: EmbedAPI v1 is already deprecated and shouldn't be used. + # So, we may be able to remove the endpoint completely, together with the usage of + # `is_sphinx_type` as well :) + # It's disabled on commercial already. We should check the stats on Cloudflare/NewRelic + # looking for EmbedAPI v1 and decide what to do depending on usage. if version.is_sphinx_type: file_content = _get_doc_content( project=project, diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index 42287cadc61..c4c2ede4dd9 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -51,7 +51,7 @@ validate_repository_url, ) from readthedocs.projects.version_handling import determine_stable_version -from readthedocs.search.parsers import GenericParser, MkDocsParser, SphinxParser +from readthedocs.search.parsers import GenericParser from readthedocs.storage import build_media_storage from readthedocs.vcs_support.backends import backend_cls @@ -1525,24 +1525,8 @@ class Meta: objects = HTMLFileManager() def get_processed_json(self): - if ( - self.version.documentation_type == constants.GENERIC - or self.project.has_feature(Feature.INDEX_FROM_HTML_FILES) - ): - parser_class = GenericParser - elif self.version.is_sphinx_type: - parser_class = SphinxParser - elif self.version.is_mkdocs_type: - parser_class = MkDocsParser - else: - log.warning( - "Invalid documentation type", - documentation_type=self.version.documentation_type, - version_slug=self.version.slug, - project_slug=self.project.slug, - ) - return {} - parser = parser_class(self.version) + # See https://github.com/readthedocs/readthedocs.org/issues/10272 + parser = GenericParser(self.version) return parser.parse(self.path) @cached_property @@ -1934,7 +1918,6 @@ def add_features(sender, **kwargs): DISABLE_SERVER_SIDE_SEARCH = 'disable_server_side_search' ENABLE_MKDOCS_SERVER_SIDE_SEARCH = 'enable_mkdocs_server_side_search' DEFAULT_TO_FUZZY_SEARCH = 'default_to_fuzzy_search' - INDEX_FROM_HTML_FILES = 'index_from_html_files' # Build related features DONT_CREATE_INDEX = "dont_create_index" @@ -2054,14 +2037,6 @@ def add_features(sender, **kwargs): DEFAULT_TO_FUZZY_SEARCH, _("Search: Default to fuzzy search for simple search queries"), ), - ( - INDEX_FROM_HTML_FILES, - _( - "Search: Index content directly from html files instead or relying in other " - "sources" - ), - ), - ( DONT_CREATE_INDEX, _( diff --git a/readthedocs/search/api/v2/serializers.py b/readthedocs/search/api/v2/serializers.py index 534fd22ace2..12b72ccbfa7 100644 --- a/readthedocs/search/api/v2/serializers.py +++ b/readthedocs/search/api/v2/serializers.py @@ -145,6 +145,7 @@ def _get_full_path(self, obj): docs_url = project_data.version.docs_url path = obj.full_path + # TODO: review this logic that uses doctype # Generate an appropriate link for the doctypes that use htmldir, # and always end it with / so it goes directly to proxito. # For a generic doctype we just strip the index.html part if it exists. diff --git a/readthedocs/search/documents.py b/readthedocs/search/documents.py index 5968fb87826..1fa9f36b208 100644 --- a/readthedocs/search/documents.py +++ b/readthedocs/search/documents.py @@ -85,7 +85,6 @@ class PageDocument(RTDDocTypeMixin, Document): # Metadata project = fields.KeywordField(attr='project.slug') version = fields.KeywordField(attr='version.slug') - doctype = fields.KeywordField(attr='version.documentation_type') path = fields.KeywordField(attr='processed_json.path') full_path = fields.KeywordField(attr='path') rank = fields.IntegerField() diff --git a/readthedocs/telemetry/collectors.py b/readthedocs/telemetry/collectors.py index af1202d0cdd..0c1484e7ac4 100644 --- a/readthedocs/telemetry/collectors.py +++ b/readthedocs/telemetry/collectors.py @@ -36,7 +36,7 @@ def __init__(self, environment): @staticmethod def _safe_json_loads(content, default=None): - def lowercase(d): # pylint: disable=invalid-name + def lowercase(d): """Convert all dictionary keys to lowercase.""" return {k.lower(): i for k, i in d.items()} @@ -96,13 +96,9 @@ def collect(self): return data def _get_doctool_name(self): - if self.version.is_sphinx_type: - return "sphinx" - - if self.version.is_mkdocs_type: - return "mkdocs" - - return "generic" + # TODO: this data should be communicated from the builder itself homehow. + # This is a place where the build contract could be useful. + return "unknown" def _get_doctool(self): data = { @@ -111,6 +107,9 @@ def _get_doctool(self): "html_theme": "", } + # TODO: adapt this logic to work with a generic builder. This requires + # a build contract that explains how to create the JSON file we are + # expecting at this point if self._get_doctool_name() != "sphinx": return data