Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions readthedocs/api/v2/views/footer_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) + '/'
Expand Down
11 changes: 6 additions & 5 deletions readthedocs/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand Down
8 changes: 0 additions & 8 deletions readthedocs/doc_builder/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions readthedocs/embed/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
31 changes: 3 additions & 28 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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,
_(
Expand Down
1 change: 1 addition & 0 deletions readthedocs/search/api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion readthedocs/search/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 7 additions & 8 deletions readthedocs/telemetry/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}

Expand Down Expand Up @@ -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 = {
Expand All @@ -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

Expand Down