Skip to content

Commit 6f9356d

Browse files
committed
Add heading comments
1 parent e5a34c2 commit 6f9356d

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

packages/weak-node-api/scripts/generate-weak-node-api.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,30 @@ type GenerateFileOptions = {
1717
functions: FunctionDecl[];
1818
fileName: string;
1919
generator: (functions: FunctionDecl[]) => string;
20+
headingComment?: string;
2021
};
2122

2223
async function generateFile({
2324
functions,
2425
fileName,
2526
generator,
27+
headingComment = "",
2628
}: GenerateFileOptions) {
2729
const generated = generator(functions);
28-
const output = `// This file is generated - don't edit it directly\n\n${generated}`;
30+
const output = `
31+
/**
32+
* @file ${fileName}
33+
* ${headingComment
34+
.trim()
35+
.split("\n")
36+
.map((l) => l.trim())
37+
.join("\n* ")}
38+
*
39+
* @note This file is generated - don't edit it directly
40+
*/
41+
42+
${generated}
43+
`;
2944
const outputPath = path.join(OUTPUT_PATH, fileName);
3045
await fs.promises.writeFile(outputPath, output, "utf-8");
3146
const { status, stderr = "No error output" } = cp.spawnSync(
@@ -46,21 +61,41 @@ async function run() {
4661
functions,
4762
fileName: "weak_node_api.hpp",
4863
generator: weakNodeApiGenerator.generateHeader,
64+
headingComment: `
65+
@brief Weak Node-API host injection interface.
66+
67+
This header provides the struct and injection function for deferring Node-API function calls from addons into a Node-API host.
68+
`,
4969
});
5070
await generateFile({
5171
functions,
5272
fileName: "weak_node_api.cpp",
5373
generator: weakNodeApiGenerator.generateSource,
74+
headingComment: `
75+
@brief Weak Node-API host injection implementation.
76+
77+
Provides the implementation for deferring Node-API function calls from addons into a Node-API host.
78+
`,
5479
});
5580
await generateFile({
5681
functions,
5782
fileName: "weak_node_api_multi_host.hpp",
5883
generator: multiHostGenerator.generateHeader,
84+
headingComment: `
85+
@brief Weak Node-API multi-host injection interface.
86+
87+
This header provides the struct for deferring Node-API function calls from addons into multiple Node-API host implementations.
88+
`,
5989
});
6090
await generateFile({
6191
functions,
6292
fileName: "weak_node_api_multi_host.cpp",
6393
generator: multiHostGenerator.generateSource,
94+
headingComment: `
95+
@brief Weak Node-API multi-host injection implementation.
96+
97+
Provides the implementation for deferring Node-API function calls from addons into multiple Node-API host implementations.
98+
`,
6499
});
65100
}
66101

0 commit comments

Comments
 (0)