Skip to content

Commit

Permalink
docs: update method names (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusJx authored Sep 16, 2023
1 parent f4f55c5 commit f5103ee
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- main

jobs:
build:
test:
runs-on: ubuntu-latest

strategy:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ testResults.xml
/out/
/test.js
/test.ts
/docs/
/docs/
.vscode
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ npm install -g java-ts-definition-generator java-bridge

## Command line usage

```
```text
java-ts-gen <output> <classnames..>
Positionals:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`.
2 changes: 1 addition & 1 deletion src/TypescriptDefinitionGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/generators/DefinitionGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
* ```
Expand Down

0 comments on commit f5103ee

Please sign in to comment.