Skip to content

Commit

Permalink
escape-html: set up autogenerated API docs (#14268)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolosw authored and youknowriad committed Mar 20, 2019
1 parent 3e3ac82 commit 1bcee0b
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 0 deletions.
27 changes: 27 additions & 0 deletions bin/update-readmes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,34 @@ const path = require( 'path' );
const childProcess = require( 'child_process' );

const packages = [
//'a11y',
//'autop',
//'blob',
//'block-editor',
//'block-library',
//'block-serialization-default-parser',
//'blocks',
//'compose',
//'data',
//'date',
//'deprecated',
//'dom',
//'dom-ready',
'e2e-test-utils',
//'edit-post',
'element',
'escape-html',
//'html-entities',
//'i18n',
//'keycodes',
//'plugins',
//'priority-queue',
//'redux-routine',
//'rich-text',
//'shortcode',
//'url',
//'viewport',
//'wordcount',
];

let aggregatedExitCode = 0;
Expand All @@ -14,6 +40,7 @@ packages.forEach( ( packageName ) => {
`packages/${ packageName }/src/index.js`,
`--output packages/${ packageName }/README.md`,
'--to-token',
'--ignore "unstable|experimental"',
];
const pathToDocGen = path.join( __dirname, '..', 'node_modules', '.bin', 'docgen' );
const { status, stderr } = childProcess.spawnSync(
Expand Down
114 changes: 114 additions & 0 deletions packages/escape-html/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,118 @@ npm install @wordpress/escape-html

_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) will add support for these methods. Learn more about it in [Babel docs](https://babeljs.io/docs/en/next/caveats)._

## API

<!-- START TOKEN(Autogenerated API docs) -->

### escapeAmpersand

[src/index.js#L28-L30](src/index.js#L28-L30)

Returns a string with ampersands escaped. Note that this is an imperfect
implementation, where only ampersands which do not appear as a pattern of
named, decimal, or hexadecimal character references are escaped. Invalid
named references (i.e. ambiguous ampersand) are are still permitted.

**Related**

- <https://w3c.github.io/html/syntax.html#character-references>
- <https://w3c.github.io/html/syntax.html#ambiguous-ampersand>
- <https://w3c.github.io/html/syntax.html#named-character-references>

**Parameters**

- **value** `string`: Original string.

**Returns**

`string`: Escaped string.

### escapeAttribute

[src/index.js#L66-L68](src/index.js#L66-L68)

Returns an escaped attribute value.

**Related**

- <https://w3c.github.io/html/syntax.html#elements-attributes>

"[...] the text cannot contain an ambiguous ampersand [...] must not contain
any literal U+0022 QUOTATION MARK characters (")"

**Parameters**

- **value** `string`: Attribute value.

**Returns**

`string`: Escaped attribute value.

### escapeHTML

[src/index.js#L82-L84](src/index.js#L82-L84)

Returns an escaped HTML element value.

**Related**

- <https://w3c.github.io/html/syntax.html#writing-html-documents-elements>

"the text must not contain the character U+003C LESS-THAN SIGN (\<) or an
ambiguous ampersand."

**Parameters**

- **value** `string`: Element value.

**Returns**

`string`: Escaped HTML element value.

### escapeLessThan

[src/index.js#L50-L52](src/index.js#L50-L52)

Returns a string with less-than sign replaced.

**Parameters**

- **value** `string`: Original string.

**Returns**

`string`: Escaped string.

### escapeQuotationMark

[src/index.js#L39-L41](src/index.js#L39-L41)

Returns a string with quotation marks replaced.

**Parameters**

- **value** `string`: Original string.

**Returns**

`string`: Escaped string.

### isValidAttributeName

[src/index.js#L93-L95](src/index.js#L93-L95)

Returns true if the given attribute name is valid, or false otherwise.

**Parameters**

- **name** `string`: Attribute name to test.

**Returns**

`boolean`: Whether attribute is valid.


<!-- END TOKEN(Autogenerated API docs) -->

<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>

0 comments on commit 1bcee0b

Please sign in to comment.