Node-RED 帮助文档风格指南

当选中一个节点时,其帮助文本会显示在信息选项卡中。该帮助内容应为用户提供使用该节点所需的所有信息。

以下风格指南描述了帮助文档应如何结构化,以确保各节点间呈现一致的外观。

Since 2.1.0 : The help text can be provided as markdown rather than HTML. In this case the type attribute of the


This section provides a high-level introduction to the node. It should be no more than 2 or 3 lines long. The first line (<p>) is used as the tooltip when hovering over the node in the palette.

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

如果节点有输入,本节将描述该节点将使用的消息属性。还可以提供每个属性的预期类型。描述应简洁明了 - 如需更详细说明,应在"详细信息"部分提供。

输入

payload string | buffer
the payload of the message to publish.
topic string
the MQTT topic to publish to.
如果节点有输出端口,与输入部分类似,此部分 描述节点将发送的消息属性。如果节点 有多个输出端口,可以为每个输出提供单独的属性列表。

输出

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

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

详情

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

使用的主题可以在节点中配置,如果留空,也可以通过msg.topic来设置。

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

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

  • 任何相关的附加文档。例如Template节点如何链接到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>

章节标题

每个部分必须用

标签标记。如果Details部分需要子标题,必须使用

标签。

<h3>Inputs</h3>
...
<h3>Details</h3>
...
 <h4>A sub section</h4>
 ...
### Inputs
...
### Details
...
#### A sub section
...

消息属性

消息属性列表使用

标签标记。该列表必须包含一个message-properties的类属性。

列表中的每个项目由一对

标签组成。

每个

包含属性名称和可选的,后者包含该属性的预期类型。如果属性是可选的,
应具有optional类属性。

每个

包含该属性的简要描述。

<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 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.前缀,以便读者清楚其含义。这些引用应当包裹在标签中。

    The interesting part is in <code>msg.payload</code>.
    
    The interesting part is in `msg.payload`.
    

    帮助文本正文中不应使用其他样式标记(例如)。

    帮助文档不应假设读者是经验丰富的开发者或对所涉及节点非常熟悉;最重要的是,它需要提供实际帮助。