Skip to content

Commit

Permalink
Drafting outline
Browse files Browse the repository at this point in the history
  • Loading branch information
ambiguousname committed Aug 18, 2024
1 parent 901b6da commit c74be33
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@
- [Stringifiers](attrs/stringifiers.md)
- [Notes on Diplomat and safety](safety.md)
- [Backend developer guide](developer.md)
- [demo_gen](demo_gen/intro.md)
- [Configuring Markup](demo_gen/markup.md)
- [Configuring the Default Renderer](demo_gen/renderer.md)
- [Attributes](demo_gen/attributes.md)
1 change: 1 addition & 0 deletions src/demo_gen/attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Attributes
4 changes: 4 additions & 0 deletions src/demo_gen/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# demo_gen
See the tracking issue: https://github.com/rust-diplomat/diplomat/issues/604.

## Using demo_gen
25 changes: 25 additions & 0 deletions src/demo_gen/markup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Configuring Markup
Diplomat takes the `-l` or `--library-config` option (in `diplomat_tool::gen` this is the `library_config` parameter). This represents a path to a `.toml` file that demo_gen will then read and convert into `DemoConfig`.

Here's a sample .toml file for configuration (with comments for clarity):

```toml
# If false, demo_gen will automatically search all methods for functions it can generate demonstration JS for.
# If true, demo_gen will look for any methods explicitly flagged with #[diplomat::demo(generate)] to perform generation.
explicit-generation=true # default = false (bool)

# This removes the rendering/ folder.
hide-default-renderer=true # default = false (bool)

# Adjusts all imports that demo_gen creates to a specific module. Setting this will not generate the js/ folder.
#
# So for instance, this setting will adjust imports to: `import { type } from "icu4x";
module-name="icu4x" # (string)

# Adjusts all imports that demo_gen creates to a relative path where Diplomat JS output should be. Setting this will not generate the js/ folder.
#
# Setting this will adjust imports to: `import {type} from "../js/folder/here/index.mjs";
#
# Intended to be a mutually exclusive setting with module-name, although you can set both simultaneously to import modules from a relative path.
relative-js-path="../js/folder/here" # (string)
```
Empty file added src/demo_gen/renderer.md
Empty file.
6 changes: 3 additions & 3 deletions src/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ Diplomat currently supports the following backends:
- C
- C++
- JavaScript/TypeScript (using WASM)
- [demo_gen](./demo_gen/intro.md)
- Dart
- Kotlin (using JNA)

There is work in progress for a [Java backend] (using Panama), as well as a [demo-autogenerating backend]. We used to have a .NET backend but it was removed in a refactor, it may get added again.
There is work in progress for a [Java backend] (using Panama). We used to have a .NET backend but it was removed in a refactor, it may get added again.

We're happy to fix bugs or add configurability in the current backends if their produced output does not match what you need in your language. Details on how to write new backends is documented [later in this book](developer.html): you can do so as a third party library depending on `diplomat_core`, but we are also happy to accept these into Diplomat with the understanding that we'll only do minimal work to keep them working over time.

Expand All @@ -51,5 +52,4 @@ It is recommended to create a separate crate for the FFI interface. Diplomat wil


[Diplomat]: https://github.com/rust-diplomat/diplomat
[Java backend]: https://github.com/rust-diplomat/diplomat/issues/144
[demo-autogenerating backend]: https://github.com/rust-diplomat/diplomat/issues/604
[Java backend]: https://github.com/rust-diplomat/diplomat/issues/144

0 comments on commit c74be33

Please sign in to comment.