Refactor duplicated code patterns into shared utilities#2
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Refactor duplicated code patterns into shared utilities#2devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- 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>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
SVG marker definitions — Each diagram redefined identical
<defs><marker id="arrowhead">blocks (4 duplicate arrowhead defs in the flow chart alone). Now a singleDiagramUtils.injectSharedDefs(svg, ids, type)call creates all markers once.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 viaDiagramUtils.createActor({ id, x, yStart, yEnd, name }).Edge path groups — 4 copy-pasted
<g class="edgePath"><path><defs><marker>blocks differing only in coordinates. NowDiagramUtils.createEdgePath({ d, markerId })+ shared defs.TOC list items — Every heading was manually duplicated in the sidebar as
<li><a href="#id">Title</a></li>. NowTocGenerator.generateFromHeadings()auto-generates the TOC from page headings.Inline styles — Repeated
stroke-width: 0.5px; stroke: #999,text-anchor: middle,fill: #eaeaeaetc. moved tocss/styles.cssas 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,createFlowNodejs/toc-generator.js—generateFromHeadings(contentSelector, tocSelector)builds nested<ul>from DOM headingsLink to Devin session: https://app.devin.ai/sessions/816cf02b6a34430daca107ea7301d0d6
Requested by: @SunilParisi123