Skip to content

Commit

Permalink
More improvmentes to docs gen
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Aug 12, 2021
1 parent e991584 commit 6729824
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
2 changes: 2 additions & 0 deletions docs/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ async function generateDocs () {
.then(output => {
const res = output
.replace(/\*\*\\\[/g, '**[')
.replace(/<\\\[/g, '<[')
.replace(/\| \\\[/g, '| [')
.replace('**Extends Model**', '');
fs.writeFileSync(`${docRoot}/api/${file[1]}`, res);
log('Created', file[1]);
Expand Down
12 changes: 7 additions & 5 deletions docs/api/device_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,26 @@ Return device by name
### Examples

```javascript
var device = deviceManager.get('Tablet');
const device = deviceManager.get('Tablet');
console.log(JSON.stringify(device));
// {name: 'Tablet', width: '900px'}
```

Returns **[Device]**

## getAll
## getDevices

Return all devices.
Return all devices

### Examples

```javascript
var devices = deviceManager.getAll();
const devices = deviceManager.getDevices();
console.log(JSON.stringify(devices));
// [{name: 'Desktop', width: ''}, ...]
```

Returns **Collection**
Returns **[Array][7]<[Device]>**

[1]: https://github.com/artf/grapesjs/blob/master/src/device_manager/config/config.js

Expand All @@ -106,3 +106,5 @@ Returns **Collection**
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
18 changes: 10 additions & 8 deletions docs/api/pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const pageManager = editor.Pages;
* [select][6]
* [getSelected][7]

[Page]: page.html

## add

Add new page
Expand All @@ -62,15 +64,15 @@ const newPage = pageManager.add({
});
```

Returns **Page**
Returns **[Page]**

## remove

Remove page

### Parameters

* `page` **([String][9] | Page)** Page or page id
* `page` **([String][9] | [Page])** Page or page id
* `opts` (optional, default `{}`)

### Examples
Expand All @@ -82,7 +84,7 @@ const somePage = pageManager.get('page-id');
pageManager.remove(somePage);
```

Returns **Page**
Returns **[Page]**

## get

Expand All @@ -98,7 +100,7 @@ Get page by id
const somePage = pageManager.get('page-id');
```

Returns **Page**
Returns **[Page]**

## getMain

Expand All @@ -110,7 +112,7 @@ Get main page (the first one available)
const mainPage = pageManager.getMain();
```

Returns **Page**
Returns **[Page]**

## getAll

Expand All @@ -122,15 +124,15 @@ Get all pages
const arrayOfPages = pageManager.getAll();
```

Returns **[Array][10]\<Page>**
Returns **[Array][10]<[Page]>**

## select

Change the selected page. This will switch the page rendered in canvas

### Parameters

* `page` **([String][9] | Page)** Page or page id
* `page` **([String][9] | [Page])** Page or page id
* `opts` (optional, default `{}`)

### Examples
Expand All @@ -154,7 +156,7 @@ Get the selected page
const selectedPage = pageManager.getSelected();
```

Returns **Page**
Returns **[Page]**

[1]: #add

Expand Down
13 changes: 9 additions & 4 deletions src/device_manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default () => {
devices = new Devices();
(c.devices || []).forEach(dv => this.add(dv.id || dv.name, dv.width, dv));
devices.on('add', (m, c, o) => em.trigger(evAdd, m, o));
this.devices = devices;

return this;
},
Expand Down Expand Up @@ -125,7 +126,7 @@ export default () => {
* @param {String} name Name of the device
* @returns {[Device]}
* @example
* var device = deviceManager.get('Tablet');
* const device = deviceManager.get('Tablet');
* console.log(JSON.stringify(device));
* // {name: 'Tablet', width: '900px'}
*/
Expand All @@ -134,13 +135,17 @@ export default () => {
},

/**
* Return all devices.
* @return {Collection}
* Return all devices
* @returns {Array<[Device]>}
* @example
* var devices = deviceManager.getAll();
* const devices = deviceManager.getDevices();
* console.log(JSON.stringify(devices));
* // [{name: 'Desktop', width: ''}, ...]
*/
getDevices() {
return devices.models;
},

getAll() {
return devices;
},
Expand Down
18 changes: 10 additions & 8 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
* * [select](#select)
* * [getSelected](#getselected)
*
* [Page]: page.html
*
* @module Pages
*/

Expand Down Expand Up @@ -141,7 +143,7 @@ export default () => {
* Add new page
* @param {Object} props Page properties
* @param {Object} [opts] Options
* @returns {Page}
* @returns {[Page]}
* @example
* const newPage = pageManager.add({
* id: 'new-page-id', // without an explicit ID, a random one will be created
Expand All @@ -163,8 +165,8 @@ export default () => {

/**
* Remove page
* @param {String|Page} page Page or page id
* @returns {Page}
* @param {String|[Page]} page Page or page id
* @returns {[Page]}
* @example
* const removedPage = pageManager.remove('page-id');
* // or by passing the page
Expand All @@ -185,7 +187,7 @@ export default () => {
/**
* Get page by id
* @param {String} id Page id
* @returns {Page}
* @returns {[Page]}
* @example
* const somePage = pageManager.get('page-id');
*/
Expand All @@ -195,7 +197,7 @@ export default () => {

/**
* Get main page (the first one available)
* @returns {Page}
* @returns {[Page]}
* @example
* const mainPage = pageManager.getMain();
*/
Expand All @@ -206,7 +208,7 @@ export default () => {

/**
* Get all pages
* @returns {Array<Page>}
* @returns {Array<[Page]>}
* @example
* const arrayOfPages = pageManager.getAll();
*/
Expand All @@ -223,7 +225,7 @@ export default () => {

/**
* Change the selected page. This will switch the page rendered in canvas
* @param {String|Page} page Page or page id
* @param {String|[Page]} page Page or page id
* @returns {this}
* @example
* pageManager.select('page-id');
Expand All @@ -242,7 +244,7 @@ export default () => {

/**
* Get the selected page
* @returns {Page}
* @returns {[Page]}
* @example
* const selectedPage = pageManager.getSelected();
*/
Expand Down

0 comments on commit 6729824

Please sign in to comment.