Skip to content

Commit d12875c

Browse files
authored
Merge pull request #1 from doc-detective/rc
Fix formatting for batched regex matches
2 parents 678bef3 + c697300 commit d12875c

File tree

6 files changed

+102
-1000
lines changed

6 files changed

+102
-1000
lines changed

.coderabbit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ reviews:
2424
ignore_title_keywords: []
2525
labels: []
2626
drafts: false
27-
base_branches: ["rc"]
27+
base_branches: ["main","rc"]
2828
tools:
2929
shellcheck:
3030
enabled: true

dev/index.js

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,61 @@ const path = require("path");
55

66
main();
77

8+
/**
9+
* Detects and resolves test cases in a specified markdown file using configured patterns and actions, then outputs the results to a JSON file.
10+
*
11+
* The function analyzes the input markdown file for test-related statements and code blocks according to the provided configuration, processes detected tests, and writes the structured results to "output.json" in the current directory.
12+
*/
813
async function main() {
914
const json = {
10-
input: "/home/hawkeyexl/Workspaces/resolver/dev/dev.spec.json",
11-
integrations:{
12-
openApi: [
13-
{
14-
name: "reqres",
15-
descriptionPath: "/home/hawkeyexl/Workspaces/resolver/dev/reqres.openapi.json",
16-
}
17-
]
18-
},
15+
input: "/home/hawkeyexl/Workspaces/resolver/dev/doc-content copy.md",
16+
fileTypes: [
17+
{
18+
name: "markdown",
19+
extensions: ["md", "markdown", "mdx"],
20+
inlineStatements: {
21+
testStart: [
22+
"{\\/\\*\\s*test\\s+?([\\s\\S]*?)\\s*\\*\\/}",
23+
"<!--\\s*test\\s*([\\s\\S]*?)\\s*-->",
24+
"\\[comment\\]:\\s+#\\s+\\(test\\s*(.*?)\\s*\\)",
25+
"\\[comment\\]:\\s+#\\s+\\(test start\\s*(.*?)\\s*\\)",
26+
],
27+
testEnd: [
28+
"{\\/\\*\\s*test end\\s*\\*\\/}",
29+
"<!--\\s*test end\\s*([\\s\\S]*?)\\s*-->",
30+
"\\[comment\\]:\\s+#\\s+\\(test end\\)",
31+
],
32+
ignoreStart: [
33+
"{\\/\\*\\s*test ignore start\\s*\\*\\/}",
34+
"<!--\\s*test ignore start\\s*-->",
35+
],
36+
ignoreEnd: [
37+
"{\\/\\*\\s*test ignore end\\s*\\*\\/}",
38+
"<!--\\s*test ignore end\\s*-->",
39+
],
40+
step: [
41+
"{\\/\\*\\s*step\\s+?([\\s\\S]*?)\\s*\\*\\/}",
42+
"<!--\\s*step\\s*([\\s\\S]*?)\\s*-->",
43+
"\\[comment\\]:\\s+#\\s+\\(step\\s*(.*?)\\s*\\)",
44+
],
45+
},
46+
markup: [
47+
{
48+
name: "runPython",
49+
regex: ["```(?:python)\\b\\s*\\n(?<code>.*?)(?=\\n```)"],
50+
batchMatches: true,
51+
actions: [
52+
{
53+
runCode: {
54+
language: "python",
55+
code: "$1",
56+
},
57+
},
58+
],
59+
},
60+
],
61+
},
62+
],
1963
logLevel: "debug",
2064
};
2165
result = await detectAndResolveTests({ config: json });
@@ -25,4 +69,4 @@ async function main() {
2569
const fs = require("fs");
2670
fs.writeFileSync(outputPath, JSON.stringify(result, null, 2));
2771
console.log(`Output written to ${outputPath}`);
28-
}
72+
}

0 commit comments

Comments
 (0)