mirror of
https://github.com/zulip/zulip.git
synced 2025-10-25 00:53:56 +00:00
help_settings_links: Refactor handleMatch function.
This code needs to be more flexible to improve the documentation
of items in the Personal and Organization settings menu when
using the `{settings_tab|[setting-name]}` Markdownm macro that
provides relative links or step-by-step instructions.
This commit moves the Markdown formatting code to a new function that
receives tuples from `link_mapping` as input. This is a preliminary
step to offer more flexibility than the current approach.
This commit is contained in:
@@ -115,6 +115,15 @@ settings_markdown = """
|
||||
"""
|
||||
|
||||
|
||||
def getMarkdown(setting_type_name: str, setting_name: str, setting_link: str) -> str:
|
||||
if relative_settings_links:
|
||||
return f"1. Go to [{setting_name}]({setting_link})."
|
||||
return settings_markdown.format(
|
||||
setting_type_name=setting_type_name,
|
||||
setting_reference=f"**{setting_name}**",
|
||||
)
|
||||
|
||||
|
||||
class SettingHelpExtension(Extension):
|
||||
def extendMarkdown(self, md: Markdown) -> None:
|
||||
"""Add SettingHelpExtension to the Markdown instance."""
|
||||
@@ -156,15 +165,7 @@ class Setting(Preprocessor):
|
||||
|
||||
def handleMatch(self, match: Match[str]) -> str:
|
||||
setting_identifier = match.group("setting_identifier")
|
||||
setting_type_name = link_mapping[setting_identifier][0]
|
||||
setting_name = link_mapping[setting_identifier][1]
|
||||
setting_link = link_mapping[setting_identifier][2]
|
||||
if relative_settings_links:
|
||||
return f"1. Go to [{setting_name}]({setting_link})."
|
||||
return settings_markdown.format(
|
||||
setting_type_name=setting_type_name,
|
||||
setting_reference=f"**{setting_name}**",
|
||||
)
|
||||
return getMarkdown(*link_mapping[setting_identifier])
|
||||
|
||||
|
||||
def makeExtension(*args: Any, **kwargs: Any) -> SettingHelpExtension:
|
||||
|
||||
Reference in New Issue
Block a user