Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Mar 7, 2019
1 parent 075c3d3 commit fda46d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
32 changes: 16 additions & 16 deletions packages/deprecated/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,6 @@ npm install @wordpress/deprecated --save

_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)._

## Usage

```js
import deprecated from '@wordpress/deprecated';

deprecated( 'Eating meat', {
version: 'the future',
alternative: 'vegetables',
plugin: 'the earth',
hint: 'You may find it beneficial to transition gradually.',
} );

// Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.'
```

## Hook

The `deprecated` action is fired with three parameters: the name of the deprecated feature, the options object passed to deprecated, and the message sent to the console.
Expand All @@ -49,10 +34,25 @@ addAction( 'deprecated', 'my-plugin/add-deprecation-alert', addDeprecationAlert

### default

[src/index.js#L25-L64](src/index.js#L25-L64)
[src/index.js#L39-L78](src/index.js#L39-L78)

Logs a message to notify developers about a deprecated feature.

**Usage**

```js
import deprecated from '@wordpress/deprecated';

deprecated( 'Eating meat', {
version: 'the future',
alternative: 'vegetables',
plugin: 'the earth',
hint: 'You may find it beneficial to transition gradually.',
} );

// Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.'
```

**Parameters**

- **feature** `string`: Name of the deprecated feature.
Expand Down
14 changes: 14 additions & 0 deletions packages/deprecated/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ export const logged = Object.create( null );
* @param {?string} options.plugin Plugin name if it's a plugin feature
* @param {?string} options.link Link to documentation
* @param {?string} options.hint Additional message to help transition away from the deprecated feature.
*
* @example
* ```js
* import deprecated from '@wordpress/deprecated';
*
* deprecated( 'Eating meat', {
* version: 'the future',
* alternative: 'vegetables',
* plugin: 'the earth',
* hint: 'You may find it beneficial to transition gradually.',
* } );
*
* // Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.'
* ```
*/
export default function deprecated( feature, options = {} ) {
const {
Expand Down

0 comments on commit fda46d7

Please sign in to comment.