From c74be339230817d5b000265376c4ddd48948d9dd Mon Sep 17 00:00:00 2001 From: Tyler K Date: Sun, 18 Aug 2024 16:24:49 -0700 Subject: [PATCH] Drafting outline --- src/SUMMARY.md | 4 ++++ src/demo_gen/attributes.md | 1 + src/demo_gen/intro.md | 4 ++++ src/demo_gen/markup.md | 25 +++++++++++++++++++++++++ src/demo_gen/renderer.md | 0 src/intro.md | 6 +++--- 6 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/demo_gen/attributes.md create mode 100644 src/demo_gen/intro.md create mode 100644 src/demo_gen/markup.md create mode 100644 src/demo_gen/renderer.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 88d3a8f..172cd0f 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -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) diff --git a/src/demo_gen/attributes.md b/src/demo_gen/attributes.md new file mode 100644 index 0000000..78a7385 --- /dev/null +++ b/src/demo_gen/attributes.md @@ -0,0 +1 @@ +# Attributes diff --git a/src/demo_gen/intro.md b/src/demo_gen/intro.md new file mode 100644 index 0000000..f3c4105 --- /dev/null +++ b/src/demo_gen/intro.md @@ -0,0 +1,4 @@ +# demo_gen +See the tracking issue: https://github.com/rust-diplomat/diplomat/issues/604. + +## Using demo_gen \ No newline at end of file diff --git a/src/demo_gen/markup.md b/src/demo_gen/markup.md new file mode 100644 index 0000000..eda2b36 --- /dev/null +++ b/src/demo_gen/markup.md @@ -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) +``` \ No newline at end of file diff --git a/src/demo_gen/renderer.md b/src/demo_gen/renderer.md new file mode 100644 index 0000000..e69de29 diff --git a/src/intro.md b/src/intro.md index cc0569a..cf51ca1 100644 --- a/src/intro.md +++ b/src/intro.md @@ -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. @@ -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 \ No newline at end of file + [Java backend]: https://github.com/rust-diplomat/diplomat/issues/144 \ No newline at end of file