Skip to content

Commit

Permalink
feat: jsdoc tweaks (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinEberhardt authored Jan 4, 2023
1 parent b63b163 commit ab4583d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
5 changes: 5 additions & 0 deletions helpers/docComment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const indent = (text) =>
// add a star before each newline and the start of the string
text.replace(/^/gm, " * ");

module.exports = indent;
12 changes: 6 additions & 6 deletions partials/model.handlebars
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{{#if description}}
/**
* {{description}}
* {{@key}}
{{#if description}}* {{description}}{{/if~}}
*
{{#each properties}}
* @param { {{~typeConvert this~}} } {{#if _required}}{{@key}}{{else}}[{{@key}}]{{/if}} {{#if description}} - {{description}}{{/if}}
{{/each}}
*/
{{/if}}
class {{@key}} {

static propertyTypes = [
Expand All @@ -15,9 +18,6 @@ class {{@key}} {
];

{{#each properties}}
{{#if description}}
// {{description}}
{{/if}}
{{@key}};
{{/each}}
}
29 changes: 18 additions & 11 deletions template/api.js.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ const request = require("./request");
const ParameterBuilder = require("./parameterBuilder");
const { deserialize, serialize } = require("./serializer");

/*
{{_info.title}}
{{info.description}}
Version: {{info.version}}
*/

{{#if _tag.description}}// {{_tag.description}}{{/if}}

/**
* {{_info.title}}
*
{{#if info.description}}{{docComment info.description}}{{/if}}
{{#if info.version}} * @version {{info.version}}{{/if}}
*/
class Api{{_tag.name}} {

constructor(config) {
Expand All @@ -24,11 +22,20 @@ class Api{{_tag.name}} {
{{#each this}}
{{#ifEquals ../../_tag.name _tag.name}}

{{#if summary}}// {{summary}}{{/if}}
{{#if description}}// {{description}}{{/if}}
/**
{{#if summary}}
* {{summary}}
*
{{/if}}
{{#if description}}
* {{description}}
*
{{/if}}
{{#if tags}} * @tags {{tags}}{{/if}}
{{#each _sortedParameters}}
// @param {{name}} {{description}}
* @param { {{~typeConvert schema ../../../_options~}} } {{name}} {{description}}
{{/each}}
*/
async {{operationId}}(
{{#each _sortedParameters}}
{{name}}
Expand Down
2 changes: 2 additions & 0 deletions template/model.js.handlebars
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{{#each components.schemas}}
{{> model}}

{{/each}}

{{#each components.inlineObjects}}
{{> model}}

{{/each}}

const models = [
Expand Down

0 comments on commit ab4583d

Please sign in to comment.