@@ -11,14 +11,17 @@ should provide the user with all the information they need in order to use the n
1111The following style guide describes how the help should be structured to ensure
1212a consistent appearance between nodes.
1313
14+ * Since 2.1.0* : The help text can be provided as markdown rather than HTML. In this
15+ case the ` type ` attribute of the ` <script> ` tag must be ` text/markdown ` .
16+
1417<hr />
1518
1619<link href =" /css/node-help.css " rel =" stylesheet " >
1720
1821<div class =" grid " style =" min-height :auto ; padding :5px 0 5px ; border-bottom : 1px solid #f0f0f0 ;" >
1922 <div class="col-1-2">
2023 This section provides a high-level introduction to the node. It should be
21- no more than 2 or 3 <code><p></code> long. The first <code><p></code>
24+ no more than 2 or 3 lines long. The first line ( <code><p></code>)
2225 is used as the tooltip when hovering over the node in the palette.
2326 </div>
2427 <div class="col-1-2 node-help" style="padding-right: 5px; background: #f9f9f9;">
@@ -106,9 +109,10 @@ a consistent appearance between nodes.
106109
107110<hr />
108111
109- The above example was created with the following HTML .
112+ The above example was created with the following: .
110113
111- ~~~~~ html
114+ {:.code-tab-html}
115+ ``` html
112116<script type =" text/html" data-help-name =" node-type" >
113117<p >Connects to a MQTT broker and publishes messages.</p >
114118
@@ -153,22 +157,70 @@ The above example was created with the following HTML.
153157 <li ><a >GitHub</a > - the nodes github repository</li >
154158 </ul >
155159</script >
156- ~~~~~
160+ ```
161+
162+ {:.code-tab-md}
163+ ``` markdown
164+ <script type="text/markdown" data-help-name="node-type">
165+ Connects to a MQTT broker and publishes messages.
166+
167+ ### Inputs
168+
169+ : payload (string | buffer) : the payload of the message to publish.
170+ : *topic* (string) : the MQTT topic to publish to.
171+
172+
173+ ### Outputs
174+
175+ 1. Standard output
176+ : payload (string) : the standard output of the command.
157177
178+ 2. Standard error
179+ : payload (string) : the standard error of the command.
180+
181+ ### Details
182+
183+ `msg.payload` is used as the payload of the published message.
184+ If it contains an Object it will be converted to a JSON string before being sent.
185+ If it contains a binary Buffer the message will be published as-is.
186+
187+ The topic used can be configured in the node or, if left blank, can be set
188+ `msg.topic`.
189+
190+ Likewise the QoS and retain values can be configured in the node or, if left
191+ blank, set by `msg.qos` and `msg.retain` respectively.
192+
193+ ### References
194+
195+ - [Twitter API docs]() - full description of `msg.tweet` property
196+ - [GitHub]() - the nodes github repository
197+ </script>
198+ ```
158199
159200#### Section headers
160201
161202Each section must be marked up with an ` <h3> ` tag. If the ` Details ` section needs
162203sub headings, they must use ` <h4> ` tags.
163204
164- ~~~~~ html
205+ {:.code-tab-html}
206+ ``` html
165207<h3 >Inputs</h3 >
166208...
167209<h3 >Details</h3 >
168210...
169211 <h4 >A sub section</h4 >
170212 ...
171- ~~~~~
213+ ```
214+
215+ {:.code-tab-md}
216+ ``` markdown
217+ ### Inputs
218+ ...
219+ ### Details
220+ ...
221+ #### A sub section
222+ ...
223+ ```
172224
173225#### Message properties
174226
@@ -183,8 +235,8 @@ the `<dt>` should have a class attribute of `optional`.
183235
184236Each ` <dd> ` contains a brief description of the property.
185237
186-
187- ~~~~~ html
238+ {:.code-tab-html}
239+ ``` html
188240<dl class =" message-properties" >
189241 <dt >payload
190242 <span class =" property-type" >string | buffer</span >
@@ -195,7 +247,13 @@ Each `<dd>` contains a brief description of the property.
195247 </dt >
196248 <dd > the MQTT topic to publish to.</dd >
197249</dl >
198- ~~~~~
250+ ```
251+
252+ {:.code-tab-md}
253+ ``` markdown
254+ : payload (string | buffer) : the payload of the message to publish.
255+ : *topic* (string) : the MQTT topic to publish to.
256+ ```
199257
200258#### Multiple outputs
201259
@@ -209,7 +267,8 @@ by a `<dl>` message property list.
209267<b >Note</b >: if the node has a single output, it should not be wrapped in such a list and
210268just the ` <dl> ` used.
211269
212- ~~~~~ html
270+ {:.code-tab-html}
271+ ``` html
213272<ol class =" node-ports" >
214273 <li >Standard output
215274 <dl class =" message-properties" >
@@ -224,7 +283,16 @@ just the `<dl>` used.
224283 </dl >
225284 </li >
226285</ol >
227- ~~~~~
286+ ```
287+
288+ {:.code-tab-md}
289+ ``` markdown
290+ 1. Standard output
291+ : payload (string) : the standard output of the command.
292+
293+ 2. Standard error
294+ : payload (string) : the standard error of the command.
295+ ```
228296
229297
230298#### General guidance
@@ -233,11 +301,66 @@ When referencing a message property outside of a message property list described
233301above, they should be prefixed with ` msg. ` to make it clear to the reader what
234302it is. They should be wrapped in ` <code> ` tags.
235303
236- ~~~~~ html
304+ {:.code-tab-html}
305+ ``` html
237306The interesting part is in <code >msg.payload</code >.
238- ~~~~~
307+ ```
308+
309+ {:.code-tab-md}
310+ ``` markdown
311+ The interesting part is in `msg.payload`.
312+ ```
239313
240314No other styling markup (e.g. ` <b> ` ,` <i> ` ) should be used within the body of the help text.
241315
242316The help should not assume the reader is an experienced developer or deeply familiar
243317with whatever the node exposes; above all, it needs to be helpful.
318+
319+ <style >
320+
321+ .format-button {
322+ padding : 2px 8px ;
323+ border : 1px solid #666 ;
324+ margin-right : 8px ;
325+ background : #bbb ;
326+ }
327+ .format-button.active {
328+ background : white ;
329+ pointer-events : none ;
330+
331+ }
332+ .code-example-switcher pre {
333+ margin-top : 0 ;
334+ }
335+ </style >
336+
337+ <script >
338+ $ (function () {
339+ $ (" .code-tab-html" ).each (function () {
340+ let htmlBlock = $ (this );
341+ let mdBlock = $ (this ).next (" .code-tab-md" ).hide ();
342+ htmlBlock .wrap (" <div></div>" );
343+ let container = htmlBlock .parent ();
344+ mdBlock .appendTo (container);
345+
346+ container .wrap (' <div class="code-example-switcher"></div>' );
347+ let toplevel = container .parent ();
348+ let toolbar = $ (' <div></div>' ).prependTo (toplevel);
349+
350+ let htmlButton = $ (' <a href="#" class="active format-button">HTML</a>' ).appendTo (toolbar).on (" click" , function (evt ) {
351+ evt .preventDefault ();
352+ mdBlock .hide ();
353+ htmlBlock .show ();
354+ htmlButton .addClass (' active' );
355+ mdButton .removeClass (' active' )
356+ });
357+ let mdButton = $ (' <a href="#" class="format-button">Markdown</a>' ).appendTo (toolbar).on (" click" , function (evt ) {
358+ evt .preventDefault ();
359+ mdBlock .show ();
360+ htmlBlock .hide ();
361+ htmlButton .removeClass (' active' );
362+ mdButton .addClass (' active' )
363+ });
364+ })
365+ })
366+ </script >
0 commit comments