Skip to content

Commit

Permalink
indentations fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
swastiksuvam55 committed Oct 9, 2023
1 parent 4df68bc commit 4023882
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,36 @@ class Generator {
});
}

// eslint-disable-next-line sonarjs/cognitive-complexity

/**
* Generates files from a given template and an AsyncAPIDocument object.
*
* @async
* @example
* await generator.generate(myAsyncAPIdocument);
* console.log('Done!');
*
* @example
* generator
* .generate(myAsyncAPIdocument)
* .then(() => {
* console.log('Done!');
* })
* .catch(console.error);
*
* @example <caption>Using async/await</caption>
* try {
* await generator.generate(myAsyncAPIdocument);
* console.log('Done!');
* } catch (e) {
* console.error(e);
* }
*
* @param {AsyncAPIDocument | string} asyncapiDocument - AsyncAPIDocument object 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.
* Remember to use the right options for the right parser depending on the template you are using.
* @return {Promise<void>} A Promise that resolves when the generation is completed.
*/

async generate(asyncapiDocument, parseOptions = {}) {
this.validateAsyncAPIDocument(asyncapiDocument);
this.setupOutput();
Expand Down Expand Up @@ -182,7 +195,6 @@ class Generator {
this.asyncapi = this.originalAsyncAPI = asyncapiDocument;
}

// Setup the output based on the configured options
/**
* Sets up the output configuration based on the specified output type.
*
Expand Down Expand Up @@ -227,22 +239,22 @@ class Generator {
* If the debug option is enabled, the log level is set to 'debug'.
*
* @returns {void}
*/
*/
setLogLevel() {
if (this.debug) log.setLevel('debug');
}

/**
* Installs and sets up the template for code generation.
*
* This function installs the specified template using the provided installation option,
* sets up the necessary directory paths, loads the template configuration, and returns
* information about the installed template.
*
* @async
* @returns {Promise<{ templatePkgName: string, templatePkgPath: string }>}
* A promise that resolves to an object containing the name and path of the installed template.
*/
* Installs and sets up the template for code generation.
*
* This function installs the specified template using the provided installation option,
* sets up the necessary directory paths, loads the template configuration, and returns
* information about the installed template.
*
* @async
* @returns {Promise<{ templatePkgName: string, templatePkgPath: string }>}
* A promise that resolves to an object containing the name and path of the installed template.
*/
async installAndSetupTemplate() {
const { name: templatePkgName, path: templatePkgPath } = await this.installTemplate(this.install);

Expand All @@ -267,7 +279,7 @@ class Generator {
* @async
* @param {*} parseOptions - Options for parsing the AsyncAPI document.
* @returns {Promise<void>} A promise that resolves when the configuration is completed.
*/
*/
async configureTemplateWorkflow(parseOptions) {
// Parse input and validate template configuration
await this.parseInput(this.asyncapi, parseOptions);
Expand Down Expand Up @@ -295,7 +307,7 @@ class Generator {
*
* @async
* @returns {Promise<void>} A promise that resolves when the entrypoint logic is completed.
*/
*/
async handleEntrypoint() {
if (this.entrypoint) {
const entrypointPath = path.resolve(this.templateContentDir, this.entrypoint);
Expand All @@ -322,7 +334,7 @@ class Generator {
*
* @async
* @returns {Promise<void>} A promise that resolves when the after-hook execution is completed.
*/
*/
async executeAfterHook() {
await this.launchHook('generate:after');
}
Expand Down

0 comments on commit 4023882

Please sign in to comment.