Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump documentation from 13.2.5 to 14.0.3 #6071

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions docs/api.js → docs/api.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
// This script uses documentation to generate API Reference files
const path = require('path');
const documentation = require('documentation');
const fs = require('fs');
import { join, basename, dirname } from 'path';
import { build, formats } from 'documentation';
import { fileURLToPath } from 'url';
import { existsSync, writeFileSync } from 'fs';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const docRoot = __dirname;
const srcRoot = path.join(docRoot, '../src/');
const START_EVENTS = '{START_EVENTS}';
const END_EVENTS = '{END_EVENTS}';
const REPLACE_EVENTS = '{REPLACE_EVENTS}';
const srcRoot = join(docRoot, '../src/');
const START_EVENTS = '{START\\_EVENTS}';
const END_EVENTS = '{END\\_EVENTS}';
const REPLACE_EVENTS = '{REPLACE\\_EVENTS}';

const log = (...args) => console.log(...args);

const getEventsMdFromTypes = async (filePath) => {
const dirname = filePath.replace(path.basename(filePath), '');
const dirname = filePath.replace(basename(filePath), '');
const typesFilePath = `${dirname}types.ts`;

if (fs.existsSync(typesFilePath)) {
const resTypes = await documentation
.build([typesFilePath], { shallow: true })
.then((cm) => documentation.formats.md(cm /*{ markdownToc: true }*/));
if (existsSync(typesFilePath)) {
const resTypes = await build([typesFilePath], { shallow: true }).then((cm) =>
formats.md(cm /*{ markdownToc: true }*/),
);
const indexFrom = resTypes.indexOf(START_EVENTS) + START_EVENTS.length;
const indexTo = resTypes.indexOf(END_EVENTS);
// console.log(`${resTypes}`)
Expand Down Expand Up @@ -85,13 +90,12 @@ async function generateDocs() {
].map(async (file) => {
const filePath = `${srcRoot}/${file[0]}`;

if (!fs.existsSync(filePath)) {
if (!existsSync(filePath)) {
throw `File not found '${filePath}'`;
}

return documentation
.build([filePath], { shallow: true })
.then((cm) => documentation.formats.md(cm /*{ markdownToc: true }*/))
return build([filePath], { shallow: true })
.then((cm) => formats.md(cm /*{ markdownToc: true }*/))
.then(async (output) => {
let addLogs = [];
let result = output
Expand All @@ -114,7 +118,7 @@ async function generateDocs() {
result = eventsMd ? result.replace(REPLACE_EVENTS, `## Available Events\n${eventsMd}`) : result;
}

fs.writeFileSync(`${docRoot}/api/${file[1]}`, result);
writeFileSync(`${docRoot}/api/${file[1]}`, result);
log('Created', file[1], addLogs.length ? `(${addLogs.join(', ')})` : '');
});
}),
Expand Down
8 changes: 4 additions & 4 deletions docs/api/asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Get asset type.
asset.getType(); // -> 'image'
```

Returns **[String][1]**
Returns **[String][1]** 

## getSrc

Expand All @@ -31,7 +31,7 @@ Get asset URL.
asset.getSrc(); // -> 'https://.../image.png'
```

Returns **[String][1]**
Returns **[String][1]** 

## getFilename

Expand All @@ -46,7 +46,7 @@ asset.getFilename(); // -> 'image.png'
asset.getFilename(); // -> 'image'
```

Returns **[String][1]**
Returns **[String][1]** 

## getExtension

Expand All @@ -61,6 +61,6 @@ asset.getExtension(); // -> 'png'
asset.getExtension(); // -> ''
```

Returns **[String][1]**
Returns **[String][1]** 

[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
16 changes: 8 additions & 8 deletions docs/api/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ editor.on('asset:upload:error', (error) => { ... });
editor.on('asset:upload:response', (res) => { ... });
```

* `asset:custom` Event to use in case of [custom Asset Manager UI](https://grapesjs.com/docs/modules/Assets.html#customization).
* `asset:custom` Event to use in case of [custom Asset Manager UI](https\://grapesjs.com/docs/modules/Assets.html#customization).

```javascript
editor.on('asset:custom', ({ container, assets, ... }) => { ... });
Expand Down Expand Up @@ -148,7 +148,7 @@ Checks if the asset manager is open
assetManager.isOpen(); // true | false
```

Returns **[Boolean][15]**
Returns **[Boolean][15]** 

## add

Expand Down Expand Up @@ -176,7 +176,7 @@ width: 200,
assetManager.add([{ src: 'img2.jpg' }, { src: 'img2.png' }]);
```

Returns **[Asset]**
Returns **[Asset]** 

## get

Expand All @@ -192,19 +192,19 @@ Return asset by URL
const asset = assetManager.get('http://img.jpg');
```

Returns **([Asset] | null)**
Returns **([Asset] | null)** 

## getAll

Return the global collection, containing all the assets

Returns **Collection<[Asset]>**
Returns **Collection<[Asset]>**&#x20;

## getAllVisible

Return the visible collection, which contains assets actually rendered

Returns **Collection<[Asset]>**
Returns **Collection<[Asset]>**&#x20;

## remove

Expand All @@ -213,7 +213,7 @@ Remove asset
### Parameters

* `asset` **([String][13] | [Asset])** Asset or asset URL
* `opts` **RemoveOptions?**
* `opts` **RemoveOptions?**&#x20;

### Examples

Expand All @@ -230,7 +230,7 @@ Returns **[Asset]** Removed asset

Return the Asset Manager Container

Returns **[HTMLElement][16]**
Returns **[HTMLElement][16]**&#x20;

[1]: https://github.com/GrapesJS/grapesjs/blob/master/src/asset_manager/config/config.ts

Expand Down
10 changes: 5 additions & 5 deletions docs/api/block.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@

Get block id

Returns **[String][1]**
Returns **[String][1]**&#x20;

## getLabel

Get block label

Returns **[String][1]**
Returns **[String][1]**&#x20;

## getMedia

Get block media

Returns **[String][1]**
Returns **[String][1]**&#x20;

## getContent

Get block content

Returns **([Object][2] | [String][1] | [Array][6]<([Object][2] | [String][1])>)**
Returns **([Object][2] | [String][1] | [Array][6]<([Object][2] | [String][1])>)**&#x20;

## getCategoryLabel

Get block category label

Returns **[String][1]**
Returns **[String][1]**&#x20;

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

Expand Down
20 changes: 10 additions & 10 deletions docs/api/block_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ editor.on('block:drag:stop', (component, block) => { ... });
editor.on('block:category:update', ({ category, changes }) => { ... });
```

* `block:custom` Event to use in case of [custom Block Manager UI](https://grapesjs.com/docs/modules/Blocks.html#customization).
* `block:custom` Event to use in case of [custom Block Manager UI](https\://grapesjs.com/docs/modules/Blocks.html#customization).

```javascript
editor.on('block:custom', ({ container, blocks, ... }) => { ... });
Expand All @@ -92,7 +92,7 @@ editor.on('block', ({ event, model, ... }) => { ... });

Get configuration object

Returns **[Object][2]**
Returns **[Object][2]**&#x20;

## add

Expand Down Expand Up @@ -135,7 +135,7 @@ console.log(JSON.stringify(block));
// {label: 'Heading', content: '<h1>Put your ...', ...}
```

Returns **[Block]**
Returns **[Block]**&#x20;

## getAll

Expand All @@ -149,13 +149,13 @@ console.log(JSON.stringify(blocks));
// [{label: 'Heading', content: '<h1>Put your ...'}, ...]
```

Returns **Collection<[Block]>**
Returns **Collection<[Block]>**&#x20;

## getAllVisible

Return the visible collection, which containes blocks actually rendered

Returns **Collection<[Block]>**
Returns **Collection<[Block]>**&#x20;

## remove

Expand All @@ -182,28 +182,28 @@ Returns **[Block]** Removed block
Get all available categories.
It's possible to add categories only within blocks via 'add()' method

Returns **([Array][4] | Collection)**
Returns **([Array][4] | Collection)**&#x20;

## getContainer

Return the Blocks container element

Returns **[HTMLElement][5]**
Returns **[HTMLElement][5]**&#x20;

## getDragBlock

Returns currently dragging block.
Updated when the drag starts and cleared once it's done.

Returns **([Block] | [undefined][6])**
Returns **([Block] | [undefined][6])**&#x20;

## getBlocksByCategory

Get blocks by category.

### Parameters

* `blocks` **[Array][4]\<Block>?**
* `blocks` **[Array][4]\<Block>?**&#x20;

### Examples

Expand All @@ -219,7 +219,7 @@ const myFilteredBlocks: Block[] = [...];
blockManager.getBlocksByCategorymyFilteredBlocks
```

Returns **[Array][4]\<BlocksByCategory>**
Returns **[Array][4]\<BlocksByCategory>**&#x20;

## render

Expand Down
Loading