From 2e0bbf8515b2656a4a25f72cb4f3291c4180ee39 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 13 Dec 2024 16:52:18 -0700 Subject: [PATCH 1/5] doveadm: Add support for adding example arguments to doveadm commands These example arguments will be used for building example command/HTTP queries --- components/DoveadmComponent.vue | 4 ++++ data/doveadm.js | 5 +++++ lib/data/doveadm.data.js | 2 ++ 3 files changed, 11 insertions(+) diff --git a/components/DoveadmComponent.vue b/components/DoveadmComponent.vue index 00b4278e6..b257f07d5 100644 --- a/components/DoveadmComponent.vue +++ b/components/DoveadmComponent.vue @@ -106,6 +106,7 @@ const d = Object.fromEntries(Object.entries(data.doveadm).filter(([k, v]) => Argument(s) Type Description + Example @@ -114,6 +115,7 @@ const d = Object.fromEntries(Object.entries(data.doveadm).filter(([k, v]) => {{ elem.flag }} {{ elem.type }} + {{ elem.example }} @@ -130,6 +132,7 @@ const d = Object.fromEntries(Object.entries(data.doveadm).filter(([k, v]) => Parameter Type Description + Example @@ -138,6 +141,7 @@ const d = Object.fromEntries(Object.entries(data.doveadm).filter(([k, v]) => {{ elem.param }} {{ elem.type }} + {{ elem.example }} diff --git a/data/doveadm.js b/data/doveadm.js index 91e27598d..56c0680b2 100644 --- a/data/doveadm.js +++ b/data/doveadm.js @@ -20,6 +20,11 @@ export const doveadm = { // If true, only show for cli, not HTTP. // cli_only: true, + // If set, will use as command example argument. + // i.e., for HTTP API requests, this argument will be added + // to the example argument string. + example: false, + // If true, this is an optional positional argument. // optional: true, diff --git a/lib/data/doveadm.data.js b/lib/data/doveadm.data.js index c60fe6ab3..9dc4fb1ac 100644 --- a/lib/data/doveadm.data.js +++ b/lib/data/doveadm.data.js @@ -124,6 +124,8 @@ async function normalizeDoveadm(doveadm) { for (const [k2, v2] of Object.entries(v.args)) { if (!v2.hidden) { args.push({ + /* Undefined examples will resolve to undefined. */ + example: v2.example, flag: v2.cli ? '-' + v2.cli : (v2.positional ? k2 : '--' + k2), param: argToHttpParam(k2), type: typeToString(v2.type), From 9f5c1b51fe10dfe4c5136bbb5076eb758f4eb190 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 13 Dec 2024 23:56:46 -0700 Subject: [PATCH 2/5] doveadm: Output HTTP API examples for each command Dynamically generate this data only when the user clicks on the API documentation for a command, otherwise we are creating giant pages which will noticeably slowdown browsing. Additionally, add the command name to the HTTP output as well, since that was previously missing (although it can be found in the request example, it is not clearly labeled there). --- components/DoveadmComponent.vue | 33 +++------ components/DoveadmHttpApiComponent.vue | 92 ++++++++++++++++++++++++++ lib/data/doveadm.data.js | 5 ++ package-lock.json | 14 ++++ package.json | 1 + 5 files changed, 121 insertions(+), 24 deletions(-) create mode 100644 components/DoveadmHttpApiComponent.vue diff --git a/components/DoveadmComponent.vue b/components/DoveadmComponent.vue index b257f07d5..09e85f24f 100644 --- a/components/DoveadmComponent.vue +++ b/components/DoveadmComponent.vue @@ -1,5 +1,6 @@