From f5103ee5b91ad819255cee95b91ece5e6994c6e4 Mon Sep 17 00:00:00 2001 From: Markus <28785953+MarkusJx@users.noreply.github.com> Date: Sat, 16 Sep 2023 14:36:34 +0200 Subject: [PATCH] docs: update method names (#4) --- .github/workflows/publish.yml | 3 ++- .github/workflows/test.yml | 2 +- .gitignore | 3 ++- README.md | 39 +++++++++++++-------------- src/TypescriptDefinitionGenerator.ts | 2 +- src/generators/DefinitionGenerator.ts | 2 +- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b2c0e4f..902d794 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,10 +7,11 @@ on: description: 'Dry run' type: boolean required: false - default: 'false' + default: false jobs: build: + permissions: write-all runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 624e85e..bc3fd38 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ on: - main jobs: - build: + test: runs-on: ubuntu-latest strategy: diff --git a/.gitignore b/.gitignore index ed21b3f..98c353d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ testResults.xml /out/ /test.js /test.ts -/docs/ \ No newline at end of file +/docs/ +.vscode \ No newline at end of file diff --git a/README.md b/README.md index c83a8de..2082736 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ npm install -g java-ts-definition-generator java-bridge ## Command line usage -``` +```text java-ts-gen Positionals: @@ -51,7 +51,7 @@ This will create a directory called `java` containing the definitions for the `j dependencies all inside subdirectories. The `java.lang.String` class will be saved to `./project/java/lang/String.ts`. Thus, the folder structure of `project` will look something like this: -``` +```text . ├── ... ├── java @@ -79,30 +79,27 @@ java-ts-gen ./project java.lang.String java.util.ArrayList ```ts import { TypescriptDefinitionGenerator } from 'java-ts-definition-generator'; -const generator = new TypescriptDefinitionGenerator('java.lang.String'); +const generator = new TypescriptDefinitionGenerator([ + 'java.lang.String', + 'java.util.List', +]); // Generate the typescript definitions -const definitions = await generator.generate(); +await generator.createModuleDeclarations(); // Save the definitions to a directory -await TypescriptDefinitionGenerator.save(definitions, './project'); +await TypescriptDefinitionGenerator.save('./project'); ``` -### Generate definitions for multiple classes +### Available generators -```ts -const generator = new TypescriptBulkDefinitionGenerator(); +The java declaration tree can be generated using two generators: -// Generate definitions for the provided modules -await generator.generate([ - 'java.lang.String', - 'java.util.List', - 'java.util.Map', - 'java.io.FileOutputStream', - 'java.io.FileInputStream', - 'java.io.File', - 'java.lang.System', -]); +- `JavaDefinitionGenerator`: This generator is the fastest, as it is written in Java. + Requires Java 11 or higher. +- `TsDefinitionGenerator`: This one is slower than the `JavaDefinitionGenerator` as it + is written in Typescript, but it works with any Java version. -// Save the definitions to a directory -await generator.save('javaDefinitions'); -``` +The best generator is automatically picked when instantiating the `TypescriptDefinitionGenerator` +class. If you still want to choose the generator yourself, you can pass an instance of +the `JavaDefinitionGenerator` or `TsDefinitionGenerator` into the constructor of the +`TypescriptDefinitionGenerator`. diff --git a/src/TypescriptDefinitionGenerator.ts b/src/TypescriptDefinitionGenerator.ts index 8df7824..88bf722 100644 --- a/src/TypescriptDefinitionGenerator.ts +++ b/src/TypescriptDefinitionGenerator.ts @@ -24,7 +24,7 @@ import { ConvertCallback, ModuleDeclaration } from './types'; * * const generator = new TypescriptDefinitionGenerator('java.lang.String'); * // Generate the typescript definitions - * await generator.generate(); + * await generator.createModuleDeclarations(); * * // Save the definitions to a directory * await generator.save('./project'); diff --git a/src/generators/DefinitionGenerator.ts b/src/generators/DefinitionGenerator.ts index 57cef19..651a163 100644 --- a/src/generators/DefinitionGenerator.ts +++ b/src/generators/DefinitionGenerator.ts @@ -28,7 +28,7 @@ export interface DefinitionGeneratorIf { * } from 'java-ts-definition-generator'; * * const generator = new TsDefinitionGenerator('java.lang.String'); - * const definitions = await generator.generate(); + * const definitions = await generator.createModuleDeclarations(); * * await TypescriptDefinitionGenerator.save(definitions, './project'); * ```