Skip to content

Commit

Permalink
fix(bindgen): Identify array parameters in the README
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Mar 28, 2023
1 parent 24c16c3 commit e264678
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BinaryStream,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipelineNode
} from 'itk-wasm'
Expand All @@ -23,10 +24,10 @@ async function compressStringifyNode(
options: CompressStringifyOptions = {}
) : Promise<CompressStringifyNodeResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.BinaryStream },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryStream, data: { data: input } },
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BinaryStream,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipeline
} from 'itk-wasm'
Expand All @@ -27,10 +28,10 @@ async function compressStringify(
options: CompressStringifyOptions = {}
) : Promise<CompressStringifyResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.BinaryStream },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryStream, data: { data: input } },
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BinaryStream,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipelineNode
} from 'itk-wasm'
Expand All @@ -23,10 +24,10 @@ async function parseStringDecompressNode(
options: ParseStringDecompressOptions = {}
) : Promise<ParseStringDecompressNodeResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.BinaryStream },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryStream, data: { data: input } },
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BinaryStream,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipeline
} from 'itk-wasm'
Expand All @@ -27,10 +28,10 @@ async function parseStringDecompress(
options: ParseStringDecompressOptions = {}
) : Promise<ParseStringDecompressResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.BinaryStream },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryStream, data: { data: input } },
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
JsonObject,
Image,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipelineNode
} from 'itk-wasm'
Expand All @@ -24,11 +25,11 @@ async function applyPresentationStateToImageNode(
options: ApplyPresentationStateToImageOptions = {}
) : Promise<ApplyPresentationStateToImageNodeResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.JsonObject },
{ type: InterfaceTypes.Image },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryFile, data: { data: imageIn, path: "file0" } },
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
JsonObject,
Image,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipeline
} from 'itk-wasm'
Expand All @@ -28,11 +29,11 @@ async function applyPresentationStateToImage(
options: ApplyPresentationStateToImageOptions = {}
) : Promise<ApplyPresentationStateToImageResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.JsonObject },
{ type: InterfaceTypes.Image },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryFile, data: { data: imageIn, path: "file0" } },
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BinaryStream,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipelineNode
} from 'itk-wasm'
Expand All @@ -23,10 +24,10 @@ async function readDicomEncapsulatedPdfNode(
options: ReadDicomEncapsulatedPdfOptions = {}
) : Promise<ReadDicomEncapsulatedPdfNodeResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.BinaryStream },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } },
]

Expand Down
5 changes: 3 additions & 2 deletions packages/dicom/typescript/src/read-dicom-encapsulated-pdf.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BinaryStream,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipeline
} from 'itk-wasm'
Expand All @@ -27,10 +28,10 @@ async function readDicomEncapsulatedPdf(
options: ReadDicomEncapsulatedPdfOptions = {}
) : Promise<ReadDicomEncapsulatedPdfResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.BinaryStream },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } },
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
TextStream,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipelineNode
} from 'itk-wasm'
Expand All @@ -23,10 +24,10 @@ async function structuredReportToHtmlNode(
options: StructuredReportToHtmlOptions = {}
) : Promise<StructuredReportToHtmlNodeResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.TextStream },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } },
]

Expand Down
5 changes: 3 additions & 2 deletions packages/dicom/typescript/src/structured-report-to-html.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
TextStream,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipeline
} from 'itk-wasm'
Expand All @@ -27,10 +28,10 @@ async function structuredReportToHtml(
options: StructuredReportToHtmlOptions = {}
) : Promise<StructuredReportToHtmlResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.TextStream },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } },
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
TextStream,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipelineNode
} from 'itk-wasm'
Expand All @@ -23,10 +24,10 @@ async function structuredReportToTextNode(
options: StructuredReportToTextOptions = {}
) : Promise<StructuredReportToTextNodeResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.TextStream },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } },
]

Expand Down
5 changes: 3 additions & 2 deletions packages/dicom/typescript/src/structured-report-to-text.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
TextStream,
InterfaceTypes,
PipelineOutput,
PipelineInput,
runPipeline
} from 'itk-wasm'
Expand All @@ -27,10 +28,10 @@ async function structuredReportToText(
options: StructuredReportToTextOptions = {}
) : Promise<StructuredReportToTextResult> {

const desiredOutputs = [
const desiredOutputs: Array<PipelineOutput> = [
{ type: InterfaceTypes.TextStream },
]
const inputs: [ PipelineInput ] = [
const inputs: Array<PipelineInput> = [
{ type: InterfaceTypes.BinaryFile, data: { data: dicomFile, path: "file0" } },
]

Expand Down
9 changes: 6 additions & 3 deletions src/bindgen/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ function typescriptBindings(outputDir, buildDir, wasmBinaries, options, forNode=
resultsImportTypes.add(outputType)
}
resultContent += ` ${camelCase(output.name)}: ${outputType}\n\n`
readmeResultTable.push([`\`${camelCase(output.name)}\``, `*${outputType}*`, output.description])
const readmeOutputArray = output.itemsExpectedMax > 1 ? "[]" : ""
readmeResultTable.push([`\`${camelCase(output.name)}\``, `*${outputType}${readmeOutputArray}*`, output.description])
})
readmeResult += markdownTable(readmeResultTable, { align: ['c', 'c', 'l'] }) + '\n'

Expand Down Expand Up @@ -285,7 +286,8 @@ function typescriptBindings(outputDir, buildDir, wasmBinaries, options, forNode=
optionsImportTypes.add(parameterType)
}
optionsInterfaceContent += ` ${camelCase(parameter.name)}?: ${parameterType}\n\n`
readmeOptionsTable.push([`\`${camelCase(parameter.name)}\``, `*${parameterType}*`, parameter.description])
const readmeParameterArray = parameter.itemsExpectedMax > 1 ? "[]" : ""
readmeOptionsTable.push([`\`${camelCase(parameter.name)}\``, `*${parameterType}${readmeParameterArray}*`, parameter.description])
})
// Insert the import statement in the beginning for the file.
if(optionsImportTypes.size !== 0)
Expand Down Expand Up @@ -348,7 +350,8 @@ function typescriptBindings(outputDir, buildDir, wasmBinaries, options, forNode=
}
const typescriptType = interfaceJsonTypeToTypeScriptType.get(input.type)
functionContent += ` * @param {${typescriptType}} ${camelCase(input.name)} - ${input.description}\n`
readmeParametersTable.push([`\`${camelCase(input.name)}\``, `*${typescriptType}*`, input.description])
const readmeParameterArray = input.itemsExpectedMax > 1 ? "[]" : ""
readmeParametersTable.push([`\`${camelCase(input.name)}\``, `*${typescriptType}${readmeParameterArray}*`, input.description])
})
functionContent += ` *\n * @returns {Promise<${modulePascalCase}${nodeTextCamel}Result>} - result object\n`
functionContent += ` */\n`
Expand Down

0 comments on commit e264678

Please sign in to comment.