mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
help: Remove current help center.
This commit removes the current help center markdown files and any logic that was used to host those files at help/. We also remove a bunch of tests, we should the equivalent of those tests for the new help center. Issues to track: #35649, #35647. These issues track adding back tests for redirects and broken links. We had a symlink from templates/zerver/integrations/email.md pointing to help/using-zulip-via-email.md. We can no longer have that symlink since the latter has been converted to an MDX file. We have deleted the symlink and put a markdown file in it's place. Both the files have comments to edit the other in case of changes. This commit also makes changes in astro config, astro component paths and other places to move the starlight help center docs base path from /starlight_help to /help. The change to rename /starlight_help/ to /help/ in MDX files is done in the next commit. If we squash these commits, this line should be removed. `./tools/build-help-center` no longer does the conversion step. We also remove some dead code related to the old help center in documentation.py.
This commit is contained in:
committed by
Tim Abbott
parent
40f723c75a
commit
d333ddb961
@@ -1,79 +0,0 @@
|
||||
import re
|
||||
from re import Match
|
||||
from typing import Any
|
||||
|
||||
from markdown import Markdown
|
||||
from markdown.extensions import Extension
|
||||
from markdown.preprocessors import Preprocessor
|
||||
from typing_extensions import override
|
||||
|
||||
from zerver.lib.emoji import EMOTICON_CONVERSIONS, name_to_codepoint
|
||||
from zerver.lib.markdown.priorities import PREPROCESSOR_PRIORITIES
|
||||
|
||||
REGEXP = re.compile(r"\{emoticon_translations\}")
|
||||
|
||||
TABLE_HTML = """\
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Emoticon</th>
|
||||
<th>Emoji</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{body}
|
||||
</tbody>
|
||||
</table>
|
||||
"""
|
||||
|
||||
ROW_HTML = """\
|
||||
<tr>
|
||||
<td><code>{emoticon}</code></td>
|
||||
<td>
|
||||
<img
|
||||
src="/static/generated/emoji/images-google-64/{codepoint}.png"
|
||||
alt="{name}"
|
||||
class="emoji-big">
|
||||
</td>
|
||||
</tr>
|
||||
"""
|
||||
|
||||
|
||||
class EmoticonTranslationsHelpExtension(Extension):
|
||||
@override
|
||||
def extendMarkdown(self, md: Markdown) -> None:
|
||||
"""Add SettingHelpExtension to the Markdown instance."""
|
||||
md.registerExtension(self)
|
||||
md.preprocessors.register(
|
||||
EmoticonTranslation(),
|
||||
"emoticon_translations",
|
||||
PREPROCESSOR_PRIORITIES["emoticon_translations"],
|
||||
)
|
||||
|
||||
|
||||
class EmoticonTranslation(Preprocessor):
|
||||
@override
|
||||
def run(self, lines: list[str]) -> list[str]: # nocoverage
|
||||
for loc, line in enumerate(lines):
|
||||
match = REGEXP.search(line)
|
||||
if match:
|
||||
text = self.handleMatch(match)
|
||||
lines = lines[:loc] + text + lines[loc + 1 :]
|
||||
break
|
||||
return lines
|
||||
|
||||
def handleMatch(self, match: Match[str]) -> list[str]: # nocoverage
|
||||
rows = [
|
||||
ROW_HTML.format(
|
||||
emoticon=emoticon,
|
||||
name=name.strip(":"),
|
||||
codepoint=name_to_codepoint[name.strip(":")],
|
||||
)
|
||||
for emoticon, name in EMOTICON_CONVERSIONS.items()
|
||||
]
|
||||
body = "".join(rows).strip()
|
||||
return TABLE_HTML.format(body=body).strip().splitlines()
|
||||
|
||||
|
||||
def makeExtension(*args: Any, **kwargs: Any) -> EmoticonTranslationsHelpExtension:
|
||||
return EmoticonTranslationsHelpExtension(*args, **kwargs)
|
||||
@@ -135,7 +135,7 @@ def getMarkdown(setting_type_name: str, setting_name: str, setting_link: str) ->
|
||||
return f"1. Navigate to the {relative_link} \
|
||||
tab of the **{setting_type_name}** menu."
|
||||
return f"1. Go to {relative_link}."
|
||||
return settings_markdown.format(
|
||||
return settings_markdown.format( # nocoverage
|
||||
setting_type_name=setting_type_name,
|
||||
setting_reference=f"**{setting_name}**",
|
||||
)
|
||||
|
||||
@@ -18,7 +18,6 @@ from markupsafe import Markup
|
||||
import zerver.lib.markdown.api_arguments_table_generator
|
||||
import zerver.lib.markdown.api_return_values_table_generator
|
||||
import zerver.lib.markdown.fenced_code
|
||||
import zerver.lib.markdown.help_emoticon_translations_table
|
||||
import zerver.lib.markdown.help_relative_links
|
||||
import zerver.lib.markdown.help_settings_links
|
||||
import zerver.lib.markdown.include
|
||||
@@ -143,7 +142,6 @@ def render_markdown_path(
|
||||
zerver.lib.markdown.tabbed_sections.makeExtension(),
|
||||
zerver.lib.markdown.help_settings_links.makeExtension(),
|
||||
zerver.lib.markdown.help_relative_links.makeExtension(),
|
||||
zerver.lib.markdown.help_emoticon_translations_table.makeExtension(),
|
||||
zerver.lib.markdown.static.makeExtension(),
|
||||
]
|
||||
if context is not None and "api_url" in context:
|
||||
|
||||
@@ -90,7 +90,6 @@ sidebar_links = XPath("//a[@href=$url]")
|
||||
class MarkdownDirectoryView(ApiURLView):
|
||||
path_template = ""
|
||||
policies_view = False
|
||||
help_view = False
|
||||
api_doc_view = False
|
||||
|
||||
def __init__(self, **kwargs: Any) -> None:
|
||||
@@ -106,26 +105,22 @@ class MarkdownDirectoryView(ApiURLView):
|
||||
http_status = 200
|
||||
if article == "":
|
||||
article = "index"
|
||||
# Only help center has this article nested inside an include,
|
||||
# after switching to the new help center, we should remove this
|
||||
# elif block.
|
||||
elif article == "include/sidebar_index": # nocoverage.
|
||||
pass
|
||||
elif article == "api-doc-template":
|
||||
# This markdown template shouldn't be accessed directly.
|
||||
article = "missing"
|
||||
http_status = 404
|
||||
# Only help center allows nested paths in urls.py, once we
|
||||
# remove that help center url declaration in urls.py after
|
||||
# switching to the new help center, we should remove this elif
|
||||
# block altogether since api docs and policies only allow slugs
|
||||
# which cannot have nested paths.
|
||||
# This was earlier checked when we we were using path for the
|
||||
# /help view. If we later add some view like /policies that
|
||||
# incorrectly uses a path section rather than a slug in
|
||||
# urls.py, removing this layer of defense against / being
|
||||
# present in article could turn that from being an irrelevant
|
||||
# mistake into a security vulnerability.
|
||||
elif "/" in article: # nocoverage
|
||||
article = "missing"
|
||||
http_status = 404
|
||||
elif len(article) > 100 or not re.match(r"^[0-9a-zA-Z_-]+$", article):
|
||||
article = "missing"
|
||||
http_status = 404
|
||||
article = "missing" # nocoverage
|
||||
http_status = 404 # nocoverage
|
||||
|
||||
path = self.path_template % (article,)
|
||||
endpoint_name = None
|
||||
@@ -165,7 +160,7 @@ class MarkdownDirectoryView(ApiURLView):
|
||||
endpoint_path=None,
|
||||
endpoint_method=None,
|
||||
)
|
||||
elif self.help_view or self.policies_view:
|
||||
elif self.policies_view:
|
||||
article = "missing"
|
||||
http_status = 404
|
||||
path = self.path_template % (article,)
|
||||
@@ -199,17 +194,7 @@ class MarkdownDirectoryView(ApiURLView):
|
||||
settings.DEPLOY_ROOT, "templates", documentation_article.article_path
|
||||
)
|
||||
|
||||
# The nocoverage blocks here are very temporary since this
|
||||
# whole block will be removed once we switch to the new help
|
||||
# center.
|
||||
if self.help_view: # nocoverage
|
||||
context["page_is_help_center"] = True
|
||||
context["doc_root"] = "/help/"
|
||||
context["doc_root_title"] = "Help center"
|
||||
sidebar_article = self.get_path("include/sidebar_index")
|
||||
sidebar_index = sidebar_article.article_path
|
||||
title_base = "Zulip help center"
|
||||
elif self.policies_view:
|
||||
if self.policies_view:
|
||||
context["page_is_policy_center"] = True
|
||||
context["doc_root"] = "/policies/"
|
||||
context["doc_root_title"] = "Terms and policies"
|
||||
|
||||
Reference in New Issue
Block a user