Skip to content

Commit

Permalink
added jsdocs inference and generator
Browse files Browse the repository at this point in the history
  • Loading branch information
zianksm committed Dec 11, 2022
1 parent a7dccb1 commit bbff97c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/implementation/javascript/assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export class JavascriptMethodAssembler {
// TODO : make return type in Promise<T>
private buildOutputLiteral(input: iochild) {
const outputType = this.determineType(input.type);
input.inferredTypes = outputType;
input.jsDoc = this.docGen.generateOutput(input);

return outputType;
}
Expand Down Expand Up @@ -131,11 +133,11 @@ export class JavascriptMethodAssembler {

private buildInputLiteral(input: iochild): string {
const inputType = this.determineType(input.type);
const inputName = this.determineInputName(input).name;

input.inferredTypes = inputType;
input.jsDoc = this.docGen.generateParam(input);

const inputName = this.determineInputName(input).name;
const inputLiteral = inputName.concat(COLON, SPACE, inputType);

return inputLiteral;
Expand Down Expand Up @@ -167,7 +169,7 @@ export class JavascriptMethodAssembler {
}

private parseFnSignature(fnObj: Branch) {
console.log(fnObj.attributes.inputs);
console.log(fnObj.attributes.outputs);

const signature = FORMAT_LINE.concat(
SPACE,
Expand Down
3 changes: 3 additions & 0 deletions src/implementation/javascript/js-doc-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ export class DocGen {
public generateParam(fragment: iochild) {
return `* @param {${fragment.inferredTypes}} ${fragment.name}`;
}
public generateOutput(fragment: iochild) {
return `@returns {Promise<${fragment.inferredTypes}>}`;
}
}

0 comments on commit bbff97c

Please sign in to comment.