diff --git a/API.md b/API.md new file mode 100644 index 0000000..78cde85 --- /dev/null +++ b/API.md @@ -0,0 +1,81 @@ + + +## Code ⇐ Shape +Implements Code shape which renders the highlighted code at specified point. + +**Kind**: global class +**Extends:** Shape +**Since**: 1.0.0 + +* [Code](#Code) ⇐ Shape + * [new Code(cursor, [options])](#new_Code_new) + * [.getCode()](#Code+getCode) ⇒ String + * [.setCode([code])](#Code+setCode) ⇒ Shape + * [.getWidth()](#Code+getWidth) ⇒ Number + * [.getHeight()](#Code+getHeight) ⇒ Number + * [.render()](#Code+render) ⇒ Text + * [.toObject()](#Code+toObject) ⇒ Object + + + +### new Code(cursor, [options]) +Create Code shape. + + +| Param | Type | Description | +| --- | --- | --- | +| cursor | Cursor | Cursor instance | +| [options] | Object | Options object | +| [options.code] | String | Code fragment that you want to show | + +**Example** +```js +Code.create(cursor, { + code: 'console.log('Your code here');' +}); +``` + + +### code.getCode() ⇒ String +Get current code from shape. + +**Kind**: instance method of [Code](#Code) + + +### code.setCode([code]) ⇒ Shape +Set new code to this shape. + +**Kind**: instance method of [Code](#Code) + +| Param | Type | Default | +| --- | --- | --- | +| [code] | String | '' | + + + +### code.getWidth() ⇒ Number +Returns actual width of the shape. +Since code shape hasn't specified width, we need to override default. +It looks for the longest line in your shape and returns its length. + +**Kind**: instance method of [Code](#Code) + + +### code.getHeight() ⇒ Number +Returns actual height of the shape. +Since code shape hasn't specified height, we need to override default. +It returns count of lines in our shape. + +**Kind**: instance method of [Code](#Code) + + +### code.render() ⇒ Text +Render the shape based on options. + +**Kind**: instance method of [Code](#Code) + + +### code.toObject() ⇒ Object +Overrides default toObject() method because we have new fields here. + +**Kind**: instance method of [Code](#Code)