|
10 | 10 | regexCommit = /\b([0-9a-f]{7,40})\b/g; |
11 | 11 |
|
12 | 12 | /** |
| 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 | + * |
13 | 26 | * @class Portal.view.news.tickets.Component |
14 | 27 | * @extends Portal.view.shared.content.Component |
15 | 28 | */ |
@@ -43,6 +56,9 @@ class Component extends ContentComponent { |
43 | 56 | */ |
44 | 57 | #dateTimeFormatToday = null |
45 | 58 | /** |
| 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. |
46 | 62 | * @member {Object[]} timelineData=null |
47 | 63 | * @private |
48 | 64 | */ |
@@ -218,6 +234,19 @@ class Component extends ContentComponent { |
218 | 234 | } |
219 | 235 |
|
220 | 236 | /** |
| 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 | + * |
221 | 250 | * @param {String} content |
222 | 251 | * @returns {String} |
223 | 252 | */ |
@@ -348,6 +377,16 @@ class Component extends ContentComponent { |
348 | 377 | } |
349 | 378 |
|
350 | 379 | /** |
| 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 | + * |
351 | 390 | * @param {String} content |
352 | 391 | * @returns {String} |
353 | 392 | */ |
|
0 commit comments