Skip to content

Commit e9d14bb

Browse files
committed
docs: Enhance JSDoc for build scripts (#8510)
1 parent 7fff9cb commit e9d14bb

2 files changed

Lines changed: 81 additions & 11 deletions

File tree

buildScripts/createReleaseIndex.mjs

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ import matter from 'gray-matter';
77
import semver from 'semver';
88
import {sanitizeInput} from './util/Sanitizer.mjs';
99

10+
/**
11+
* @module buildScripts.createReleaseIndex
12+
* @summary Generates a hierarchical JSON index of Release Notes for the Neo.mjs Portal application.
13+
*
14+
* This script scans local markdown files in `resources/content/release-notes` and constructs a
15+
* structured JSON index (`releases.json`). This index is consumed by the Portal's "Release Notes"
16+
* section, allowing users to browse history grouped by Major Version.
17+
*
18+
* **Key Features:**
19+
* - **Metadata Extraction:** Parses frontmatter (`tagName`, `publishedAt`) but falls back to file stats/names if needed.
20+
* - **SemVer Grouping:** Automatically groups releases by Major Version (e.g., "v5", "v6") using `semver`.
21+
* - **Tree-Ready Output:** Generates a flat-tree structure with `parentId` references, optimized for `Neo.tree.List`.
22+
*
23+
* @see apps/portal/view/release/MainContainer.mjs
24+
* @see buildScripts/createTicketIndex.mjs
25+
* @keywords portal, releases, changelog, semver, build-script, knowledge-base
26+
*/
27+
1028
const ROOT_DIR = process.cwd();
1129
const RELEASE_DIR = path.resolve(ROOT_DIR, 'resources/content/release-notes');
1230
const OUTPUT_FILE = path.resolve(ROOT_DIR, 'apps/portal/resources/data/releases.json');
@@ -21,11 +39,18 @@ const OUTPUT_FILE = path.resolve(ROOT_DIR, 'apps/portal/resources/data/releases.
2139
*/
2240

2341
/**
24-
* Scans the release notes directory and generates a JSON index.
25-
* @param {Object} options
26-
* @param {String} options.inputDir - Directory containing markdown release notes
27-
* @param {String} options.outputFile - Path to the output JSON file
28-
* @returns {Promise<void>}
42+
* Core logic to scan and index release note markdown files.
43+
*
44+
* 1. Glob-scans `resources/content/release-notes/*.md`.
45+
* 2. Extracts version numbers and dates (handling both frontmatter and filesystem fallbacks).
46+
* 3. Groups releases into Major Version buckets (e.g., "v1", "v2").
47+
* 4. Sorts majors and minors descending.
48+
* 5. Flattens the structure for `Neo.data.Store` consumption.
49+
*
50+
* @param {Object} options Configuration options
51+
* @param {String} [options.inputDir] - Directory containing markdown release notes (defaults to `resources/content/release-notes`)
52+
* @param {String} [options.outputFile] - Path to the output JSON file (defaults to `apps/portal/resources/data/releases.json`)
53+
* @returns {Promise<void>} Resolves when the JSON file is written
2954
*/
3055
async function createReleaseIndex(options = {}) {
3156
const inputDir = options.inputDir || RELEASE_DIR;
@@ -157,6 +182,14 @@ async function createReleaseIndex(options = {}) {
157182
console.log(`Release index written to ${outputFile}`);
158183
}
159184

185+
/**
186+
* CLI entry point for the script.
187+
* Handles argument parsing using `commander` and invokes the main `createReleaseIndex` function.
188+
*
189+
* Supported flags:
190+
* - `-i, --input <path>`: Custom input directory
191+
* - `-o, --output <path>`: Custom output file path
192+
*/
160193
async function runCli() {
161194
const program = new Command();
162195

buildScripts/createTicketIndex.mjs

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ import matter from 'gray-matter';
77
import semver from 'semver';
88
import {sanitizeInput} from './util/Sanitizer.mjs';
99

10+
/**
11+
* @module buildScripts.createTicketIndex
12+
* @summary Generates a hierarchical JSON index of GitHub tickets for the Neo.mjs Portal application.
13+
*
14+
* This script is a critical part of the **Portal Knowledge Hub** data pipeline. It parses local markdown
15+
* files (synced from GitHub Issues) and transforms them into a lightweight, structured JSON index (`tickets.json`).
16+
* This index drives the `TreeList` navigation in the Portal's "Tickets" section.
17+
*
18+
* **Key Features:**
19+
* - **Dual-Source Scanning:** Reads from both active issues (`resources/content/issues`) and the issue archive (`resources/content/issue-archive`).
20+
* - **Intelligent Filtering:** Includes high-value tickets (bug, feature, epic) while excluding noise (chore, task) to ensure high signal-to-noise ratio for SEO and AI.
21+
* - **Hierarchical Grouping:** Groups tickets by "Latest" (active) or by Release Version (archived), sorted semantically.
22+
* - **TreeList Optimization:** Outputs a flat-tree structure compatible with `Neo.tree.List` and `Neo.data.Store`.
23+
*
24+
* @see apps/portal/view/news/tickets/MainContainer.mjs
25+
* @see buildScripts/createReleaseIndex.mjs
26+
* @keywords portal, tickets, seo, json-index, build-script, knowledge-base
27+
*/
28+
1029
const ROOT_DIR = process.cwd();
1130
const ISSUES_DIR = path.resolve(ROOT_DIR, 'resources/content/issues');
1231
const ARCHIVE_DIR = path.resolve(ROOT_DIR, 'resources/content/issue-archive');
@@ -18,12 +37,21 @@ const INCLUDE_LABELS = new Set(['bug', 'feature', 'enhancement', 'documentation'
1837
const EXCLUDE_LABELS = new Set(['chore', 'task', 'agent-task']);
1938

2039
/**
21-
* Scans the issues and issue-archive directories and generates a hierarchical JSON index.
22-
* @param {Object} options
23-
* @param {String} options.issuesDir - Directory containing active markdown tickets
24-
* @param {String} options.archiveDir - Directory containing archived markdown tickets (versioned folders)
25-
* @param {String} options.outputFile - Path to the output JSON file
26-
* @returns {Promise<void>}
40+
* Core logic to scan, filter, and index ticket markdown files.
41+
*
42+
* This function performs the heavy lifting:
43+
* 1. Glob-scans the configured directories for `.md` files.
44+
* 2. Parses YAML frontmatter to extract metadata (id, title, labels, dates).
45+
* 3. Applies inclusion/exclusion label logic.
46+
* 4. Groups tickets by version (directory name) or 'Latest'.
47+
* 5. Sorts groups by SemVer and tickets by date/ID.
48+
* 6. Flattens the result into a `Neo.data.Store` compatible array.
49+
*
50+
* @param {Object} options Configuration options
51+
* @param {String} [options.issuesDir] - Directory containing active markdown tickets (defaults to `resources/content/issues`)
52+
* @param {String} [options.archiveDir] - Directory containing archived markdown tickets (defaults to `resources/content/issue-archive`)
53+
* @param {String} [options.outputFile] - Path to the output JSON file (defaults to `apps/portal/resources/data/tickets.json`)
54+
* @returns {Promise<void>} Resolves when the JSON file is written
2755
*/
2856
async function createTicketIndex(options = {}) {
2957
const issuesDir = options.issuesDir || ISSUES_DIR;
@@ -178,6 +206,15 @@ async function createTicketIndex(options = {}) {
178206
console.log(`Ticket index written to ${outputFile}`);
179207
}
180208

209+
/**
210+
* CLI entry point for the script.
211+
* Handles argument parsing using `commander` and invokes the main `createTicketIndex` function.
212+
*
213+
* Supported flags:
214+
* - `-i, --issues <path>`: Custom issues directory
215+
* - `-a, --archive <path>`: Custom archive directory
216+
* - `-o, --output <path>`: Custom output file path
217+
*/
181218
async function runCli() {
182219
const program = new Command();
183220

0 commit comments

Comments
 (0)