From 7dd1e7d0541bf109e95017ac4bd1dfde4dcdc5fa Mon Sep 17 00:00:00 2001 From: hawkeyexl Date: Thu, 22 May 2025 09:50:02 -0700 Subject: [PATCH 1/4] Update version numbers and fix formatting in utils.js - Bump version to 3.0.1 in package.json and package-lock.json - Update posthog-node dependency to version 4.17.2 - Change join character in parseContent function from empty string to newline --- package-lock.json | 12 ++++++------ package.json | 4 ++-- src/utils.js | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9502d76..8d2873b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "doc-detective-resolver", - "version": "3.0.0", + "version": "3.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "doc-detective-resolver", - "version": "3.0.0", + "version": "3.0.1", "license": "AGPL-3.0-only", "dependencies": { "@apidevtools/json-schema-ref-parser": "^12.0.2", @@ -15,7 +15,7 @@ "doc-detective-common": "^3.0.4", "dotenv": "^16.5.0", "json-schema-faker": "^0.5.9", - "posthog-node": "^4.17.1", + "posthog-node": "^4.17.2", "uuid": "^11.1.0" }, "devDependencies": { @@ -1819,9 +1819,9 @@ "license": "ISC" }, "node_modules/posthog-node": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/posthog-node/-/posthog-node-4.17.1.tgz", - "integrity": "sha512-cVlQPOwOPjakUnrueKRCQe1m2Ku+XzKaOos7Tn/zDZkkZFeBT/byP7tbNf7LiwhaBRWFBRowZZb/MsTtSRaorg==", + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/posthog-node/-/posthog-node-4.17.2.tgz", + "integrity": "sha512-bFmwOTk4QdYavopeHVXtyFGQ9vyLMVaNWkWocwjix+0n6sQgv7Zq5nYjYulz7ThmK18zsvNJ337ahuMLv3ulow==", "license": "MIT", "dependencies": { "axios": "^1.8.2" diff --git a/package.json b/package.json index 0a90e3b..c28ce6b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "doc-detective-resolver", - "version": "3.0.0", + "version": "3.0.1", "description": "Detect and resolve docs into Doc Detective tests.", "main": "src/index.js", "scripts": { @@ -30,7 +30,7 @@ "doc-detective-common": "^3.0.4", "dotenv": "^16.5.0", "json-schema-faker": "^0.5.9", - "posthog-node": "^4.17.1", + "posthog-node": "^4.17.2", "uuid": "^11.1.0" }, "devDependencies": { diff --git a/src/utils.js b/src/utils.js index 35a9902..14523cc 100644 --- a/src/utils.js +++ b/src/utils.js @@ -343,7 +343,7 @@ async function parseContent({ config, content, filePath, fileType }) { if (matches.length > 0 && markup.batchMatches) { // Combine all matches into a single match const combinedMatch = { - 1: matches.map((match) => match[1] || match[0]).join(""), + 1: matches.map((match) => match[1] || match[0]).join("\n"), type: "detectedStep", markup: markup, sortIndex: Math.min(...matches.map((match) => match.index)), From 682bc0e842800dad8465114c2f75988b17eab5fe Mon Sep 17 00:00:00 2001 From: hawkeyexl Date: Thu, 22 May 2025 09:53:07 -0700 Subject: [PATCH 2/4] Update base branches in .coderabbit.yaml - Add "main" to the list of base branches for auto review --- .coderabbit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 24d8af3..2b782d2 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -24,7 +24,7 @@ reviews: ignore_title_keywords: [] labels: [] drafts: false - base_branches: ["rc"] + base_branches: ["main","rc"] tools: shellcheck: enabled: true From 9b5a822fb8fd7e2b29e3c9b4382da4dda79be44e Mon Sep 17 00:00:00 2001 From: hawkeyexl Date: Thu, 22 May 2025 09:56:14 -0700 Subject: [PATCH 3/4] Replace newline character with OS-specific line ending in parseContent function --- dev/index.js | 59 ++- dev/output.json | 1006 ++--------------------------------------------- src/utils.js | 2 +- 3 files changed, 76 insertions(+), 991 deletions(-) diff --git a/dev/index.js b/dev/index.js index bba9a47..3e24f5c 100644 --- a/dev/index.js +++ b/dev/index.js @@ -7,15 +7,54 @@ main(); async function main() { const json = { - input: "/home/hawkeyexl/Workspaces/resolver/dev/dev.spec.json", - integrations:{ - openApi: [ - { - name: "reqres", - descriptionPath: "/home/hawkeyexl/Workspaces/resolver/dev/reqres.openapi.json", - } - ] - }, + input: "/home/hawkeyexl/Workspaces/resolver/dev/doc-content copy.md", + fileTypes: [ + { + name: "markdown", + extensions: ["md", "markdown", "mdx"], + inlineStatements: { + testStart: [ + "{\\/\\*\\s*test\\s+?([\\s\\S]*?)\\s*\\*\\/}", + "", + "\\[comment\\]:\\s+#\\s+\\(test\\s*(.*?)\\s*\\)", + "\\[comment\\]:\\s+#\\s+\\(test start\\s*(.*?)\\s*\\)", + ], + testEnd: [ + "{\\/\\*\\s*test end\\s*\\*\\/}", + "", + "\\[comment\\]:\\s+#\\s+\\(test end\\)", + ], + ignoreStart: [ + "{\\/\\*\\s*test ignore start\\s*\\*\\/}", + "", + ], + ignoreEnd: [ + "{\\/\\*\\s*test ignore end\\s*\\*\\/}", + "", + ], + step: [ + "{\\/\\*\\s*step\\s+?([\\s\\S]*?)\\s*\\*\\/}", + "", + "\\[comment\\]:\\s+#\\s+\\(step\\s*(.*?)\\s*\\)", + ], + }, + markup: [ + { + name: "runPython", + regex: ["```(?:python)\\b\\s*\\n(?.*?)(?=\\n```)"], + batchMatches: true, + actions: [ + { + runCode: { + language: "python", + code: "$1", + }, + }, + ], + }, + ], + }, + ], logLevel: "debug", }; result = await detectAndResolveTests({ config: json }); @@ -25,4 +64,4 @@ async function main() { const fs = require("fs"); fs.writeFileSync(outputPath, JSON.stringify(result, null, 2)); console.log(`Output written to ${outputPath}`); -} \ No newline at end of file +} diff --git a/dev/output.json b/dev/output.json index 84177a6..16bc329 100644 --- a/dev/output.json +++ b/dev/output.json @@ -1,302 +1,8 @@ { "config": { "input": [ - "/home/hawkeyexl/Workspaces/resolver/dev/dev.spec.json" + "/home/hawkeyexl/Workspaces/resolver/dev/doc-content copy.md" ], - "integrations": { - "openApi": [ - { - "name": "reqres", - "descriptionPath": "/home/hawkeyexl/Workspaces/resolver/dev/reqres.openapi.json", - "validateAgainstSchema": "both", - "useExample": "none", - "exampleKey": "", - "definition": { - "openapi": "3.0.3", - "info": { - "title": "Reqres API", - "description": "Sample API for testing and prototyping", - "version": "0.0.1" - }, - "servers": [ - { - "url": "https://reqres.in/api" - } - ], - "tags": [ - { - "name": "Test", - "description": "Test operations" - } - ], - "security": [ - {} - ], - "paths": { - "/users": { - "post": { - "tags": [ - "Test" - ], - "summary": "Add a new user", - "description": "Add a new user", - "operationId": "addUser", - "requestBody": { - "description": "Create a new user", - "content": { - "application/json": { - "schema": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "job": { - "type": "string" - } - } - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "description": "response payload" - }, - "examples": { - "test": { - "value": { - "name": "morpheus", - "job": "leader" - } - }, - "foobar": { - "value": { - "name": "neo", - "job": "the-one" - } - } - } - } - } - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "get": { - "tags": [ - "Test" - ], - "summary": "Return a list of users", - "description": "Return a list of users", - "operationId": "getUsers", - "parameters": [ - { - "name": "page", - "in": "query", - "description": "Select the portition of record you want back", - "required": false, - "schema": { - "type": "integer", - "example": 1 - } - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "description": "response payload" - } - } - } - } - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - } - } - } - } - } - } - } - }, - "/users/{id}": { - "put": { - "tags": [ - "Test" - ], - "summary": "Update an existing user", - "description": "Update an existing user by Id", - "operationId": "updateUser", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "id of user to delete", - "required": true, - "example": 1, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "description": "Update an existent pet in the store", - "content": { - "application/json": { - "schema": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "job": { - "type": "string" - } - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "description": "response payload" - } - } - } - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - } - } - } - } - } - } - }, - "delete": { - "tags": [ - "Test" - ], - "summary": "Deletes a user", - "description": "delete a user", - "operationId": "deleteUser", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "id of user to delete", - "required": true, - "example": 1, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "No content" - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "userResponse": { - "description": "response payload" - }, - "userRequest": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "job": { - "type": "string" - } - } - } - } - } - } - } - ] - }, - "logLevel": "debug", - "output": ".", - "recursive": true, - "relativePathBase": "file", - "detectSteps": true, "fileTypes": [ { "name": "markdown", @@ -333,117 +39,32 @@ }, "markup": [ { - "name": "checkHyperlink", - "regex": [ - "(?.*?)(?=\\n```)" ], + "batchMatches": true, "actions": [ - "click" - ] - }, - { - "name": "findOnscreenText", - "regex": [ - "\\*\\*((?:(?!\\*\\*).)+)\\*\\*" - ], - "actions": [ - "find" - ] - }, - { - "name": "goToUrl", - "regex": [ - "\\b(?:[Gg]o\\s+to|[Oo]pen|[Nn]avigate\\s+to|[Vv]isit|[Aa]ccess|[Pp]roceed\\s+to|[Ll]aunch)\\b\\s+\\[[^\\]]+\\]\\(\\s*(https?:\\/\\/[^\\s)]+)(?:\\s+\"[^\"]*\")?\\s*\\)" - ], - "actions": [ - "goTo" - ] - }, - { - "name": "screenshotImage", - "regex": [ - "!\\[[^\\]]*\\]\\(\\s*([^\\s)]+)(?:\\s+\"[^\"]*\")?\\s*\\)\\s*\\{(?=[^}]*\\.screenshot)[^}]*\\}" - ], - "actions": [ - "screenshot" - ] - }, - { - "name": "typeText", - "regex": [ - "\\b(?:press|enter|type)\\b\\s+\"([^\"]+)\"" - ], - "actions": [ - "type" + { + "runCode": { + "language": "python", + "code": "print(\"Hello, world!\")\nprint(\"Hello to you too!\")" + } + } ] } ] - }, - { - "name": "asciidoc", - "extensions": [ - "adoc", - "asciidoc", - "asc" - ], - "inlineStatements": { - "testStart": [ - "\\/\\/\\s+\\(\\s*test\\s+([\\s\\S]*?)\\s*\\)" - ], - "testEnd": [ - "\\/\\/\\s+\\(\\s*test end\\s*\\)" - ], - "ignoreStart": [ - "\\/\\/\\s+\\(\\s*test ignore start\\s*\\)" - ], - "ignoreEnd": [ - "\\/\\/\\s+\\(\\s*test ignore end\\s*\\)" - ], - "step": [ - "\\/\\/\\s+\\(\\s*step\\s+([\\s\\S]*?)\\s*\\)" - ] - }, - "markup": [] - }, - { - "name": "html", - "extensions": [ - "html", - "htm" - ], - "inlineStatements": { - "testStart": [ - "" - ], - "testEnd": [ - "" - ], - "ignoreStart": [ - "" - ], - "ignoreEnd": [ - "" - ], - "step": [ - "" - ] - }, - "markup": [] } ], + "logLevel": "debug", + "output": ".", + "recursive": true, + "relativePathBase": "file", + "detectSteps": true, "telemetry": { "send": true }, - "configId": "343eeb23-6a45-496f-84ef-6210be7e10c7", + "configId": "6ffa39d0-4353-42f0-a891-09aae0980197", "environment": { "arch": "x64", "platform": "linux", @@ -452,606 +73,31 @@ }, "specs": [ { + "specId": "b0d003dd-0fe2-4e46-8844-05f7cd0be602", + "contentPath": "/home/hawkeyexl/Workspaces/resolver/dev/doc-content copy.md", "tests": [ { - "after": "/home/hawkeyexl/Workspaces/resolver/dev/cleanup.spec.json", - "testId": "17e04f88-1c54-447f-ab6b-1d3a38ef1033", + "testId": "2374e8d5-8c4b-444a-a321-034455045740", "runOn": [], - "openApi": [ - { - "name": "reqres", - "descriptionPath": "/home/hawkeyexl/Workspaces/resolver/dev/reqres.openapi.json", - "validateAgainstSchema": "both", - "useExample": "none", - "exampleKey": "", - "definition": { - "openapi": "3.0.3", - "info": { - "title": "Reqres API", - "description": "Sample API for testing and prototyping", - "version": "0.0.1" - }, - "servers": [ - { - "url": "https://reqres.in/api" - } - ], - "tags": [ - { - "name": "Test", - "description": "Test operations" - } - ], - "security": [ - {} - ], - "paths": { - "/users": { - "post": { - "tags": [ - "Test" - ], - "summary": "Add a new user", - "description": "Add a new user", - "operationId": "addUser", - "requestBody": { - "description": "Create a new user", - "content": { - "application/json": { - "schema": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "job": { - "type": "string" - } - } - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "description": "response payload" - }, - "examples": { - "test": { - "value": { - "name": "morpheus", - "job": "leader" - } - }, - "foobar": { - "value": { - "name": "neo", - "job": "the-one" - } - } - } - } - } - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "get": { - "tags": [ - "Test" - ], - "summary": "Return a list of users", - "description": "Return a list of users", - "operationId": "getUsers", - "parameters": [ - { - "name": "page", - "in": "query", - "description": "Select the portition of record you want back", - "required": false, - "schema": { - "type": "integer", - "example": 1 - } - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "description": "response payload" - } - } - } - } - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - } - } - } - } - } - } - } - }, - "/users/{id}": { - "put": { - "tags": [ - "Test" - ], - "summary": "Update an existing user", - "description": "Update an existing user by Id", - "operationId": "updateUser", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "id of user to delete", - "required": true, - "example": 1, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "description": "Update an existent pet in the store", - "content": { - "application/json": { - "schema": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "job": { - "type": "string" - } - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "description": "response payload" - } - } - } - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - } - } - } - } - } - } - }, - "delete": { - "tags": [ - "Test" - ], - "summary": "Deletes a user", - "description": "delete a user", - "operationId": "deleteUser", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "id of user to delete", - "required": true, - "example": 1, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "No content" - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "userResponse": { - "description": "response payload" - }, - "userRequest": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "job": { - "type": "string" - } - } - } - } - } - } - } - ], + "openApi": [], "contexts": [ { "openApi": [], "steps": [ { - "goTo": "https://duckduckgo.com" - }, - { - "find": "/Set As.+/" - }, - { - "runShell": "echo cleanup" + "runCode": { + "language": "python", + "code": "print(\"Hello, world!\")\nprint(\"Hello to you too!\")" + } } ], - "contextId": "e7c3c74c-315a-453e-86c8-537171c1ff72" + "contextId": "4eb87d33-034d-49ee-8252-be3981ff92ed" } ] } ], - "specId": "722226ef-bc40-4e98-8ddf-c7c0da8b377f", "runOn": [], - "openApi": [ - { - "name": "reqres", - "descriptionPath": "/home/hawkeyexl/Workspaces/resolver/dev/reqres.openapi.json", - "validateAgainstSchema": "both", - "useExample": "none", - "exampleKey": "", - "definition": { - "openapi": "3.0.3", - "info": { - "title": "Reqres API", - "description": "Sample API for testing and prototyping", - "version": "0.0.1" - }, - "servers": [ - { - "url": "https://reqres.in/api" - } - ], - "tags": [ - { - "name": "Test", - "description": "Test operations" - } - ], - "security": [ - {} - ], - "paths": { - "/users": { - "post": { - "tags": [ - "Test" - ], - "summary": "Add a new user", - "description": "Add a new user", - "operationId": "addUser", - "requestBody": { - "description": "Create a new user", - "content": { - "application/json": { - "schema": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "job": { - "type": "string" - } - } - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "description": "response payload" - }, - "examples": { - "test": { - "value": { - "name": "morpheus", - "job": "leader" - } - }, - "foobar": { - "value": { - "name": "neo", - "job": "the-one" - } - } - } - } - } - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "get": { - "tags": [ - "Test" - ], - "summary": "Return a list of users", - "description": "Return a list of users", - "operationId": "getUsers", - "parameters": [ - { - "name": "page", - "in": "query", - "description": "Select the portition of record you want back", - "required": false, - "schema": { - "type": "integer", - "example": 1 - } - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "description": "response payload" - } - } - } - } - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - } - } - } - } - } - } - } - }, - "/users/{id}": { - "put": { - "tags": [ - "Test" - ], - "summary": "Update an existing user", - "description": "Update an existing user by Id", - "operationId": "updateUser", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "id of user to delete", - "required": true, - "example": 1, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "description": "Update an existent pet in the store", - "content": { - "application/json": { - "schema": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "job": { - "type": "string" - } - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful operation", - "content": { - "application/json": { - "schema": { - "description": "response payload" - } - } - } - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - } - } - } - } - } - } - }, - "delete": { - "tags": [ - "Test" - ], - "summary": "Deletes a user", - "description": "delete a user", - "operationId": "deleteUser", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "id of user to delete", - "required": true, - "example": 1, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "No content" - }, - "400": { - "description": "Invalid input", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "error": { - "type": "string" - } - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "userResponse": { - "description": "response payload" - }, - "userRequest": { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "job": { - "type": "string" - } - } - } - } - } - } - } - ] + "openApi": [] } ] } \ No newline at end of file diff --git a/src/utils.js b/src/utils.js index 14523cc..6385716 100644 --- a/src/utils.js +++ b/src/utils.js @@ -343,7 +343,7 @@ async function parseContent({ config, content, filePath, fileType }) { if (matches.length > 0 && markup.batchMatches) { // Combine all matches into a single match const combinedMatch = { - 1: matches.map((match) => match[1] || match[0]).join("\n"), + 1: matches.map((match) => match[1] || match[0]).join(os.EOL), type: "detectedStep", markup: markup, sortIndex: Math.min(...matches.map((match) => match.index)), From a8c614b93b98c6c54925038cb4091a1ff35fb0ed Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Thu, 22 May 2025 16:57:13 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`rc`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @hawkeyexl. * https://github.com/doc-detective/resolver/pull/1#issuecomment-2901950841 The following files were modified: * `dev/index.js` * `src/utils.js` --- dev/index.js | 5 +++++ src/utils.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/dev/index.js b/dev/index.js index 3e24f5c..ea8a80f 100644 --- a/dev/index.js +++ b/dev/index.js @@ -5,6 +5,11 @@ const path = require("path"); main(); +/** + * Detects and resolves test cases in a specified markdown file using configured patterns and actions, then outputs the results to a JSON file. + * + * 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. + */ async function main() { const json = { input: "/home/hawkeyexl/Workspaces/resolver/dev/doc-content copy.md", diff --git a/src/utils.js b/src/utils.js index 6385716..d73f67a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -251,6 +251,18 @@ async function isValidSourceFile({ config, files, source }) { return true; } +/** + * Parses raw test content into an array of structured test objects. + * + * Processes input content using inline statement and markup regex patterns defined by {@link fileType}, extracting test and step definitions. Supports detection of test boundaries, ignored sections, and step definitions, including batch markup matches. Converts and validates extracted objects against the test and step schemas, handling both v2 and v3 formats. Returns an array of validated test objects with their associated steps. + * + * @param {Object} options - Options for parsing. + * @param {Object} options.config - Test configuration object. + * @param {string|Object} options.content - Raw file content as a string or object. + * @param {string} options.filePath - Path to the file being parsed. + * @param {Object} options.fileType - File type definition containing parsing rules. + * @returns {Array} Array of parsed and validated test objects. + */ async function parseContent({ config, content, filePath, fileType }) { const statements = []; const statementTypes = [