Skip to content

Commit 887b314

Browse files
committed
docs: update documentation for TypescriptBulkDefinitionGenerator
Signed-off-by: Markus <[email protected]>
1 parent caff47b commit 887b314

File tree

6 files changed

+51
-6
lines changed

6 files changed

+51
-6
lines changed

Diff for: Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
edition = "2021"
33
name = "java"
4-
version = "2.1.8"
4+
version = "2.2.0"
55

66
[lib]
77
crate-type = ["cdylib"]

Diff for: package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "java-bridge",
3-
"version": "2.1.8",
3+
"version": "2.2.0",
44
"main": "dist/index.prod.min.js",
55
"types": "dist/ts-src/index.d.ts",
66
"description": "A bridge between Node.js and Java APIs",

Diff for: test/system_test/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
"typescript": "^4.9.3"
3434
},
3535
"dependencies": {
36-
"java-bridge": "^2.1.8-beta.2"
36+
"java-bridge": "latest"
3737
}
3838
}

Diff for: ts-src/TypescriptBulkDefinitionGenerator.ts

+45
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,46 @@ import TypescriptDefinitionGenerator, {
33
ProgressCallback,
44
} from './TypescriptDefinitionGenerator';
55

6+
/**
7+
* Generates a lot of definitions for a lot of modules at once.
8+
* This caches the definitions for each module, so that if a module is used in multiple
9+
* other modules, it only needs to be generated once. This is a lot faster than generating
10+
* each module individually. It also generates the definitions in the correct order, so that
11+
* dependencies are always generated before the modules that depend on them.
12+
*
13+
* ## Example
14+
* ```ts
15+
* const generator = new TypescriptBulkDefinitionGenerator();
16+
*
17+
* // Generate definitions for the provided modules
18+
* await generator.generate([
19+
* 'java.lang.String',
20+
* 'java.util.List',
21+
* 'java.util.Map',
22+
* 'java.io.FileOutputStream',
23+
* 'java.io.FileInputStream',
24+
* 'java.io.File',
25+
* 'java.lang.System',
26+
* ]);
27+
*
28+
* // Save the definitions to a directory
29+
* await generator.save('javaDefinitions');
30+
* ```
31+
*
32+
* @see TypescriptDefinitionGenerator
33+
*/
634
export class TypescriptBulkDefinitionGenerator {
735
private readonly declarations: ModuleDeclaration[] = [];
836
private readonly resolvedImports: string[] = [];
937

38+
/**
39+
* Generate the definitions for a module.
40+
*
41+
* @see TypescriptDefinitionGenerator.generate
42+
* @param classnames the fully qualified names of the classes to generate
43+
* @param progressCallback a callback that is called when a class is generated
44+
* @returns the number of classes that were generated
45+
*/
1046
public async generate(
1147
classnames: string[],
1248
progressCallback: ProgressCallback | null = null
@@ -27,10 +63,19 @@ export class TypescriptBulkDefinitionGenerator {
2763
return numResolved;
2864
}
2965

66+
/**
67+
* Save the generated definitions to a directory.
68+
*
69+
* @see TypescriptDefinitionGenerator.save
70+
* @param output the directory to save the definitions to
71+
*/
3072
public async save(output: string): Promise<void> {
3173
await TypescriptDefinitionGenerator.save(this.declarations, output);
3274
}
3375

76+
/**
77+
* Get the generated definitions.
78+
*/
3479
public get moduleDeclarations(): ModuleDeclaration[] {
3580
return this.declarations;
3681
}

0 commit comments

Comments
 (0)