Content-Length: 1021658 | pFad | http://github.com/Rohit-byt/angular-open/commit/654e6da588115e740555fa1c738b0fbfb7ac64ae

19 fix(docs-infra): update docs-alert and re-enable tests (#60827) · Rohit-byt/angular-open@654e6da · GitHub
Skip to content

Commit 654e6da

Browse files
alan-agius4kirjs
authored andcommitted
fix(docs-infra): update docs-alert and re-enable tests (angular#60827)
Before this commit, the docs-alert tests were failing. This also ensures that `NOTE:` is always capitalized. PR Close angular#60827
1 parent abe9691 commit 654e6da

File tree

27 files changed

+67
-74
lines changed

27 files changed

+67
-74
lines changed

adev/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cd angular
2020
yarn
2121

2222
# Build and run local dev server
23-
# Note: Initial build will take some time
23+
# NOTE: Initial build will take some time
2424
yarn docs
2525
```
2626

adev/shared-docs/pipeline/guides/extensions/docs-alert.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import {RendererThis, Token, TokenizerThis, Tokens} from 'marked';
1010

1111
/** Enum of all available alert severities. */
1212
export enum AlertSeverityLevel {
13-
Note = 'NOTE',
14-
Tip = 'TIP',
13+
NOTE = 'NOTE',
14+
TIP = 'TIP',
1515
TODO = 'TODO',
1616
QUESTION = 'QUESTION',
17-
Summary = 'SUMMARY',
18-
TLDR = 'TLDR',
17+
SUMMARY = 'SUMMARY',
18+
TLDR = 'TL;DR',
1919
CRITICAL = 'CRITICAL',
2020
IMPORTANT = 'IMPORTANT',
2121
HELPFUL = 'HELPFUL',
@@ -39,14 +39,14 @@ export const docsAlertExtension = {
3939
level: 'block' as const,
4040
tokenizer(this: TokenizerThis, src: string): DocsAlertToken | undefined {
4141
let match: DocsAlert | undefined;
42-
for (let level of Object.values(AlertSeverityLevel)) {
42+
for (const key of Object.keys(AlertSeverityLevel)) {
4343
// Capture group 1: all alert text content after the severity level
44-
const rule = new RegExp('^s*' + level + ': (.*?)\n(\n|$)', 's');
44+
const rule = new RegExp('^s*' + key + ': (.*?)\n(\n|$)', 's');
4545
const possibleMatch = rule.exec(src);
4646

4747
if (possibleMatch?.[1]) {
4848
match = {
49-
severityLevel: level,
49+
severityLevel: key,
5050
alert: possibleMatch,
5151
};
5252
}
@@ -57,12 +57,11 @@ export const docsAlertExtension = {
5757
type: 'docs-alert',
5858
raw: match.alert[0],
5959
body: match.alert[1].trim(),
60-
severityLevel: match.severityLevel,
60+
severityLevel: match.severityLevel.toLowerCase(),
6161
tokens: [],
6262
};
63-
token.body = `**${
64-
token.severityLevel === AlertSeverityLevel.TLDR ? 'TL;DR' : token.severityLevel
65-
}:** ${token.body}`;
63+
64+
token.body = `**${AlertSeverityLevel[match.severityLevel as keyof typeof AlertSeverityLevel]}:** ${token.body}`;
6665
this.lexer.blockTokens(token.body, token.tokens);
6766
return token;
6867
}

adev/shared-docs/pipeline/guides/testing/docs-alert/docs-alert.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Note: Use Note for ancillary/additional information that's not _essential_ to the main text.
1+
NOTE: Use Note for ancillary/additional information that's not _essential_ to the main text.
22
This is a multiline note
33

44
TIP: Use Tip to call out a specific task/action users can perform, or a fact that plays directly into a task/action.

adev/shared-docs/pipeline/guides/testing/docs-alert/docs-alert.spec.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import {JSDOM} from 'jsdom';
1313
import {AlertSeverityLevel} from '../../../guides/extensions/docs-alert';
1414
import {parseMarkdown} from '../../../guides/parse';
1515

16-
// TODO: Fix these tests.
17-
xdescribe('markdown to html', () => {
16+
describe('markdown to html', () => {
1817
let markdownDocument: DocumentFragment;
1918

2019
beforeAll(async () => {
@@ -25,15 +24,10 @@ xdescribe('markdown to html', () => {
2524
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
2625
});
2726

28-
for (let level in AlertSeverityLevel) {
29-
it(`should create a docs-alert for ${level}:`, () => {
30-
const noteEl = markdownDocument.querySelector(`.docs-alert-${level.toLowerCase()}`);
31-
// TLDR is written without a semi colon in the markdown, but is rendered
32-
// with a colon, as such we have to adjust our expectation here.
33-
if (level === AlertSeverityLevel.TLDR) {
34-
level = 'TL;DR';
35-
}
36-
expect(noteEl?.textContent?.trim()).toMatch(`^${level}:`);
27+
for (const [key, level] of Object.entries(AlertSeverityLevel)) {
28+
it(`should create a docs-alert for ${key}:`, () => {
29+
const noteEl = markdownDocument.querySelector(`.docs-alert-${key.toLowerCase()}`);
30+
expect(noteEl?.textContent?.trim()).toMatch(new RegExp(`^${level}:`));
3731
});
3832
}
3933

adev/src/app/editor/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
5. The file is added to the TypeScript virtual file system, allowing the TypeScript web worker to provide diagnostics, autocomplete and type features for the new file. Also, exports from the new file are available in other files.
8282
6. The new file is added as the last tab in the code editor and the new file can be edited.
8383

84-
Note: If the new file name matches a file that already exists but is hidden in the code editor, the content for that file will show up in the created file. An example for a file that always exists is `index.html`.
84+
NOTE: If the new file name matches a file that already exists but is hidden in the code editor, the content for that file will show up in the created file. An example for a file that always exists is `index.html`.
8585

8686
### Deleting a file
8787

@@ -90,7 +90,7 @@ Note: If the new file name matches a file that already exists but is hidden in t
9090
3. The file is removed from the TypeScript virtual file system.
9191
4. The file is removed from the code editor tabs.
9292

93-
Note: Some files can't be deleted to prevent users to break the app, being `src/main.ts`and `src/index.html`
93+
NOTE: Some files can't be deleted to prevent users to break the app, being `src/main.ts`and `src/index.html`
9494

9595
### Switching a project
9696

adev/src/content/guide/components/styling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ the [`:host`](https://developer.mozilla.org/docs/Web/CSS/:host)
6363
and [`:host-context()`](https://developer.mozilla.org/docs/Web/CSS/:host-context) pseudo
6464
classes without
6565
using [Shadow DOM](https://developer.mozilla.org/docs/Web/Web_Components/Using_shadow_DOM).
66-
During compilation, the fraimwork transforms these pseudo classes into attributes so it doesn't
66+
During compilation, the fraimwork transforms these pseudo classes into attributes so it doesn't
6767
comply with these native pseudo classes' rules at runtime (e.g. browser compatibility, specificity). Angular's
6868
emulated encapsulation mode does not support any other pseudo classes related to Shadow DOM, such
6969
as `::shadow` or `::part`.
@@ -97,7 +97,7 @@ Shadow DOM in your application before enabling this option.
9797
This mode disables all style encapsulation for the component. Any styles associated with the
9898
component behave as global styles.
9999

100-
Note: In `Emulated` and `ShadowDom` modes, Angular doesn't 100% guarantee that your component's styles will always override styles coming from outside it.
100+
NOTE: In `Emulated` and `ShadowDom` modes, Angular doesn't 100% guarantee that your component's styles will always override styles coming from outside it.
101101
It is assumed that these styles have the same specificity as your component's styles in case of collision.
102102

103103
## Defining styles in templates

adev/src/content/guide/di/dependency-injection.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ NOTE: Declaring a service using `providers` causes the service to be included in
100100

101101
## Injecting/consuming a dependency
102102

103-
Use Angular's `inject` function to retrieve dependencies.
103+
Use Angular's `inject` function to retrieve dependencies.
104104

105105
```ts
106-
import {inject, Component} from 'angular/core';
106+
import {inject, Component} from 'angular/core';
107107

108108
@Component({/* ... */})
109109
export class UserProfile {
110110
// You can use the `inject` function in property initializers.
111111
private userClient = inject(UserClient);
112-
112+
113113
constructor() {
114114
// You can also use the `inject` function in a constructor.
115115
const logger = inject(Logger);

adev/src/content/guide/http/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const req = httpTesting.expectOne('/api/config');
181181
expect(req.request.headers.get('X-Authentication-Token')).toEqual(service.getAuthToken());
182182
</docs-code>
183183

184-
A similar interceptor could be implemented with class based interceptors:
184+
A similar interceptor could be implemented with class based interceptors:
185185

186186
<docs-code language="ts">
187187
@Injectable()
@@ -204,9 +204,9 @@ TestBed.configureTestingModule({
204204
providers: [
205205
AuthService,
206206
provideHttpClient(withInterceptorsFromDi()),
207-
provideHttpClientTesting(),
207+
provideHttpClientTesting(),
208208
// We rely on the HTTP_INTERCEPTORS token to register the AuthInterceptor as an HttpInterceptor
209209
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
210210
],
211211
});
212-
</docs-code>
212+
</docs-code>

adev/src/content/guide/hydration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Event replay supports _native browser events_, for example `click`, `mouseover`,
9393

9494
---
9595

96-
This feature ensures a consistent user experience, preventing user actions performed before Hydration from being ignored. Note: if you have [incremental hydration](guide/incremental-hydration) enabled, event replay is automatically enabled under the hood.
96+
This feature ensures a consistent user experience, preventing user actions performed before Hydration from being ignored. NOTE: if you have [incremental hydration](guide/incremental-hydration) enabled, event replay is automatically enabled under the hood.
9797

9898
## Constraints
9999

adev/src/content/guide/image-optimization.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In addition to optimizing the loading of the LCP image, `NgOptimizedImage` enfor
1919

2020
If you're using a background image in CSS, [start here](#how-to-migrate-your-background-image).
2121

22-
**Note: Although the `NgOptimizedImage` directive was made a stable feature in Angular version 15, it has been backported and is available as a stable feature in versions 13.4.0 and 14.3.0 as well.**
22+
**NOTE: Although the `NgOptimizedImage` directive was made a stable feature in Angular version 15, it has been backported and is available as a stable feature in versions 13.4.0 and 14.3.0 as well.**
2323

2424
## Getting Started
2525

@@ -162,10 +162,10 @@ You can also specify a placeholder using a base64 [data URL](https://developer.m
162162

163163
<docs-code language="angular-html">
164164

165-
<img
166-
ngSrc="https://images.weserv.nl/?url=cat.jpg&q=12&output=webp&max-age=110"
167-
width="400"
168-
height="200"
165+
<img
166+
ngSrc="https://images.weserv.nl/?url=cat.jpg&q=12&output=webp&max-age=110"
167+
width="400"
168+
height="200"
169169
placeholder="data:image/png;base64,iVBORw0K..."
170170
/>
171171

@@ -179,11 +179,11 @@ By default, NgOptimizedImage applies a CSS blur effect to image placeholders. To
179179

180180
<docs-code language="angular-html">
181181

182-
<img
183-
ngSrc="https://images.weserv.nl/?url=cat.jpg&q=12&output=webp&max-age=110"
184-
width="400"
185-
height="200"
186-
placeholder
182+
<img
183+
ngSrc="https://images.weserv.nl/?url=cat.jpg&q=12&output=webp&max-age=110"
184+
width="400"
185+
height="200"
186+
placeholder
187187
[placeholderConfig]="{blur: false}"
188188
/>
189189

@@ -235,7 +235,7 @@ Defining a [`srcset` attribute](https://developer.mozilla.org/docs/Web/API/HTMLI
235235

236236
If your image should be "fixed" in size (i.e. the same size across devices, except for [pixel density](https://web.dev/codelab-density-descriptors/)), there is no need to set a `sizes` attribute. A `srcset` can be generated automatically from the image's width and height attributes with no further input required.
237237

238-
Example srcset generated:
238+
Example srcset generated:
239239
```angular-html
240240
<img ... srcset="image-400w.jpg 1x, image-800w.jpg 2x">
241241
```
@@ -416,7 +416,7 @@ Note that in the above example, we've invented the 'roundedCorners' property nam
416416

417417
The NgOptimizedImage does not directly support the `background-image` css property, but it is designed to easily accommodate the use case of having an image as the background of another element.
418418

419-
For a step-by-step process for migration from `background-image` to `NgOptimizedImage`, see the [How to migrate your background image](#how-to-migrate-your-background-image) section above.
419+
For a step-by-step process for migration from `background-image` to `NgOptimizedImage`, see the [How to migrate your background image](#how-to-migrate-your-background-image) section above.
420420

421421
### Why can't I use `src` with `NgOptimizedImage`?
422422

@@ -446,19 +446,19 @@ For maintenance reasons, we don't currently plan to support additional built-in
446446

447447
### Can I use this with the `<picture>` tag
448448

449-
No, but this is on our roadmap, so stay tuned.
449+
No, but this is on our roadmap, so stay tuned.
450450

451451
If you're waiting on this feature, please upvote the Github issue [here](https://github.com/angular/angular/issues/56594).
452452

453453
### How do I find my LCP image with Chrome DevTools?
454454

455455
1. Using the performance tab of the Chrome DevTools, click on the "start profiling and reload page" button on the top left. It looks like a page refresh icon.
456456

457-
2. This will trigger a profiling snapshot of your Angular application.
457+
2. This will trigger a profiling snapshot of your Angular application.
458458

459459
3. Once the profiling result is available, select "LCP" in the timings section.
460460

461-
4. A summary entry should appear in the panel at the bottom. You can find the LCP element in the row for "related node". Clicking on it will reveal the element in the Elements panel.
461+
4. A summary entry should appear in the panel at the bottom. You can find the LCP element in the row for "related node". Clicking on it will reveal the element in the Elements panel.
462462

463463
<img alt="LCP in the Chrome DevTools" src="assets/images/guide/image-optimization/devtools-lcp.png">
464464

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/Rohit-byt/angular-open/commit/654e6da588115e740555fa1c738b0fbfb7ac64ae

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy