chore: Add docs

This commit is contained in:
Sidharth Vinod 2023-12-08 10:06:36 +05:30
parent edf32911be
commit b9bc518a0a
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
3 changed files with 22 additions and 11 deletions

View File

@ -97,7 +97,7 @@ mermaid.initialize(config);
#### Defined in
[mermaidAPI.ts:624](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L624)
[mermaidAPI.ts:623](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L623)
## Functions
@ -128,7 +128,7 @@ Return the last node appended
#### Defined in
[mermaidAPI.ts:278](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L278)
[mermaidAPI.ts:277](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L277)
---
@ -154,7 +154,7 @@ the cleaned up svgCode
#### Defined in
[mermaidAPI.ts:224](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L224)
[mermaidAPI.ts:223](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L223)
---
@ -179,7 +179,7 @@ the string with all the user styles
#### Defined in
[mermaidAPI.ts:154](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L154)
[mermaidAPI.ts:153](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L153)
---
@ -202,7 +202,7 @@ the string with all the user styles
#### Defined in
[mermaidAPI.ts:201](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L201)
[mermaidAPI.ts:200](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L200)
---
@ -229,7 +229,7 @@ with an enclosing block that has each of the cssClasses followed by !important;
#### Defined in
[mermaidAPI.ts:139](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L139)
[mermaidAPI.ts:138](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L138)
---
@ -255,7 +255,7 @@ Put the svgCode into an iFrame. Return the iFrame code
#### Defined in
[mermaidAPI.ts:255](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L255)
[mermaidAPI.ts:254](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L254)
---
@ -280,4 +280,4 @@ Remove any existing elements from the given document
#### Defined in
[mermaidAPI.ts:328](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L328)
[mermaidAPI.ts:327](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L327)

View File

@ -314,9 +314,21 @@ const executeQueue = async () => {
/**
* Parse the text and validate the syntax.
* @param text - The mermaid diagram definition.
* @param parseOptions - Options for parsing.
* @returns An object with the diagramType set to type of the diagram if valid. Otherwise false if parseOptions.suppressErrors is true.
* @param parseOptions - Options for parsing. @see {@link ParseOptions}
* @returns If valid, {@link ParseResult} otherwise `false` if parseOptions.suppressErrors is `true`.
* @throws Error if the diagram is invalid and parseOptions.suppressErrors is false or not set.
*
* @example
* ```js
* console.log(await mermaid.parse('flowchart \n a --> b'));
* // { diagramType: 'flowchart-v2' }
* console.log(await mermaid.parse('wrong \n a --> b', { suppressErrors: true }));
* // false
* console.log(await mermaid.parse('wrong \n a --> b', { suppressErrors: false }));
* // throws Error
* console.log(await mermaid.parse('wrong \n a --> b'));
* // throws Error
* ```
*/
const parse: typeof mermaidAPI.parse = async (text, parseOptions) => {
return new Promise((resolve, reject) => {

View File

@ -108,7 +108,6 @@ function processAndSetConfigs(text: string) {
* @returns An object with the `diagramType` set to type of the diagram if valid. Otherwise `false` if parseOptions.suppressErrors is `true`.
* @throws Error if the diagram is invalid and parseOptions.suppressErrors is false or not set.
*/
async function parse(
text: string,
parseOptions: ParseOptions & { suppressErrors: true }