Skip to content

Commit 30bcd3d

Browse files
docs: additional docs
1 parent 0f62a91 commit 30bcd3d

File tree

13 files changed

+77
-13
lines changed

13 files changed

+77
-13
lines changed

docs/cli/build.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `jtd-codebuild <path>`
2+
3+
This command generates code from JSON Type Definition IDL files.
4+
5+
## Usage
6+
7+
```bash
8+
jtd-codebuild <path>
9+
```
10+
11+
### Arguments
12+
13+
- `<path>`: The path that contains `jtd-codebuild.json` file. If this is not provided, the current directory is used. See [Quick Example][quick-example] or [Configuration] for how to write `jtd-codebuild.json`.
14+
15+
[quick-example]: ../../README.md#quick-example
16+
[Configuration]: ../codegen/config/index.md
17+

docs/cli/init.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# `jtd-codebuild <path> init [--preset <preset>]`
2+
3+
This command initializes a `jtd-codebuild.json` file in the given path.
4+
5+
## Usage
6+
7+
```bash
8+
jtd-codebuild <path> init [--preset <preset>]
9+
```
10+
11+
### Arguments
12+
13+
- `<path>`: The path to initialize the `jtd-codebuild.json` file. If this is not provided, the current directory is used.
14+
15+
### Options
16+
17+
- `--preset <preset>`: The preset to use for the initialization. If this is not provided, the `config` preset is used by default. See [Presets](#presets) for available presets.
18+
19+
20+
## Presets
21+
22+
Presets are predefined configurations that can be used to quickly initialize a `jtd-codebuild.json` configuration file and related files.
23+
24+
Currently, 3 presets are available:
25+
26+
- `config`: Initializes a configuration file with default values. If `--preset` is not provided, this preset is used by default.
27+
- `project`: Initializes a configuration file with a project structure.
28+
- `workspace`: Initializes a workspace configuration file.

docs/codegen/config/index.md renamed to docs/codegen/config/project.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Configuration
1+
# Project Configuration
22

33
`jtd-codebuild <path>` CLI finds the configuration file in the given path and generates the code based on the configuration.
44

@@ -84,3 +84,10 @@ Check each language's configuration for more details.
8484
- [Ruby](./ruby.md)
8585
- [Rust](./rust.md)
8686
- [Typescript](./typescript.md)
87+
88+
## Substitutes
89+
90+
`jtd-codebuild.json` supports the following substitutes.
91+
92+
- `<projectRoot>`: The root directory of the project. It is same as the directory that `jtd-codebuild.json` is in.
93+
- `<workspaceRoot>`: The root directory of the workspace. `jtd-codebuild` searches for the closest parent which contains `jtd-codebuild-workspace.json` file, and uses that directory as the workspace root. If `jtd-codebuild` fails to find the workspace root, it uses the project root as the workspace root.

docs/codegen/config/workspace.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Workspace Configuration
2+
3+
`jtd-codebuild` supports multiple projects in a workspace. You can define a workspace configuration file `jtd-codebuild-workspace.json` to manage multiple projects in a workspace.
4+
5+
> [!NOTE]
6+
> The file name should be `jtd-codebuild-workspace.json`. No other file name is allowed.
7+
8+
## Configuration Options
9+
10+
Currently, no configuration options are available for workspace configuration, and the only purpose of the `jtd-codebuild-workspace.json` file is to find where the workspace root is.

docs/codegen/idl/inheritance.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Inheritance
22

3-
By default, [jtd-codegen] does not support inheritance.
3+
By default, [JSON Type Definition][jsontypedef.com] does not support inheritance.
44

55
But by using `jtd-codebuild`, you can define inheritance between type definitions.
66
You can do this by using `extends` keyword like below.
@@ -45,10 +45,11 @@ Chef:
4545
extends: [Person, MyRestaurantMixin]
4646
```
4747
48-
These `extends` properties will be processed by `jtd-codebuild`, and every properties will be merged into one schema.
48+
If a class or classes are given in the `extends` keyword, the properties of the parent classes are merged into the child class.
4949

50-
> [IMPORTANT]
50+
> [!IMPORTANT]
5151
> Note that this feature does not programatically inherit the classes in the generated code.
5252
> It only merges the properties of the parent schemas into the child schema.
5353

54+
[jsontypedef.com]: https://jsontypedef.com/docs/
5455
[jtd-codegen]: https://jsontypedef.com/docs/jtd-codegen/

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
- IDL
77
- [JSON Type Definition](./codegen/idl/json-typedef.md)
88
- [Inheritance](./codegen/idl/inheritance.md)
9-
- [Configuration](./codegen/config/index.md)
9+
- [Workspace Configuration](./codegen/config/workspace.md)
10+
- [Project Configuration](codegen/config/project.md)
1011
- [C#](./codegen/config/csharp.md)
1112
- [Go](./codegen/config/go.md)
1213
- [Java](./codegen/config/java.md)

jtd_codebuild/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def cli(ctx: Context, path: str):
1919
@click.option(
2020
"--preset",
2121
"-p",
22-
type=click.Choice(["config", "module", "workspace"]),
22+
type=click.Choice(["config", "project", "workspace"]),
2323
default="config",
2424
)
2525
def init(ctx: Context, preset: str):

jtd_codebuild/commands/_init.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from jtd_codebuild.utils.fs import resolve
33
from jtd_codebuild.preset.config import ConfigPreset
44
from jtd_codebuild.preset.workspace import WorkspacePreset
5-
from jtd_codebuild.preset.module import ModulePreset
5+
from jtd_codebuild.preset.project import ProjectPreset
66
from ._command import Command
77

88

@@ -21,7 +21,7 @@ def run(
2121
ConfigPreset(logger=self.logger).generate(path)
2222
elif preset == "workspace":
2323
WorkspacePreset(logger=self.logger).generate(path)
24-
elif preset == "module":
25-
ModulePreset(logger=self.logger).generate(path)
24+
elif preset == "project":
25+
ProjectPreset(logger=self.logger).generate(path)
2626
else:
2727
raise ValueError(f"Unknown preset {preset}")

jtd_codebuild/preset/module/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# flake8: noqa: F401
2+
3+
from ._preset import ProjectPreset

0 commit comments

Comments
 (0)