diff --git a/docs/api.md b/docs/api.md index 41fb622f7..a02a8aae3 100644 --- a/docs/api.md +++ b/docs/api.md @@ -4,6 +4,22 @@ weight: 75 --- Reference API documentation for AsyncAPI Generator library. +## Classes + +
+
Generator
+
+
+ +## Typedefs + +
+
TemplateRenderMetadata : Object
+
+
TemplateRenderResult : Object
+
+
+ @@ -29,9 +45,9 @@ Reference API documentation for AsyncAPI Generator library. * [.originalAsyncAPI](#Generator+originalAsyncAPI) : `String` * [.generate(asyncapiDocument)](#Generator+generate) ⇒ `Promise` * [.configureTemplate()](#Generator+configureTemplate) - * [.generateFromString(asyncapiString, [parseOptions])](#Generator+generateFromString) ⇒ `Promise` - * [.generateFromURL(asyncapiURL)](#Generator+generateFromURL) ⇒ `Promise` - * [.generateFromFile(asyncapiFile)](#Generator+generateFromFile) ⇒ `Promise` + * [.generateFromString(asyncapiString, [parseOptions])](#Generator+generateFromString) ⇒ `Promise.<(TemplateRenderResult|undefined)>` + * [.generateFromURL(asyncapiURL)](#Generator+generateFromURL) ⇒ `Promise.<(TemplateRenderResult|undefined)>` + * [.generateFromFile(asyncapiFile)](#Generator+generateFromFile) ⇒ `Promise.<(TemplateRenderResult|undefined)>` * [.installTemplate([force])](#Generator+installTemplate) * _static_ * [.getTemplateFile(templateName, filePath, [templatesDir])](#Generator.getTemplateFile) ⇒ `Promise` @@ -342,3 +358,27 @@ const content = await Generator.getTemplateFile('@asyncapi/html-template', 'part const Generator = require('@asyncapi/generator'); const content = await Generator.getTemplateFile('@asyncapi/html-template', 'partials/content.html', '~/my-templates'); ``` + + + +* TemplateRenderMetadata : `Object`** : +**Kind**: global typedef +**Properties** + +| Name | Type | +| --- | --- | +| fileName | `string` | +| permissions | `string` | + + + + +* TemplateRenderResult : `Object`** : +**Kind**: global typedef +**Properties** + +| Name | Type | +| --- | --- | +| content | `string` | +| metadata | [`TemplateRenderMetadata`](#TemplateRenderMetadata) | + diff --git a/lib/generator.js b/lib/generator.js index 2caf855ac..1fdd9f5eb 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -213,6 +213,17 @@ class Generator { this.nunjucks = configureNunjucks(this.debug, this.templateDir); } } + /** + * @typedef {Object} TemplateRenderMetadata + * @property {string} fileName + * @property {string} permissions + */ + + /** + * @typedef {Object} TemplateRenderResult + * @property {string} content + * @property {TemplateRenderMetadata} metadata + */ /** * Generates files from a given template and AsyncAPI string. @@ -250,7 +261,7 @@ class Generator { * * @param {String} asyncapiString AsyncAPI string to use as source. * @param {Object} [parseOptions={}] AsyncAPI Parser parse options. Check out {@link https://www.github.com/asyncapi/parser-js|@asyncapi/parser} for more information. - * @return {Promise} + * @return {Promise} */ async generateFromString(asyncapiString, parseOptions = {}) { if (!asyncapiString || typeof asyncapiString !== 'string') throw new Error('Parameter "asyncapiString" must be a non-empty string.'); @@ -288,7 +299,7 @@ class Generator { * } * * @param {String} asyncapiURL Link to AsyncAPI file - * @return {Promise} + * @return {Promise} */ async generateFromURL(asyncapiURL) { const doc = await fetchSpec(asyncapiURL); @@ -315,7 +326,7 @@ class Generator { * } * * @param {String} asyncapiFile AsyncAPI file to use as source. - * @return {Promise} + * @return {Promise} */ async generateFromFile(asyncapiFile) { const doc = await readFile(asyncapiFile, { encoding: 'utf8' });