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] =?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 = [