Skip to content

Commit eb0aa61

Browse files
authored
Switch to using Markdown code fence notation instead of shortcodes and update style guide accordingly. (#45)
1 parent 9268dfb commit eb0aa61

File tree

8 files changed

+323
-314
lines changed

8 files changed

+323
-314
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changelog
22

3+
- 2020-09-25 Update code examples to use Markdown code fence notation instead of shortcodes.
34
- 2019-12-21 Update `javascript.md` from the [handbook page](https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/).
45
- 2019-12-21 Update `accessibility.md` from the [handbook page](https://make.wordpress.org/core/handbook/best-practices/coding-standards/accessibility-coding-standards/).
56
- 2018-01-14 Initial import from https://make.wordpress.org/core/handbook/best-practices/

inline-documentation-standards/javascript.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ Related comments should be spaced so that they align to make them more easily re
6262

6363
For example:
6464

65-
[js]
65+
```javascript
6666
/**
6767
* @param {very_long_type} name Description.
6868
* @param {type} very_long_name Description.
6969
*/
70-
[/js]
70+
```
7171

7272
<h2>Functions</h2>
7373
Functions should be formatted as follows:
@@ -93,7 +93,7 @@ Functions should be formatted as follows:
9393
<li><strong>@return:</strong> Note the period after the description.</li>
9494
</ul>
9595

96-
[js]
96+
```javascript
9797
/**
9898
* Summary. (use period)
9999
*
@@ -129,7 +129,7 @@ Functions should be formatted as follows:
129129
*
130130
* @return {type} Return value description.
131131
*/
132-
[/js]
132+
```
133133

134134
<h2>Backbone classes</h2>
135135
Backbone's <code>extend</code> calls should be formatted as follows:
@@ -160,7 +160,7 @@ Backbone's <code>initialize</code> functions should be formatted as follows:
160160
</li>
161161
</ul>
162162

163-
[js]
163+
```javascript
164164
Class = Parent.extend( /** @lends namespace.Class.prototype */{
165165
/**
166166
* Summary. (use period)
@@ -191,11 +191,11 @@ Class = Parent.extend( /** @lends namespace.Class.prototype */{
191191
//Do stuff.
192192
}
193193
} );
194-
[/js]
194+
```
195195

196196
If a Backbone class does not have an initialize function it should be documented by using @inheritDoc as follows:
197197

198-
[js]
198+
```javascript
199199
/**
200200
* Summary. (use period)
201201
*
@@ -220,15 +220,15 @@ If a Backbone class does not have an initialize function it should be documented
220220
Class = Parent.extend( /** @lends namespace.Class.prototype */{
221221
// Functions and properties.
222222
} );
223-
[/js]
223+
```
224224

225225
<blockquote>Note: This currently doesn't provide the expected functionality due to a bug with JSDoc's inheritDoc tag. See the issue <a href="https://github.com/jsdoc3/jsdoc/issues/1012">here</a></blockquote>
226226
<h2>Local functions</h2>
227227
At times functions will be assigned to a local variable before being assigned as a class member.
228228
Such functions should be marked as inner functions of the namespace that uses them using <code>~</code>.
229229
The functions should be formatted as follows:
230230

231-
[js]
231+
```javascript
232232
/**
233233
* Function description, you can use any JSDoc here as long as the function remains private.
234234
*
@@ -257,7 +257,7 @@ Class = Parent.extend( /** @lends namespace.Class.prototype */{
257257
*/
258258
doStuff: doStuff,
259259
} );
260-
[/js]
260+
```
261261

262262
<h2>Local ancestors</h2>
263263
At times classes will have Ancestors that are only assigned to a local variable. Such classes should be assigned to the namespace their children are and be made inner classes using <code>~</code>.
@@ -274,7 +274,7 @@ Class members should be formatted as follows:
274274
<li><strong>@memberof:</strong> Optionally use this to override what class this is a member of.</li>
275275
</ul>
276276

277-
[js]
277+
```javascript
278278
/**
279279
* Short description. (use period)
280280
*
@@ -287,7 +287,7 @@ Class members should be formatted as follows:
287287
* @member {type} realName
288288
* @memberof className
289289
*/
290-
[/js]
290+
```
291291

292292
<h2>Namespaces</h2>
293293
Namespaces should be formatted as follows:
@@ -299,7 +299,7 @@ Namespaces should be formatted as follows:
299299
<li><strong>@property:</strong> Properties that this namespace exposes. Use a period at the end.</li>
300300
</ul>
301301

302-
[js]
302+
```javascript
303303
/**
304304
* Short description. (use period)
305305
*
@@ -310,25 +310,25 @@ Namespaces should be formatted as follows:
310310
*
311311
* @property {type} key Description.
312312
*/
313-
[/js]
313+
```
314314

315315
<h2>Inline Comments</h2>
316316
Inline comments inside methods and functions should be formatted as follows:
317317
<h3>Single line comments</h3>
318318

319-
[js]
319+
```javascript
320320
// Extract the array values.
321-
[/js]
321+
```
322322

323323
<h3>Multi-line comments</h3>
324324

325-
[js]
325+
```javascript
326326
/*
327327
* This is a comment that is long enough to warrant being stretched over
328328
* the span of multiple lines. You'll notice this follows basically
329329
* the same format as the JSDoc wrapping and comment block style.
330330
*/
331-
[/js]
331+
```
332332

333333
<strong>Important note:</strong> Multi-line comments must not begin with <code>/**</code> (double asterisk). Use <code>/*</code> (single asterisk) instead.
334334
<h2>File Headers</h2>
@@ -338,7 +338,7 @@ Whenever possible, all WordPress JavaScript files should contain a header block.
338338

339339
WordPress uses JSHint for general code quality testing. Any inline configuration options should be placed at the end of the header block.
340340

341-
[js]
341+
```javascript
342342
/**
343343
* Summary. (use period)
344344
*
@@ -351,7 +351,7 @@ WordPress uses JSHint for general code quality testing. Any inline configuration
351351
*/
352352

353353
/** jshint {inline configuration here} */
354-
[/js]
354+
```
355355

356356
<h2>Supported JSDoc Tags</h2>
357357
<table>

0 commit comments

Comments
 (0)