Skip to content

Commit

Permalink
Continue to improve doc generation
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph committed Sep 24, 2024
1 parent 7e8fc68 commit 8643773
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.0.11 (binary 0.1.9) -- 2024-09-23

- Adds more doc comments

## 0.0.10 (binary 0.1.9) -- 2024-09-23

- Adds an `ipc` flag to enable sending messages from the webview back to the host deno process.
Expand Down
12 changes: 8 additions & 4 deletions schemas/WebViewOptions.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions scripts/generate-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const outputFile = new URL("../src/schemas.ts", import.meta.url).pathname;
interface DocIR {
type: "doc";
title: string;
description?: string;
root: NodeIR;
}
type NodeIR =
Expand Down Expand Up @@ -126,6 +127,7 @@ function jsonSchemaToIR(schema: JSONSchema): DocIR {
return {
type: "doc",
title: schema.title!,
description: schema.description,
root: nodeToIR(schema),
};
}
Expand All @@ -137,6 +139,9 @@ function generateTypes(ir: DocIR) {
};
const wn = (...t: (string | false | undefined | null | 0)[]) => w(...t, "\n");

wn("/**");
wn(` * ${ir.description}`);
wn(" */");
wn("export type", ir.title, " = ");
generateNode(ir.root);

Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use tao::window::Fullscreen;

const VERSION: &str = env!("CARGO_PKG_VERSION");

/// Options for creating a webview.
#[derive(JsonSchema, Deserialize, Debug)]
struct WebViewOptions {
/// Sets the title of the window.
Expand Down
23 changes: 18 additions & 5 deletions src/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
// DO NOT EDIT: This file is auto-generated by scripts/generate-zod.ts
import { z } from "npm:zod";

/**
* Options for creating a webview.
*/
export type WebViewOptions =
& {
/** Sets whether clicking an inactive window also clicks through to the webview. Default is false. */
accept_first_mouse?: boolean;
/** Sets whether all media can be played without user interaction. */
/** When true, all media can be played without user interaction. Default is false. */
autoplay?: boolean;
/**
* Enables clipboard access for the page rendered on Linux and Windows.
*
* macOS doesn’t provide such method and is always enabled by default. But your app will still need to add menu item accelerators to use the clipboard shortcuts.
*/
clipboard?: boolean;
/** Sets whether the window should have a border, a title bar, etc. */
/** When true, the window will have a border, a title bar, etc. Default is true. */
decorations?: boolean;
/**
* Enable or disable web inspector which is usually called devtools.
* Enable or disable webview devtools.
*
* Note this only enables devtools to the webview. To open it, you can call WebView::open_devtools, or right click the page and open it from the context menu.
* Note this only enables devtools to the webview. To open it, you can call `webview.open_devtools()`, or right click the page and open it from the context menu.
*/
devtools?: boolean;
/** Sets whether the webview should be focused when created. Default is false. */
focused?: boolean;
/** Sets whether the window should be fullscreen. */
/** When true, the window will be fullscreen. Default is false. */
fullscreen?: boolean;
/**
* Run the WebView with incognito mode. Note that WebContext will be ingored if incognito is enabled.
Expand All @@ -35,6 +38,7 @@ export type WebViewOptions =
ipc?: boolean;
/** Sets the title of the window. */
title: string;
/** Sets whether the window should be transparent. */
transparent?: boolean;
}
& (
Expand Down Expand Up @@ -62,6 +66,9 @@ export const WebViewOptions: z.ZodType<WebViewOptions> = z.intersection(
z.union([z.object({ url: z.string() }), z.object({ html: z.string() })]),
);

/**
* Explicit requests from the client to the webview.
*/
export type WebViewRequest =
| {
$type: "getVersion";
Expand Down Expand Up @@ -115,6 +122,9 @@ export const WebViewRequest: z.ZodType<WebViewRequest> = z.discriminatedUnion(
],
);

/**
* Responses from the webview to the client.
*/
export type WebViewResponse =
| {
$type: "ack";
Expand Down Expand Up @@ -159,6 +169,9 @@ export const WebViewResponse: z.ZodType<WebViewResponse> = z.discriminatedUnion(
],
);

/**
* Complete definition of all outbound messages from the webview to the client.
*/
export type WebViewMessage =
| {
$type: "notification";
Expand Down

0 comments on commit 8643773

Please sign in to comment.