integrations: Add new file for fixtureless screenshot configs registry.

This does not include any screenshot configs, just defining the format,
and loading FIXTURELESS_SCREENSHOT_CONFIG from the file.

Co-authored-by: Lauryn Menard <lauryn@zulip.com>
This commit is contained in:
Niloth P
2025-07-22 04:13:41 +05:30
committed by Tim Abbott
parent aed6d37ecd
commit c7a6fcaf88
3 changed files with 36 additions and 4 deletions

View File

@@ -54,10 +54,16 @@ Typically, the documentation process involves the following steps:
generate a screenshot of the message to provide an example message in the
integration's documentation.
If your new integration is an incoming webhook integration, you can
generate the screenshot using
`tools/screenshots/generate-integration-docs-screenshot`, where
`integrationname` is the name of the integration:
If your new integration is not a webhook and does not have fixtures, add a
message template and topic to `zerver/webhooks/fixtureless_integrations.py`.
Then, add your integration's name to `FIXTURELESS_INTEGRATIONS_WITH_SCREENSHOTS`
in `zerver/lib/integrations.py`.
Otherwise, you should have already added your integration to
`WEBHOOK_SCREENSHOT_CONFIG`.
Generate the screenshot using `tools/screenshots/generate-integration-docs-screenshot`,
where `integrationname` is the name of the integration:
```bash
./tools/screenshots/generate-integration-docs-screenshot --integration integrationname

View File

@@ -14,6 +14,7 @@ from django_stubs_ext import StrPromise
from zerver.lib.storage import static_path
from zerver.lib.validator import check_bool
from zerver.lib.webhooks.common import PresetUrlOption, WebhookConfigOption, WebhookUrlOption
from zerver.webhooks import fixtureless_integrations
"""This module declares all of the (documented) integrations available
in the Zulip server. The Integration class is used as part of
@@ -60,6 +61,15 @@ CATEGORIES: dict[str, StrPromise] = {
"version-control": gettext_lazy("Version control"),
}
# Can also be computed from INTEGRATIONS by removing entries from
# WEBHOOK_INTEGRATIONS and NO_SCREENSHOT_CONFIG, but defined explicitly to
# avoid circular dependency
FIXTURELESS_INTEGRATIONS_WITH_SCREENSHOTS: list[str] = []
FIXTURELESS_SCREENSHOT_CONTENT: dict[str, list[fixtureless_integrations.ScreenshotContent]] = {
key: [getattr(fixtureless_integrations, key.upper().replace("-", "_"))]
for key in FIXTURELESS_INTEGRATIONS_WITH_SCREENSHOTS
}
class Integration:
DEFAULT_LOGO_STATIC_PATH_PNG = "images/integrations/logos/{name}.png"
@@ -846,6 +856,11 @@ WEBHOOK_SCREENSHOT_CONFIG: dict[str, list[WebhookScreenshotConfig]] = {
}
FIXTURELESS_SCREENSHOT_CONFIG: dict[str, list[FixturelessScreenshotConfig]] = {}
for integration, screenshots_contents in FIXTURELESS_SCREENSHOT_CONTENT.items():
FIXTURELESS_SCREENSHOT_CONFIG[integration] = [
FixturelessScreenshotConfig(screenshot_content["content"], screenshot_content["topic"])
for screenshot_content in screenshots_contents
]
DOC_SCREENSHOT_CONFIG: dict[
str, list[WebhookScreenshotConfig] | list[FixturelessScreenshotConfig]

View File

@@ -0,0 +1,11 @@
from typing import TypedDict
# For integrations that don't have example webhook fixtures/payloads,
# we create an Zulip notification message content and topic here in
# order to generate an example screenshot to include in the documentation
# page for those integrations.
class ScreenshotContent(TypedDict):
topic: str
content: str