Skip to content

Commit 9dcdd90

Browse files
committed
docs: Comprehensive intent-driven JSDoc for TicketComponent (#8554)
1 parent 577fd31 commit 9dcdd90

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

apps/portal/view/news/tickets/Component.mjs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ const
1010
regexCommit = /\b([0-9a-f]{7,40})\b/g;
1111

1212
/**
13+
* @summary The "Markdown Transformer" for GitHub Tickets.
14+
*
15+
* This component extends the standard ContentComponent to provide specialized rendering for GitHub Issues.
16+
* Its primary responsibility is to parse the raw Markdown content (which includes custom Frontmatter and
17+
* a pre-generated Timeline section) and transform it into a rich, interactive HTML structure.
18+
*
19+
* **Key Responsibilities:**
20+
* 1. **Parsing Pipeline**: Extracts Frontmatter, Body, and the custom "Timeline" section from the raw Markdown.
21+
* 2. **Rich Rendering**: Generates HTML for Status Badges, Labels, Commit Links, and User Mentions.
22+
* 3. **Data Extraction**: As a side effect of rendering, it extracts structured data (`me.timelineData`)
23+
* representing every timeline event (comment, label change, close, etc.). This data is then
24+
* pushed to the `sections` store to drive the `TimelineCanvas` visualization.
25+
*
1326
* @class Portal.view.news.tickets.Component
1427
* @extends Portal.view.shared.content.Component
1528
*/
@@ -43,6 +56,9 @@ class Component extends ContentComponent {
4356
*/
4457
#dateTimeFormatToday = null
4558
/**
59+
* Temporary storage for the structured timeline data extracted during the parsing phase.
60+
* This array is populated by `renderTimeline` and `modifyMarkdown` and then assigned
61+
* to the `sections` store to drive the Canvas visualization.
4662
* @member {Object[]} timelineData=null
4763
* @private
4864
*/
@@ -218,6 +234,19 @@ class Component extends ContentComponent {
218234
}
219235

220236
/**
237+
* The Main Parsing Pipeline.
238+
*
239+
* This method intercepts the raw markdown content before it is rendered and performs a multi-pass transformation:
240+
* 1. **Extract Timeline**: Pulls out the raw `## Timeline` section to process it separately.
241+
* 2. **Process Frontmatter**: Extracts metadata (labels, state, author) and removes the YAML block.
242+
* 3. **Render Body**: Uses the superclass (marked.js) to convert the main issue body to HTML.
243+
* 4. **Inject Title IDs**: Adds IDs to H1 tags for navigation.
244+
* 5. **Generate Badges**: Creates HTML for Status/Label badges based on extracted metadata.
245+
* 6. **Wrap Body**: Wraps the main issue body in a `timeline-item` structure so it appears as the first item.
246+
* 7. **Re-Assemble**: Concatenates Frontmatter + Title + Timeline (with Body injected) into the final HTML.
247+
*
248+
* **Side Effect**: Populates `me.timelineData` and updates the `sections` store.
249+
*
221250
* @param {String} content
222251
* @returns {String}
223252
*/
@@ -348,6 +377,16 @@ class Component extends ContentComponent {
348377
}
349378

350379
/**
380+
* Parses the custom "Timeline" markdown section.
381+
*
382+
* Expects a line-based format generated by the build process:
383+
* - Events: `- YYYY-MM-DDTHH:mm:ss @user action text...`
384+
* - Comments: `### @user - YYYY-MM-DDTHH:mm:ss` followed by comment body.
385+
*
386+
* This method converts these lines into structured `timeline-item` HTML blocks
387+
* and simultaneously populates `me.timelineData` with semantic data (color, icon, type)
388+
* for each event.
389+
*
351390
* @param {String} content
352391
* @returns {String}
353392
*/

0 commit comments

Comments
 (0)