节点帮助样式指南

选中节点后,其帮助文本将显示在信息选项卡中。此帮助应向用户提供使用该节点所需的所有信息。

以下样式指南描述了帮助的结构,以确保节点之间外观一致。

自 2.1.0 版本起:帮助文本可以以 Markdown 格式而不是 HTML 格式提供。在这种情况下,<script> 标签的 type 属性必须是 text/markdown
创建 Markdown 帮助文本时,请注意缩进,Markdown 对空白敏感,因此所有行在 <script> 标签内都不应有前导空白。


本节提供了对节点的高级介绍。它不应超过 2 或 3 行。第一行(<p>)用作鼠标悬停在调色板中的节点上时的工具提示。

连接到 MQTT 代理并发布消息。

如果节点有输入,本节将描述节点将使用的消息属性。还可以提供每个属性的预期类型。描述应简明扼要——如果需要进一步的描述,应放在“详细信息”部分。

输入

payload string | buffer
要发布的消息的有效负载。
topic string
要发布到的 MQTT 主题。
如果节点有输出,与“输入”部分一样,本节描述节点将发送的消息的属性。如果节点有多个输出,则可以为每个输出提供单独的属性列表。

输出

  1. 标准输出
    payload string
    命令的标准输出。
  2. 标准错误
    payload string
    命令的标准错误。

本节提供有关节点的更详细信息。它应解释如何使用它,提供有关其输入/输出的更多信息。

详细信息

msg.payload 用作发布消息的有效负载。如果它包含一个对象,它将在发送前转换为 JSON 字符串。如果它包含二进制缓冲区,消息将按原样发布。

使用的主题可以在节点中配置,如果留空,则可以由 msg.topic 设置。

同样,QoS 和保留值可以在节点中配置,如果留空,则分别由 msg.qosmsg.retain 设置。

本节可用于提供外部资源的链接,例如

  • 任何相关的附加文档。例如,模板节点如何链接到 Mustache 语言指南。
  • 节点的 Git 仓库或 npm 页面——用户可以在其中获得额外帮助

参考资料


上述示例是用以下内容创建的:

<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>)。

帮助不应假定读者是经验丰富的开发人员或对节点公开的任何内容都非常熟悉;最重要的是,它需要有用。