Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Handle Clap unit structs in documentation check

Manav Rathi4659d324a0a1
diff --git a/.github/checks/documentation-comments/check.mjs b/.github/checks/documentation-comments/check.mjs
index b62fe82dca..97b19da377 100644
--- a/.github/checks/documentation-comments/check.mjs
+++ b/.github/checks/documentation-comments/check.mjs
@@ -141,6 +141,11 @@ function clapRanges(source, comments) {
depth += (code.match(/{/g) ?? []).length;
if (depth) opened = true;
depth -= (code.match(/}/g) ?? []).length;
+ if (!opened && /;\s*$/.test(code)) {
+ ranges.push([start, end + 1]);
+ i = end;
+ break;
+ }
if (!opened || depth) continue;
ranges.push([start, end + 1]);
i = end;
diff --git a/.github/checks/documentation-comments/test.mjs b/.github/checks/documentation-comments/test.mjs
index 9a66999eb2..305643a339 100644
--- a/.github/checks/documentation-comments/test.mjs
+++ b/.github/checks/documentation-comments/test.mjs
@@ -46,6 +46,13 @@ let result = run(
"/// API documentation.",
"pub fn value() {}",
].join("\n"),
+ "rust/unit_clap.rs": [
+ "/// Printed in top-level command help.",
+ "#[derive(clap::Parser)]",
+ "struct Args;",
+ "/// API documentation.",
+ "pub fn value() {}",
+ ].join("\n"),
"deleted.rs": "/// Deleted documentation.\n",
},
{
@@ -72,12 +79,14 @@ for (const path of [
"web/satisfies.js:1",
"web/returns.js:1",
"rust/clap.rs:6",
+ "rust/unit_clap.rs:4",
"native/Value.swift:1",
]) {
assert.match(result.stderr, new RegExp(path.replace(".", "\\.")));
}
assert.doesNotMatch(result.stderr, /deleted/);
assert.doesNotMatch(result.stderr, /rust\/clap\.rs:3/);
+assert.doesNotMatch(result.stderr, /rust\/unit_clap\.rs:1/);
result = run({
"rust/local.rs": "// Non-obvious implementation reason.\npub fn value() {}\n",