选中节点后,其帮助文本将显示在信息选项卡中。此帮助应向用户提供使用该节点所需的所有信息。
以下样式指南描述了帮助的结构,以确保节点之间外观一致。
自 2.1.0 版本起:帮助文本可以以 Markdown 格式而不是 HTML 格式提供。在这种情况下,<script>
标签的 type
属性必须是 text/markdown
。
创建 Markdown 帮助文本时,请注意缩进,Markdown 对空白敏感,因此所有行在 <script>
标签内都不应有前导空白。
<p>
)用作鼠标悬停在调色板中的节点上时的工具提示。连接到 MQTT 代理并发布消息。
本节提供有关节点的更详细信息。它应解释如何使用它,提供有关其输入/输出的更多信息。
msg.payload
用作发布消息的有效负载。如果它包含一个对象,它将在发送前转换为 JSON 字符串。如果它包含二进制缓冲区,消息将按原样发布。
使用的主题可以在节点中配置,如果留空,则可以由 msg.topic
设置。
同样,QoS 和保留值可以在节点中配置,如果留空,则分别由 msg.qos
和 msg.retain
设置。
本节可用于提供外部资源的链接,例如
msg.tweet
属性的完整描述上述示例是用以下内容创建的:
<script type="text/html" data-help-name="node-type">
<p>Connects to a MQTT broker and publishes messages.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">string | buffer</span>
</dt>
<dd> the payload of the message to publish. </dd>
<dt class="optional">topic <span class="property-type">string</span></dt>
<dd> the MQTT topic to publish to.</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Standard output
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>the standard output of the command.</dd>
</dl>
</li>
<li>Standard error
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>the standard error of the command.</dd>
</dl>
</li>
</ol>
<h3>Details</h3>
<p><code>msg.payload</code> is used as the payload of the published message.
If it contains an Object it will be converted to a JSON string before being sent.
If it contains a binary Buffer the message will be published as-is.</p>
<p>The topic used can be configured in the node or, if left blank, can be set
by <code>msg.topic</code>.</p>
<p>Likewise the QoS and retain values can be configured in the node or, if left
blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p>
<h3>References</h3>
<ul>
<li><a>Twitter API docs</a> - full description of <code>msg.tweet</code> property</li>
<li><a>GitHub</a> - the nodes github repository</li>
</ul>
</script>
<script type="text/markdown" data-help-name="node-type">
Connects to a MQTT broker and publishes messages.
### Inputs
: payload (string | buffer) : the payload of the message to publish.
: *topic* (string) : the MQTT topic to publish to.
### Outputs
1. Standard output
: payload (string) : the standard output of the command.
2. Standard error
: payload (string) : the standard error of the command.
### Details
`msg.payload` is used as the payload of the published message.
If it contains an Object it will be converted to a JSON string before being sent.
If it contains a binary Buffer the message will be published as-is.
The topic used can be configured in the node or, if left blank, can be set
`msg.topic`.
Likewise the QoS and retain values can be configured in the node or, if left
blank, set by `msg.qos` and `msg.retain` respectively.
### References
- [Twitter API docs]() - full description of `msg.tweet` property
- [GitHub]() - the nodes github repository
</script>
每个章节都必须用 <h3>
标签标记。如果 Details
章节需要副标题,则必须使用 <h4>
标签。
<h3>Inputs</h3>
...
<h3>Details</h3>
...
<h4>A sub section</h4>
...
### Inputs
...
### Details
...
#### A sub section
...
消息属性列表用 <dl>
列表标记。该列表必须具有类属性 message-properties
。
列表中的每个项目都由一对 <dt>
和 <dd>
标签组成。
每个 <dt>
包含属性名称和可选的 <span class="property-type">
,其中包含属性的预期类型。如果属性是可选的,则 <dt>
应具有 optional
类属性。
每个 <dd>
包含属性的简要描述。
<dl class="message-properties">
<dt>payload
<span class="property-type">string | buffer</span>
</dt>
<dd> the payload of the message to publish. </dd>
<dt class="optional">topic
<span class="property-type">string</span>
</dt>
<dd> the MQTT topic to publish to.</dd>
</dl>
: payload (string | buffer) : the payload of the message to publish.
: *topic* (string) : the MQTT topic to publish to.
如果节点有多个输出,则每个输出都应有自己的消息属性列表,如上所述。这些列表应包含在具有 node-ports
类属性的 <ol>
列表中
列表中的每个项目都应包含对输出的简要描述,后跟 <dl>
消息属性列表。
注意:如果节点只有一个输出,则不应将其包含在此类列表中,而应仅使用 <dl>
。
<ol class="node-ports">
<li>Standard output
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>the standard output of the command.</dd>
</dl>
</li>
<li>Standard error
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>the standard error of the command.</dd>
</dl>
</li>
</ol>
1. Standard output
: payload (string) : the standard output of the command.
2. Standard error
: payload (string) : the standard error of the command.
在上述消息属性列表之外引用消息属性时,它们应以 msg.
为前缀,以向读者清楚地表明其含义。它们应包含在 <code>
标签中。
The interesting part is in <code>msg.payload</code>.
The interesting part is in `msg.payload`.
帮助文本正文中不应使用其他样式标记(例如 <b>
、<i>
)。
帮助不应假定读者是经验丰富的开发人员或对节点公开的任何内容都非常熟悉;最重要的是,它需要有用。
版权所有 OpenJS Foundation 和 Node-RED 贡献者。保留所有权利。OpenJS Foundation 已注册商标并使用商标。有关 OpenJS Foundation 商标列表,请参阅我们的商标政策和商标列表。未在OpenJS Foundation 商标列表中指明的商标和徽标是其各自持有人的商标™ 或注册® 商标。使用它们不表示与它们的任何关联或认可。
OpenJS Foundation | 使用条款 | 隐私政策 | OpenJS Foundation 章程 | 商标政策 | 商标列表 | Cookie 政策