templates: Support parametric Markdown macros for webhooks docs.

This commit is contained in:
Eeshan Garg 2017-05-24 19:43:50 -02:30 committed by Tim Abbott
parent 2e4078cbd2
commit 3cb758d339
4 changed files with 16 additions and 7 deletions

View File

@ -1,5 +1,5 @@
Next, on your {{ settings_html|safe }}, create a bot for this Next, on your {{ settings_html|safe }}, create a bot for
integration. Construct the URL for this bot using the bot API key {{ integration_display_name }}. Construct the URL for the
and stream name: {{ integration_display_name }} bot using the bot API key and stream name:
`{{ external_api_uri_subdomain }}/v1/external/ {!webhook-url.md!}

View File

@ -1,3 +1,4 @@
First, create the stream you'd like to use for notifications from First, create the stream you'd like to use for
this integration, and subscribe all interested parties to this stream. {{ integration_display_name }} notifications, and subscribe all
We recommend the name interested parties to this stream. We recommend the
name `{{ integration_name }}`.

View File

@ -0,0 +1 @@
`{{ external_api_uri_subdomain }}{{ integration_url }}?api_key=abcdefgh&stream={{ integration_name }}`

View File

@ -82,6 +82,13 @@ def render_markdown_path(markdown_file_path, context=None):
if context is None: if context is None:
context = {} context = {}
if markdown_file_path.endswith('doc.md'):
integration_dir = markdown_file_path.split('/')[0]
integration = context['integrations_dict'][integration_dir]
context['integration_name'] = integration.name
context['integration_display_name'] = integration.display_name
context['integration_url'] = integration.url[3:]
jinja = engines['Jinja2'] jinja = engines['Jinja2']
markdown_string = jinja.env.loader.get_source(jinja.env, markdown_file_path)[0] markdown_string = jinja.env.loader.get_source(jinja.env, markdown_file_path)[0]
html = md_engine.convert(markdown_string) html = md_engine.convert(markdown_string)