Skip to content

Refactor duplicated code patterns into shared utilities#2

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1782156050-refactor-shared-utilities
Open

Refactor duplicated code patterns into shared utilities#2
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1782156050-refactor-shared-utilities

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

The single HTML file had significant code duplication across its inline SVG diagrams and page structure. This PR extracts those patterns into reusable shared utilities:

Duplicated patterns identified & eliminated:

  1. SVG marker definitions — Each diagram redefined identical <defs><marker id="arrowhead"> blocks (4 duplicate arrowhead defs in the flow chart alone). Now a single DiagramUtils.injectSharedDefs(svg, ids, type) call creates all markers once.

  2. Actor blocks — The sequence diagram had 6 near-identical <g><line><rect fill="#eaeaea" stroke="#666" width="150" height="65" rx="3" ry="3"><text> groups (3 top + 3 bottom actors). Now created via DiagramUtils.createActor({ id, x, yStart, yEnd, name }).

  3. Edge path groups — 4 copy-pasted <g class="edgePath"><path><defs><marker> blocks differing only in coordinates. Now DiagramUtils.createEdgePath({ d, markerId }) + shared defs.

  4. TOC list items — Every heading was manually duplicated in the sidebar as <li><a href="#id">Title</a></li>. Now TocGenerator.generateFromHeadings() auto-generates the TOC from page headings.

  5. Inline styles — Repeated stroke-width: 0.5px; stroke: #999, text-anchor: middle, fill: #eaeaea etc. moved to css/styles.css as class-based rules.

New files:

  • css/styles.css — Shared styles (SVG diagram classes, layout, table, KaTeX)
  • js/diagram-utils.js — SVG factories: createArrowheadMarker, createCrossheadMarker, injectSharedDefs, createActor, createMessage, createEdgePath, createFlowNode
  • js/toc-generator.jsgenerateFromHeadings(contentSelector, tocSelector) builds nested <ul> from DOM headings

Link to Devin session: https://app.devin.ai/sessions/816cf02b6a34430daca107ea7301d0d6
Requested by: @SunilParisi123

- Extract repeated inline SVG styles into css/styles.css
- Create js/diagram-utils.js: shared factories for SVG markers,
  actors, messages, edge paths, and flow nodes (eliminates 4+
  duplicated arrowhead defs, 6 duplicated actor blocks, and
  repeated edgePath boilerplate)
- Create js/toc-generator.js: auto-generates TOC from headings
  instead of manually duplicating every heading title in sidebar
- Refactor Welcome file.md to use shared utilities via data-driven
  rendering instead of copy-pasted inline SVG

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@SunilParisi123 SunilParisi123 self-assigned this Jun 22, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant