Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

integrations-docs: Move markdown macros include files.

Lauryn Menard5f9dc76d54ac
diff --git a/docs/documentation/integrations.md b/docs/documentation/integrations.md
index c544adf5aef..35376ec426b 100644
--- a/docs/documentation/integrations.md
+++ b/docs/documentation/integrations.md
@@ -64,7 +64,7 @@ phrases and steps at the location of the macros. Macros help eliminate
repeated content in our documentation.
The source for macros is the Markdown files under
-`templates/zerver/help/include` in the
+`templates/zerver/integrations/include/` in the
[main Zulip server repository](https://github.com/zulip/zulip). If you find
multiple instances of particular content in the documentation, you can
always create a new macro by adding a new file to that folder.
diff --git a/templates/zerver/help/include/append-stream-name.md b/templates/zerver/integrations/include/append-stream-name.md
similarity index 100%
rename from templates/zerver/help/include/append-stream-name.md
rename to templates/zerver/integrations/include/append-stream-name.md
diff --git a/templates/zerver/help/include/append-topic.md b/templates/zerver/integrations/include/append-topic.md
similarity index 100%
rename from templates/zerver/help/include/append-topic.md
rename to templates/zerver/integrations/include/append-topic.md
diff --git a/templates/zerver/help/include/change-zulip-config-file.md b/templates/zerver/integrations/include/change-zulip-config-file.md
similarity index 100%
rename from templates/zerver/help/include/change-zulip-config-file.md
rename to templates/zerver/integrations/include/change-zulip-config-file.md
diff --git a/templates/zerver/help/include/configure-matrix-bridge.md b/templates/zerver/integrations/include/configure-matrix-bridge.md
similarity index 100%
rename from templates/zerver/help/include/configure-matrix-bridge.md
rename to templates/zerver/integrations/include/configure-matrix-bridge.md
diff --git a/templates/zerver/help/include/congrats.md b/templates/zerver/integrations/include/congrats.md
similarity index 100%
rename from templates/zerver/help/include/congrats.md
rename to templates/zerver/integrations/include/congrats.md
diff --git a/templates/zerver/help/include/create-a-generic-bot.md b/templates/zerver/integrations/include/create-a-generic-bot.md
similarity index 100%
rename from templates/zerver/help/include/create-a-generic-bot.md
rename to templates/zerver/integrations/include/create-a-generic-bot.md
diff --git a/templates/zerver/help/include/create-an-incoming-webhook.md b/templates/zerver/integrations/include/create-an-incoming-webhook.md
similarity index 100%
rename from templates/zerver/help/include/create-an-incoming-webhook.md
rename to templates/zerver/integrations/include/create-an-incoming-webhook.md
diff --git a/templates/zerver/help/include/create-bot-construct-url.md b/templates/zerver/integrations/include/create-bot-construct-url.md
similarity index 100%
rename from templates/zerver/help/include/create-bot-construct-url.md
rename to templates/zerver/integrations/include/create-bot-construct-url.md
diff --git a/templates/zerver/help/include/create-stream.md b/templates/zerver/integrations/include/create-stream.md
similarity index 100%
rename from templates/zerver/help/include/create-stream.md
rename to templates/zerver/integrations/include/create-stream.md
diff --git a/templates/zerver/help/include/download-python-bindings.md b/templates/zerver/integrations/include/download-python-bindings.md
similarity index 100%
rename from templates/zerver/help/include/download-python-bindings.md
rename to templates/zerver/integrations/include/download-python-bindings.md
diff --git a/templates/zerver/help/include/event-filtering-instruction.md b/templates/zerver/integrations/include/event-filtering-instruction.md
similarity index 100%
rename from templates/zerver/help/include/event-filtering-instruction.md
rename to templates/zerver/integrations/include/event-filtering-instruction.md
diff --git a/templates/zerver/help/include/git-append-branches.md b/templates/zerver/integrations/include/git-append-branches.md
similarity index 100%
rename from templates/zerver/help/include/git-append-branches.md
rename to templates/zerver/integrations/include/git-append-branches.md
diff --git a/templates/zerver/help/include/git-webhook-url-with-branches.md b/templates/zerver/integrations/include/git-webhook-url-with-branches.md
similarity index 100%
rename from templates/zerver/help/include/git-webhook-url-with-branches.md
rename to templates/zerver/integrations/include/git-webhook-url-with-branches.md
diff --git a/templates/zerver/help/include/install-matrix.md b/templates/zerver/integrations/include/install-matrix.md
similarity index 100%
rename from templates/zerver/help/include/install-matrix.md
rename to templates/zerver/integrations/include/install-matrix.md
diff --git a/templates/zerver/help/include/webhook-url-with-bot-email.md b/templates/zerver/integrations/include/webhook-url-with-bot-email.md
similarity index 100%
rename from templates/zerver/help/include/webhook-url-with-bot-email.md
rename to templates/zerver/integrations/include/webhook-url-with-bot-email.md
diff --git a/templates/zerver/help/include/webhook-url.md b/templates/zerver/integrations/include/webhook-url.md
similarity index 100%
rename from templates/zerver/help/include/webhook-url.md
rename to templates/zerver/integrations/include/webhook-url.md
diff --git a/zerver/lib/templates.py b/zerver/lib/templates.py
index edd4560d859..354f8079e3a 100644
--- a/zerver/lib/templates.py
+++ b/zerver/lib/templates.py
@@ -83,7 +83,10 @@ docs_without_macros = [
@items_tuple_to_dict
@register.filter(name="render_markdown_path", is_safe=True)
def render_markdown_path(
- markdown_file_path: str, context: Optional[Dict[str, Any]] = None, pure_markdown: bool = False
+ markdown_file_path: str,
+ context: Optional[Dict[str, Any]] = None,
+ pure_markdown: bool = False,
+ integration_doc: bool = False,
) -> str:
"""Given a path to a Markdown file, return the rendered HTML.
@@ -127,10 +130,6 @@ def render_markdown_path(
zerver.lib.markdown.help_relative_links.makeExtension(),
zerver.lib.markdown.help_emoticon_translations_table.makeExtension(),
]
- if md_macro_extension is None:
- md_macro_extension = zerver.lib.markdown.include.makeExtension(
- base_path="templates/zerver/help/include/"
- )
if "api_url" in context:
# We need to generate the API code examples extension each
# time so the `api_url` config parameter can be set dynamically.
@@ -146,6 +145,14 @@ def render_markdown_path(
else:
extensions = md_extensions
+ if integration_doc:
+ md_macro_extension = zerver.lib.markdown.include.makeExtension(
+ base_path="templates/zerver/integrations/include/"
+ )
+ else:
+ md_macro_extension = zerver.lib.markdown.include.makeExtension(
+ base_path="templates/zerver/help/include/"
+ )
if not any(doc in markdown_file_path for doc in docs_without_macros):
extensions = [md_macro_extension, *extensions]
diff --git a/zerver/views/documentation.py b/zerver/views/documentation.py
index 4056f4e6233..7e2f06244fb 100644
--- a/zerver/views/documentation.py
+++ b/zerver/views/documentation.py
@@ -325,6 +325,6 @@ def integration_doc(request: HttpRequest, integration_name: str = REQ()) -> Http
if isinstance(integration, HubotIntegration):
context["hubot_docs_url"] = integration.hubot_docs_url
- doc_html_str = render_markdown_path(integration.doc, context)
+ doc_html_str = render_markdown_path(integration.doc, context, integration_doc=True)
return HttpResponse(doc_html_str)