in src/docgen/transpile/java.ts [116:165]
public callable(callable: reflect.Callable): transpile.TranspiledCallable {
const type = this.type(callable.parentType);
const parameters = callable.parameters.sort(this.optionalityCompare);
const requiredParams = parameters.filter((p) => !p.optional);
const optionalParams = parameters.filter((p) => p.optional);
const name = callable.name;
// simulate Java method overloading
const inputLists = prefixArrays(optionalParams).map((optionals) => {
return [...requiredParams, ...optionals].map((p) => this.formatParameter(this.parameter(p)));
});
const signatures = inputLists.map((inputs) => {
return this.formatSignature(name, inputs);
});
let invocations;
if (this.isClassBuilderGenerated(callable)) {
const struct = this.extractFirstStruct(parameters);
// render using Java builder syntax (show no overloads)
invocations = [this.formatClassBuilder(type, parameters, struct)];
// flatten out the parameters so the user doesn't have to jump between
// docs of Foo and FooProps
for (const property of struct.allProperties) {
const parameter = propertyToParameter(callable, property);
parameters.push(parameter);
}
} else {
invocations = callable.kind === reflect.MemberKind.Initializer
// render with `new Class` syntax (showing all constructor overloads)
? inputLists.map((inputs) => this.formatClassInitialization(type, inputs))
// render invocation as method calls (showing all method overloads)
: inputLists.map((inputs) => this.formatInvocation(type, inputs, name));
}
return {
name,
parentType: type,
import: this.formatImport(type),
parameters,
signatures,
invocations,
};
}