2017-06-30 07:05:29 +02:00
|
|
|
|
# Documenting an integration
|
|
|
|
|
|
2021-05-07 02:38:07 +02:00
|
|
|
|
In order for a [Zulip
|
|
|
|
|
integration](https://zulip.com/api/integrations-overview) to be useful
|
|
|
|
|
to users, it must be documented. Zulip's common system for documenting
|
|
|
|
|
integrations involves writing Markdown files, either at
|
|
|
|
|
`zerver/webhooks/{webhook_name}/doc.md` (for webhook integrations) or
|
|
|
|
|
`templates/zerver/integrations/{integration_name}.md` (for other
|
2017-06-30 07:05:29 +02:00
|
|
|
|
integrations).
|
|
|
|
|
|
|
|
|
|
Usually, this involves a few steps:
|
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- Add text explaining all of the steps required to set up the
|
2018-05-15 01:45:00 +02:00
|
|
|
|
integration, including what URLs to use, etc. See
|
|
|
|
|
[Writing guidelines](#writing-guidelines) for detailed writing guidelines.
|
|
|
|
|
|
|
|
|
|
Zulip's pre-defined Markdown macros can be used for some of these steps.
|
|
|
|
|
See [Markdown macros](#markdown-macros) for further details.
|
2017-06-30 07:05:29 +02:00
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- Make sure you've added your integration to
|
2021-03-28 01:18:10 +01:00
|
|
|
|
`zerver/lib/integrations.py` in both the `WEBHOOK_INTEGRATIONS`
|
|
|
|
|
section (or `INTEGRATIONS` if not a webhook), and the
|
2021-08-20 21:53:28 +02:00
|
|
|
|
`DOC_SCREENSHOT_CONFIG` sections. These registries configure your
|
2021-03-28 01:18:10 +01:00
|
|
|
|
integration to appear on the `/integrations` page and make it
|
|
|
|
|
possible to automatically generate the screenshot of a sample
|
|
|
|
|
message (which is important for the screenshots to be updated as
|
|
|
|
|
Zulip's design changes).
|
2017-06-30 07:05:29 +02:00
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- You'll need to add an SVG graphic
|
2017-06-30 07:05:29 +02:00
|
|
|
|
of your integration's logo under the
|
|
|
|
|
`static/images/integrations/logos/<name>.svg`, where `<name>` is the
|
|
|
|
|
name of the integration, all in lower case; you can usually find them in the
|
|
|
|
|
product branding or press page. Make sure to optimize the SVG graphic by
|
2021-04-16 23:33:35 +02:00
|
|
|
|
running `tools/setup/optimize-svg`. This will also run
|
|
|
|
|
`tools/setup/generate_integration_bots_avatars.py` automatically to generate
|
|
|
|
|
a smaller version of the image you just added and optimized. This smaller image will be
|
|
|
|
|
used as the bot avatar in the documentation screenshot that will be generated
|
|
|
|
|
in the next step.
|
2017-06-30 07:05:29 +02:00
|
|
|
|
|
2021-04-13 18:04:31 +02:00
|
|
|
|
If you cannot find an SVG graphic of the logo, please find and include a PNG
|
2017-06-30 07:05:29 +02:00
|
|
|
|
image of the logo instead.
|
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- Finally, generate a message sent by the integration and take a screenshot of
|
2020-05-11 19:52:50 +02:00
|
|
|
|
the message to provide an example message in the documentation.
|
2017-06-30 07:05:29 +02:00
|
|
|
|
|
2020-04-17 11:46:02 +02:00
|
|
|
|
If your new integration is an incoming webhook integration, you can generate
|
|
|
|
|
the screenshot using `tools/generate-integration-docs-screenshot`:
|
2017-06-30 07:05:29 +02:00
|
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
|
```bash
|
2021-03-28 01:18:10 +01:00
|
|
|
|
./tools/generate-integration-docs-screenshot --integration integrationname
|
2020-04-17 11:46:02 +02:00
|
|
|
|
```
|
2017-06-30 07:05:29 +02:00
|
|
|
|
|
2020-04-17 11:49:02 +02:00
|
|
|
|
If you have trouble using this tool, you can also manually generate the
|
2021-03-28 01:18:10 +01:00
|
|
|
|
screenshot using `manage.py send_webhook_fixture_message`. When generating the
|
2020-04-17 11:49:02 +02:00
|
|
|
|
screenshot of a sample message using this method, give your test bot a nice
|
|
|
|
|
name like "GitHub Bot", use the project's logo as the bot's avatar, and take
|
|
|
|
|
the screenshot showing the stream/topic bar for the message, not just the
|
|
|
|
|
message body.
|
|
|
|
|
|
2017-06-30 07:05:29 +02:00
|
|
|
|
## Markdown macros
|
|
|
|
|
|
|
|
|
|
**Macros** are elements in the format of `{!macro.md!}` that insert common
|
|
|
|
|
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
|
2022-12-07 19:43:49 +01:00
|
|
|
|
`templates/zerver/integrations/include/` in the
|
2017-06-30 07:05:29 +02:00
|
|
|
|
[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.
|
|
|
|
|
|
|
|
|
|
Here are a few common macros used to document Zulip's integrations:
|
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- `{!create-stream.md!}` macro - Recommends that users create a dedicated
|
2021-04-13 18:04:31 +02:00
|
|
|
|
stream for a given integration. Usually the first step is setting up an
|
2018-05-31 01:56:18 +02:00
|
|
|
|
integration or incoming webhook. For an example rendering, see **Step 1** of
|
2021-08-21 00:03:43 +02:00
|
|
|
|
[the docs for Zulip's GitHub integration][github-integration].
|
2018-05-15 00:44:08 +02:00
|
|
|
|
|
2022-09-09 03:24:32 +02:00
|
|
|
|
- `{!create-an-incoming-webhook.md!}` macro - Instructs users to create a bot
|
|
|
|
|
for a given integration and select **Incoming webhook** as the **Bot type**.
|
|
|
|
|
This macro is usually used right after `{!create-stream!}`. For an example
|
|
|
|
|
rendering, see **Step 2** of [the docs for Zulip's Zendesk integration][zendesk].
|
|
|
|
|
|
|
|
|
|
- `{!create-a-generic-bot.md!}` macro - Instructs users to create a bot
|
|
|
|
|
for a given integration and select **Generic bot** as the **Bot type**. For an
|
|
|
|
|
example rendering, see [the docs for Zulip's Matrix integration][matrix].
|
|
|
|
|
|
2022-06-26 02:38:55 +02:00
|
|
|
|
- `{!create-bot-construct-url.md!}` macro - Instructs users to create a bot
|
2022-09-09 03:24:32 +02:00
|
|
|
|
for a given integration and select **Incoming webhook** as the **Bot type**.
|
|
|
|
|
The URL is generated automatically for every incoming webhook by using
|
|
|
|
|
attributes in the `WebhookIntegration` class in [zerver/lib/integrations.py][integrations-file].
|
2018-05-15 00:44:08 +02:00
|
|
|
|
This macro is usually used right after `{!create-stream!}`. For an example
|
2021-08-21 00:03:43 +02:00
|
|
|
|
rendering, see **Step 2** of [the docs for Zulip's GitHub integration][github-integration].
|
2017-11-22 17:33:52 +01:00
|
|
|
|
|
2021-08-20 22:54:08 +02:00
|
|
|
|
**Note:** If special configuration is
|
|
|
|
|
required to set up the URL and you can't use this macro, be sure to use the
|
|
|
|
|
`{{ api_url }}` template variable, so that your integration
|
|
|
|
|
documentation will provide the correct URL for whatever server it is
|
|
|
|
|
deployed on. If special configuration is required to set the `SITE`
|
|
|
|
|
variable, you should document that too.
|
2017-06-30 07:05:29 +02:00
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- `{!append-stream-name.md!}` macro - Recommends appending `&stream=stream_name`
|
2018-05-15 00:44:08 +02:00
|
|
|
|
to a URL in cases where supplying a stream name in the URL is optional.
|
|
|
|
|
Supplying a stream name is optional for most Zulip integrations. If you use
|
2022-06-26 02:38:55 +02:00
|
|
|
|
`{!create-bot-construct-url.md!}`, this macro need not be used.
|
2018-05-15 00:44:08 +02:00
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- `{!append-topic.md!}` macro - Recommends appending `&topic=my_topic` to a URL
|
2018-05-15 00:44:08 +02:00
|
|
|
|
to supply a custom topic for webhook notification messages. Supplying a custom
|
|
|
|
|
topic is optional for most Zulip integrations. If you use
|
2022-06-26 02:38:55 +02:00
|
|
|
|
`{!create-bot-construct-url.md!}`, this macro need not be used.
|
2018-05-15 00:44:08 +02:00
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- `{!congrats.md!}` macro - Inserts congratulatory lines signifying the
|
2018-05-15 00:44:08 +02:00
|
|
|
|
successful setup of a given integration. This macro is usually used at
|
|
|
|
|
the end of the documentation, right before the sample message screenshot.
|
|
|
|
|
For an example rendering, see the end of
|
2021-08-21 00:03:43 +02:00
|
|
|
|
[the docs for Zulip's GitHub integration][github-integration].
|
2018-05-15 00:44:08 +02:00
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- `{!download-python-bindings.md!}` macro - Links to Zulip's
|
2020-06-08 23:04:39 +02:00
|
|
|
|
[API page](https://zulip.com/api/) to download and install Zulip's
|
2018-05-15 00:44:08 +02:00
|
|
|
|
API bindings. This macro is usually used in non-webhook integration docs under
|
|
|
|
|
`templates/zerver/integrations/<integration_name>.md`. For an example
|
2022-09-09 03:24:32 +02:00
|
|
|
|
rendering, see **Step 3** of
|
2018-05-15 00:44:08 +02:00
|
|
|
|
[the docs for Zulip's Codebase integration][codebase].
|
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- `{!change-zulip-config-file.md!}` macro - Instructs users to create a bot and
|
2018-05-15 00:44:08 +02:00
|
|
|
|
specify said bot's credentials in the config file for a given non-webhook
|
|
|
|
|
integration. This macro is usually used in non-webhook integration docs under
|
|
|
|
|
`templates/zerver/integrations/<integration_name>.md`. For an example
|
|
|
|
|
rendering, see **Step 4** of
|
|
|
|
|
[the docs for Zulip's Codebase integration][codebase].
|
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- `{!git-append-branches.md!}` and `{!git-webhook-url-with-branches.md!}` -
|
2018-05-15 00:44:08 +02:00
|
|
|
|
These two macros explain how to specify a list of branches in the webhook URL
|
|
|
|
|
to filter notifications in our Git-related webhooks. For an example rendering,
|
|
|
|
|
see the last paragraph of **Step 2** in
|
2021-08-21 00:03:43 +02:00
|
|
|
|
[the docs for Zulip's GitHub integration][github-integration].
|
2017-06-30 07:05:29 +02:00
|
|
|
|
|
2022-06-26 02:38:55 +02:00
|
|
|
|
- `{!webhook-url.md!}` - Used internally by `{!create-bot-construct-url.md!}`
|
2018-05-15 00:44:08 +02:00
|
|
|
|
to generate the webhook URL.
|
2017-06-30 07:05:29 +02:00
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
|
- `{!webhook-url-with-bot-email.md!}` - Used in certain non-webhook integrations
|
2018-05-15 00:44:08 +02:00
|
|
|
|
to generate URLs of the form:
|
2017-11-22 17:33:52 +01:00
|
|
|
|
|
2021-08-20 22:54:08 +02:00
|
|
|
|
```text
|
|
|
|
|
https://bot_email:bot_api_key@yourZulipDomain.zulipchat.com/api/v1/external/beanstalk
|
|
|
|
|
```
|
2017-06-30 07:05:29 +02:00
|
|
|
|
|
2021-08-20 22:54:08 +02:00
|
|
|
|
For an example rendering, see
|
|
|
|
|
[Zulip's Beanstalk integration](https://zulip.com/integrations/doc/beanstalk).
|
2018-05-15 00:44:08 +02:00
|
|
|
|
|
2022-08-16 21:27:45 +02:00
|
|
|
|
- `{!event-filtering-instructions}` macro - Instructs user to use the event
|
|
|
|
|
filtering feature and shows a list of event types that the integration supports.
|
|
|
|
|
For an example rendering, see the last 4 paragraphs of **Step 2** in
|
|
|
|
|
[the docs for Zulip's Front integration][front].
|
|
|
|
|
|
2021-08-21 00:03:43 +02:00
|
|
|
|
[github-integration]: https://zulip.com/integrations/doc/github
|
2022-09-09 03:24:32 +02:00
|
|
|
|
[zendesk]: https://zulip.com/integrations/doc/zendesk
|
|
|
|
|
[matrix]: https://zulip.com/integrations/doc/matrix#configure-the-bridge
|
2020-06-08 23:04:39 +02:00
|
|
|
|
[codebase]: https://zulip.com/integrations/doc/codebase
|
|
|
|
|
[beanstalk]: https://zulip.com/integrations/doc/beanstalk
|
2022-08-16 21:27:45 +02:00
|
|
|
|
[front]: https://zulip.com/integrations/doc/front
|
2021-09-01 00:15:31 +02:00
|
|
|
|
[integrations-file]: https://github.com/zulip/zulip/blob/main/zerver/lib/integrations.py
|
2018-05-15 01:45:00 +02:00
|
|
|
|
|
|
|
|
|
## Writing guidelines
|
|
|
|
|
|
|
|
|
|
For the vast majority of integrations, you should just copy the docs for a
|
|
|
|
|
similar integration and edit it. [Basecamp][basecamp] is a good one to copy.
|
|
|
|
|
|
2020-06-08 23:04:39 +02:00
|
|
|
|
[basecamp]: https://zulip.com/integrations/doc/basecamp
|
2018-05-15 01:45:00 +02:00
|
|
|
|
|
|
|
|
|
### General writing guidelines
|
|
|
|
|
|
2021-04-13 18:04:31 +02:00
|
|
|
|
At a high level, the goals are for the instructions to feel simple, be easy to
|
2018-05-15 01:45:00 +02:00
|
|
|
|
follow, and be easy to maintain. Easier said than done, but here are a few
|
|
|
|
|
concrete guidelines.
|
|
|
|
|
|
|
|
|
|
##### Feel simple
|
|
|
|
|
|
|
|
|
|
- Use simple language.
|
|
|
|
|
- Use the imperative tense.
|
|
|
|
|
- Only describe things as much as necessary. For example: "Select **Project settings**."
|
|
|
|
|
is better than "Select **Project settings** from the dropdown."
|
|
|
|
|
- Cut unnecessary words. For example, do not start steps with transition words
|
|
|
|
|
like "Next", "First", "Now", etc. Each step should be structurally
|
|
|
|
|
independent.
|
|
|
|
|
|
|
|
|
|
##### Be easy to follow
|
|
|
|
|
|
|
|
|
|
- Actions should appear in order, including implicit ones. So "Under
|
|
|
|
|
**Webhooks**, click **Add Webhook**." not "Click **Add Webhook** in the
|
|
|
|
|
**Webhooks** section." "Under **Webhooks**" is an action, since it’s basically
|
|
|
|
|
the same as "Find the Webhooks section".
|
|
|
|
|
- UI elements in third-party websites should be **bolded**.
|
|
|
|
|
- Trailing punctuation can be stripped from bolded elements. For example,
|
|
|
|
|
"**Enable this checkbox**" instead of "**Enable this checkbox?**".
|
|
|
|
|
Starting punctuation such as the "**+**" in "**+ New Notification**" should
|
|
|
|
|
be preserved.
|
|
|
|
|
- You can use a screenshot if a step is particularly complicated
|
|
|
|
|
(see [Screenshots](#screenshots) below).
|
|
|
|
|
|
|
|
|
|
##### Be easy to maintain
|
|
|
|
|
|
|
|
|
|
- Follow the organization and wording of existing docs as much as possible.
|
|
|
|
|
|
|
|
|
|
### Guidelines for specific steps
|
|
|
|
|
|
|
|
|
|
Most doc files should start with a generic sentence about the
|
|
|
|
|
integration, for example, "Get `webhook name` notifications in Zulip!"
|
|
|
|
|
A typical doc will then have the following steps.
|
|
|
|
|
|
|
|
|
|
##### "Create the stream" step
|
|
|
|
|
|
|
|
|
|
- Use the `create-stream` macro. This step should be omitted if the
|
|
|
|
|
integration only supports notifications via PMs.
|
|
|
|
|
|
|
|
|
|
##### "Create the bot" step
|
|
|
|
|
|
2022-06-26 02:38:55 +02:00
|
|
|
|
- Typically, use the `create-bot-construct-url` macro.
|
2018-05-15 01:45:00 +02:00
|
|
|
|
- [Existing macros](#markdown-macros) should be used for this if they exist, but if the macro
|
|
|
|
|
defaults don’t work, it may make sense to write something custom for the
|
|
|
|
|
integration in question. This step is mandatory for all integrations.
|
|
|
|
|
|
|
|
|
|
##### "Navigate to this screen" step
|
|
|
|
|
|
|
|
|
|
- In general, this should be one step, even if it takes multiple clicks.
|
|
|
|
|
- Begin by mentioning the third-party service being documented with language
|
|
|
|
|
such as "Go to your Taiga project", "Go to your GitHub repository",
|
|
|
|
|
"On your X project", etc. Assume the user is already logged in to their
|
|
|
|
|
account.
|
|
|
|
|
- If a UI element is difficult to spot, you can use additional cues like
|
|
|
|
|
"Click on **Settings** in the top-right corner" or "On the left, click
|
|
|
|
|
**Webhooks**.". Only do this if the element is actually difficult to spot.
|
|
|
|
|
- If this step includes more than 5 sentences, it may need to be split up
|
|
|
|
|
into multiple steps.
|
|
|
|
|
|
|
|
|
|
##### "Fill out form and save" step
|
|
|
|
|
|
|
|
|
|
- Filling out a form and clicking **Save** should generally be one step, even if
|
|
|
|
|
there are multiple fields to fill out.
|
|
|
|
|
- It’s fine to say things like "Follow the on-screen instructions to create an
|
|
|
|
|
app" if they have a sequence of steps they guide you through that are pretty
|
|
|
|
|
clear.
|
|
|
|
|
|
|
|
|
|
Lastly, end with the `congrats.md` macro and a screenshot of a sample message
|
|
|
|
|
within Zulip.
|
|
|
|
|
|
|
|
|
|
### Screenshots
|
|
|
|
|
|
|
|
|
|
Screenshots are hard to maintain, so we generally err on the side of not
|
|
|
|
|
including screenshots. That being said, screenshots may be used to aid the
|
|
|
|
|
process if the third-party UI is confusing or a specific UI element is hard
|
|
|
|
|
to find. A few things to keep in mind:
|
|
|
|
|
|
|
|
|
|
- Screenshots should be small and should mainly include the third-party UI that
|
|
|
|
|
the text is referring to that is difficult to locate.
|
|
|
|
|
- Screenshots should never include the entirety of a third-party website’s page.
|
|
|
|
|
- Each screenshot should come after the step that refers to it.
|