Skip to content

Commit

Permalink
feat: display protocol bindings on server, channel, operation, message (
Browse files Browse the repository at this point in the history
  • Loading branch information
M3lkior authored Apr 12, 2021
1 parent 02f5fbf commit bcd3c9c
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 9 deletions.
5 changes: 4 additions & 1 deletion partials/message.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% from "./schema.html" import schema %}
{% from "./tags.html" import tags %}
{% from "./protocols.html" import bindings %}

{% macro message(msg, showIndex=false, index=0, open=false) %}

Expand All @@ -23,7 +24,6 @@
{% if correlationId %}
<div class="border border-gray-400 bg-gray-200 rounded p-4 mt-2">
<div class="text-sm text-gray-700 mb-2">Correlation ID<span class="border text-orange-600 rounded text-xs ml-3 py-0 px-2">{{correlationId.location()}}</span>

</div>
{% if correlationId.hasDescription() %}
<div class="text-gray-600 text-sm">{{correlationId.description() | markdown2html | safe }}</div>
Expand All @@ -40,6 +40,9 @@
{{ schema(msg.headers(), 'Headers', open=open) }}
</div>
{% endif %}

{{ bindings("Message", msg, odd=true) }}

</div>

{% endmacro %}
3 changes: 3 additions & 0 deletions partials/operation.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% from "./message.html" import message %}
{% from "./example.html" import example %}
{% from "./schema-prop.html" import schemaProp %}
{% from "./protocols.html" import bindings %}


{% macro operation(operation, operationType, channelName, channel) %}
Expand All @@ -26,6 +27,7 @@ <h3 class="font-mono text-base">
<p class="text-gray-500 text-sm">{{operation.summary()}}</p>
<div class="mt-4 mb-4 markdown">{{ operation.description() | markdown2html | safe }}</div>

{{ bindings("Channel", channel) }}


{% if channel.parameters() | length %}
Expand All @@ -50,6 +52,7 @@ <h3 class="font-mono text-base">
</div>
{% endif %}

{{ bindings("Operation", operation) }}

{% if operation.hasMultipleMessages() %}
<p>Accepts <strong>one of</strong> the following messages:</p>
Expand Down
2 changes: 2 additions & 0 deletions partials/operations.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{% from "./operation.html" import operation %}
{% from "./protocols.html" import bindings %}


<a name="operations"></a>
<h2 class="mb-4 ml-8">Operations</h2>
Expand Down
83 changes: 83 additions & 0 deletions partials/protocols.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{% macro displayProtocol(protocol, protocolVersion) %}
{% if protocolVersion %}
<span class="bg-teal-500 font-bold no-underline text-white uppercase rounded ml-2"
style="height: 20px;font-size: 11px;padding: 3px;">{{ protocol }}
{{ protocolVersion }}</span>
{% else %}
<span class="bg-teal-500 font-sans font-bold no-underline text-white uppercase rounded ml-2"
style="height: 20px;font-size: 11px;padding: 3px;">{{ protocol }}</span>
{% endif %}
{% endmacro %}


{% macro bindings(propName, prop, odd=false, showProtocol=true) %}

{% if prop.hasBindings() %}
{% for protocol in prop.bindingProtocols() %}
<div class="{% if open %}is-open{% endif %} mt-4">
<div class="js-prop cursor-pointer py-2 property">
<div class="pr-4" style="margin-top: -2px; min-width: 25%">
<div class="text-sm">
<span class="string-chunk">{{propName}} specific information</span>
<svg
class="expand inline align-baseline"
version="1.1"
viewBox="0 0 24 24"
x="0"
xmlns="http://www.w3.org/2000/svg"
y="0"
>
<polygon
points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "
></polygon>
</svg>
{% if showProtocol %}
{{ displayProtocol(protocol) }}
{% endif %}
</div>
</div>
</div>

<div class="children bg-gray-100 py-4 rounded">
{% for bindingName, bindingValue in prop.binding(protocol) %}
<div class="{% if odd %}bg-gray-100{% else %}bg-gray-200{% endif %} pl-8 pr-8">
{% if bindingValue | isObject %}
<div class="{% if open %}is-open{% endif %}">
<div class="js-prop cursor-pointer py-2 property">
<div class="pr-4" style="margin-top: -2px; min-width: 25%">
<span class="text-sm" style="word-break: break-word"
>{{ bindingName }}</span
>
<svg
class="expand inline align-baseline"
version="1.1"
viewBox="0 0 24 24"
x="0"
xmlns="http://www.w3.org/2000/svg"
y="0"
>
<polygon
points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "
></polygon>
</svg>
</div>
</div>
<div class="children">
<div
class="{% if odd %}bg-gray-200{% else %}bg-gray-100{% endif %} {% if not root %}pl-8 pr-8{% endif %} rounded"
>
<pre class="text-sm">{{ bindingValue | dump(2) }}</pre>
</div>
</div>
</div>
{% else %}
<div class="text-sm">{{ bindingName }}: {{ bindingValue }}</div>
{% endif %}
</div>
{% endfor %}
</div>
</div>
{% endfor %}
{% endif %}

{% endmacro %}
15 changes: 7 additions & 8 deletions partials/servers.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{% from "./sliced-string.html" import slicedString %}
{% from "./protocols.html" import displayProtocol %}
{% from "./protocols.html" import bindings %}

<a name="servers"></a>
<div class="center-block p-8">

Expand All @@ -11,18 +14,14 @@ <h2 class="mb-4">Servers</h2>
<div class="pr-4 font-mono">
{{ slicedString(server.url()) }}

{% if server.protocolVersion() %}
<span class="bg-teal-500 font-bold no-underline text-white uppercase rounded ml-2"
style="height: 20px;font-size: 11px;padding: 3px;">{{server.protocol()}}
{{server.protocolVersion()}}</span>
{% else %}
<span class="bg-teal-500 font-sans font-bold no-underline text-white uppercase rounded ml-2"
style="height: 20px;font-size: 11px;padding: 3px;">{{server.protocol()}}</span>
{% endif %}
{{ displayProtocol(server.protocol(), server.protocolVersion()) }}
</div>
<div class="text-xs text-gray-600">
{{ server.description() | markdown2html | safe }}
</div>

{{ bindings("Server", server, odd=true, showProtocol=false) }}

</div>
</div>

Expand Down

0 comments on commit bcd3c9c

Please sign in to comment.