Skip to content

Commit 333c712

Browse files
docs: add background to code-path-diagrams for dark-mode (#16822)
* docs: add background to code path diagrams * docs: aligns code-path-diagrams to center * docs: add background to architecture image * fix: indentation checks
1 parent f5f7b9b commit 333c712

5 files changed

Lines changed: 63 additions & 1 deletion

File tree

docs/.eleventy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ module.exports = function(eleventyConfig) {
195195
.use(markdownItAnchor, {
196196
slugify
197197
})
198+
.use(markdownItContainer, "img-container", {})
198199
.use(markdownItContainer, "correct", {})
199200
.use(markdownItContainer, "incorrect", {})
200201
.use(markdownItContainer, "warning", {

docs/src/assets/scss/docs.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ div.incorrect {
126126
}
127127
}
128128

129+
div.img-container {
130+
background-color: var(--img-background-color);
131+
border-radius: var(--border-radius);
132+
133+
img {
134+
margin: 0 auto;
135+
}
136+
}
137+
129138
pre[class*="language-"] {
130139
position: relative;
131140
}

docs/src/assets/scss/tokens/themes.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ html[data-theme="light"] {
131131
--hero-background-color: var(--color-neutral-25);
132132
--footer-background-color: var(--color-neutral-25);
133133
--outline-color: var(--color-brand);
134+
--img-background-color: #fff;
134135
}
135136

136137
html[data-theme="dark"] {
@@ -151,4 +152,5 @@ html[data-theme="dark"] {
151152
--hero-background-color: var(--color-neutral-800);
152153
--footer-background-color: var(--color-neutral-800);
153154
--outline-color: #fff;
155+
--img-background-color: var(--color-neutral-300);
154156
}

docs/src/contribute/architecture/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ eleventyNavigation:
77
order: 1
88
---
99

10-
<center><img alt="dependency graph" src="../../assets/images/architecture/dependency.svg"></center>
10+
:::img-container
11+
<img alt="dependency graph" src="../../assets/images/architecture/dependency.svg">
12+
:::
1113

1214
At a high level, there are a few key parts to ESLint:
1315

docs/src/extend/code-path-analysis.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ if (a && b) {
1414
bar();
1515
```
1616

17+
:::img-container
1718
![Code Path Example](../assets/images/code-path-analysis/helo.svg)
19+
:::
1820

1921
## Objects
2022

@@ -143,17 +145,23 @@ bar();
143145

144146
1. First, the analysis advances to the end of loop.
145147

148+
:::img-container
146149
![Loop Event's Example 1](../assets/images/code-path-analysis/loop-event-example-while-1.svg)
150+
:::
147151

148152
2. Second, it creates the looping path.
149153
At this time, the next segment has existed already, so the `onCodePathSegmentStart` event is not fired.
150154
It fires `onCodePathSegmentLoop` instead.
151155

156+
:::img-container
152157
![Loop Event's Example 2](../assets/images/code-path-analysis/loop-event-example-while-2.svg)
158+
:::
153159

154160
3. Last, it advances to the end.
155161

162+
:::img-container
156163
![Loop Event's Example 3](../assets/images/code-path-analysis/loop-event-example-while-3.svg)
164+
:::
157165

158166
For example 2:
159167

@@ -168,29 +176,39 @@ bar();
168176
First, the analysis advances to `ForStatement.update`.
169177
The `update` segment is hovered at first.
170178

179+
:::img-container
171180
![Loop Event's Example 1](../assets/images/code-path-analysis/loop-event-example-for-1.svg)
181+
:::
172182

173183
2. Second, it advances to `ForStatement.body`.
174184
Of course the `body` segment is preceded by the `test` segment.
175185
It keeps the `update` segment hovering.
176186

187+
:::img-container
177188
![Loop Event's Example 2](../assets/images/code-path-analysis/loop-event-example-for-2.svg)
189+
:::
178190

179191
3. Third, it creates the looping path from `body` segment to `update` segment.
180192
At this time, the next segment has existed already, so the `onCodePathSegmentStart` event is not fired.
181193
It fires `onCodePathSegmentLoop` instead.
182194

195+
:::img-container
183196
![Loop Event's Example 3](../assets/images/code-path-analysis/loop-event-example-for-3.svg)
197+
:::
184198

185199
4. Fourth, also it creates the looping path from `update` segment to `test` segment.
186200
At this time, the next segment has existed already, so the `onCodePathSegmentStart` event is not fired.
187201
It fires `onCodePathSegmentLoop` instead.
188202

203+
:::img-container
189204
![Loop Event's Example 4](../assets/images/code-path-analysis/loop-event-example-for-4.svg)
205+
:::
190206

191207
5. Last, it advances to the end.
192208

209+
:::img-container
193210
![Loop Event's Example 5](../assets/images/code-path-analysis/loop-event-example-for-5.svg)
211+
:::
194212

195213
## Usage Examples
196214

@@ -336,7 +354,9 @@ See Also:
336354
console.log("Hello world!");
337355
```
338356

357+
:::img-container
339358
![Hello World](../assets/images/code-path-analysis/example-hello-world.svg)
359+
:::
340360

341361
### `IfStatement`
342362

@@ -348,7 +368,9 @@ if (a) {
348368
}
349369
```
350370

371+
:::img-container
351372
![`IfStatement`](../assets/images/code-path-analysis/example-ifstatement.svg)
373+
:::
352374

353375
### `IfStatement` (chain)
354376

@@ -362,7 +384,9 @@ if (a) {
362384
}
363385
```
364386

387+
:::img-container
365388
![`IfStatement` (chain)](../assets/images/code-path-analysis/example-ifstatement-chain.svg)
389+
:::
366390

367391
### `SwitchStatement`
368392

@@ -383,7 +407,9 @@ switch (a) {
383407
}
384408
```
385409

410+
:::img-container
386411
![`SwitchStatement`](../assets/images/code-path-analysis/example-switchstatement.svg)
412+
:::
387413

388414
### `SwitchStatement` (has `default`)
389415

@@ -408,7 +434,9 @@ switch (a) {
408434
}
409435
```
410436

437+
:::img-container
411438
![`SwitchStatement` (has `default`)](../assets/images/code-path-analysis/example-switchstatement-has-default.svg)
439+
:::
412440

413441
### `TryStatement` (try-catch)
414442

@@ -431,7 +459,9 @@ It creates the paths from `try` block to `catch` block at:
431459
* The first throwable node (e.g. a function call) in the `try` block.
432460
* The end of the `try` block.
433461

462+
:::img-container
434463
![`TryStatement` (try-catch)](../assets/images/code-path-analysis/example-trystatement-try-catch.svg)
464+
:::
435465

436466
### `TryStatement` (try-finally)
437467

@@ -449,7 +479,9 @@ If there is not `catch` block, `finally` block has two current segments.
449479
At this time, `CodePath.currentSegments.length` is `2`.
450480
One is the normal path, and another is the leaving path (`throw` or `return`).
451481

482+
:::img-container
452483
![`TryStatement` (try-finally)](../assets/images/code-path-analysis/example-trystatement-try-finally.svg)
484+
:::
453485

454486
### `TryStatement` (try-catch-finally)
455487

@@ -465,7 +497,9 @@ try {
465497
last();
466498
```
467499

500+
:::img-container
468501
![`TryStatement` (try-catch-finally)](../assets/images/code-path-analysis/example-trystatement-try-catch-finally.svg)
502+
:::
469503

470504
### `WhileStatement`
471505

@@ -479,7 +513,9 @@ while (a) {
479513
}
480514
```
481515

516+
:::img-container
482517
![`WhileStatement`](../assets/images/code-path-analysis/example-whilestatement.svg)
518+
:::
483519

484520
### `DoWhileStatement`
485521

@@ -490,7 +526,9 @@ do {
490526
} while (a);
491527
```
492528

529+
:::img-container
493530
![`DoWhileStatement`](../assets/images/code-path-analysis/example-dowhilestatement.svg)
531+
:::
494532

495533
### `ForStatement`
496534

@@ -504,7 +542,9 @@ for (let i = 0; i < 10; ++i) {
504542
}
505543
```
506544

545+
:::img-container
507546
![`ForStatement`](../assets/images/code-path-analysis/example-forstatement.svg)
547+
:::
508548

509549
### `ForStatement` (for ever)
510550

@@ -515,7 +555,9 @@ for (;;) {
515555
bar();
516556
```
517557

558+
:::img-container
518559
![`ForStatement` (for ever)](../assets/images/code-path-analysis/example-forstatement-for-ever.svg)
560+
:::
519561

520562
### `ForInStatement`
521563

@@ -525,7 +567,9 @@ for (let key in obj) {
525567
}
526568
```
527569

570+
:::img-container
528571
![`ForInStatement`](../assets/images/code-path-analysis/example-forinstatement.svg)
572+
:::
529573

530574
### When there is a function
531575

@@ -544,8 +588,12 @@ It creates two code paths.
544588

545589
* The global's
546590

591+
:::img-container
547592
![When there is a function](../assets/images/code-path-analysis/example-when-there-is-a-function-g.svg)
593+
:::
548594

549595
* The function's
550596

597+
:::img-container
551598
![When there is a function](../assets/images/code-path-analysis/example-when-there-is-a-function-f.svg)
599+
:::

0 commit comments

Comments
 (0)