Skip to content

Commit

Permalink
feat: minor jsdoc tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinEberhardt committed Jan 4, 2023
1 parent b9905e1 commit 7f29289
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 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;
14 changes: 7 additions & 7 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}}
export class {{@key}} {

static propertyTypes: Array<{name: string, type: string}> = [
Expand All @@ -15,9 +18,6 @@ export class {{@key}} {
];

{{#each properties}}
{{#if description}}
// {{description}}
{{/if}}
public {{@key}}{{#unless _required}}?{{/unless}}: {{typeConvert this}};
{{/each}}
}
}
30 changes: 18 additions & 12 deletions template/api.ts.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import { request } from "./request";
import { Parameter, ParameterBuilder } from "./parameterBuilder";
import { deserialize, serialize } from "./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}}
*/
export default class Api{{_tag.name}} {
private config: Configuration;

Expand All @@ -25,12 +23,20 @@ export default class Api{{_tag.name}} {
{{#each this}}
{{#ifEquals ../../_tag.name _tag.name}}

{{#if summary}}// {{summary}}{{/if}}
{{#if description}}// {{description}}{{/if}}
{{#if tags}}// tags: {{tags}}{{/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}}{{#if _optional}}?{{/if}}:
Expand Down
2 changes: 2 additions & 0 deletions template/model.ts.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}}

export const models: string[] = [
Expand Down

0 comments on commit 7f29289

Please sign in to comment.