Skip to content

Commit 3731f07

Browse files
MeAkibpkozlowski-opensource
authored andcommitted
docs: format typescript examples and replace <docs-code> with fenced code blocks
Replaced <docs-code language="typescript" to improved readability and consistency across documentation.
1 parent 4e89bc6 commit 3731f07

8 files changed

Lines changed: 28 additions & 52 deletions

File tree

adev/src/content/best-practices/runtime-performance/skipping-subtrees.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ You can set the change detection strategy of a component to `OnPush` in the `@Co
1717

1818
```ts
1919
import { ChangeDetectionStrategy, Component } from '@angular/core';
20+
2021
@Component({
2122
changeDetection: ChangeDetectionStrategy.OnPush,
2223
})

adev/src/content/guide/di/creating-injectable-service.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Angular helps you follow these principles by making it easy to factor your appli
2121

2222
Here's an example of a service class that logs to the browser console:
2323

24-
<docs-code header="logger.service.ts (class)" language="typescript">
24+
```ts {header: "logger.service.ts (class)"}
2525
export class Logger {
2626
log(msg: unknown) { console.log(msg); }
2727
error(msg: unknown) { console.error(msg); }
2828
warn(msg: unknown) { console.warn(msg); }
2929
}
30-
</docs-code>
30+
```
3131

3232
Services can depend on other services.
3333
For example, here's a `HeroService` that depends on the `Logger` service, and also uses `BackendService` to get heroes.

adev/src/content/guide/i18n/format-data-locale.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,19 @@ The data transformation pipes use the [`LOCALE_ID`][ApiCoreLocaleId] token to fo
1414

1515
To display the current date in the format for the current locale, use the following format for the `DatePipe`.
1616

17-
<!--todo: replace with docs-code -->
18-
19-
<docs-code language="typescript">
20-
17+
```angular-html
2118
{{ today | date }}
22-
23-
</docs-code>
19+
```
2420

2521
## Override current locale for CurrencyPipe
2622

2723
Add the `locale` parameter to the pipe to override the current value of `LOCALE_ID` token.
2824

2925
To force the currency to use American English \(`en-US`\), use the following format for the `CurrencyPipe`
3026

31-
<!--todo: replace with docs-code -->
32-
33-
<docs-code language="typescript">
34-
27+
```angular-html
3528
{{ amount | currency : 'en-US' }}
36-
37-
</docs-code>
29+
```
3830

3931
HELPFUL: The locale specified for the `CurrencyPipe` overrides the global `LOCALE_ID` token of your application.
4032

adev/src/content/guide/i18n/manage-marked-text.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,9 @@ The following example defines the `introductionHeader` custom ID in a heading el
2828

2929
The following example defines the `introductionHeader` custom ID for a variable.
3030

31-
<!--todo: replace with code example -->
32-
33-
<docs-code language="typescript">
34-
31+
```ts
3532
variableText1 = $localize`:@@introductionHeader:Hello i18n!`;
36-
37-
</docs-code>
33+
```
3834

3935
When you specify a custom ID, the extractor generates a translation unit with the custom ID.
4036

@@ -54,27 +50,19 @@ The following example includes a description, followed by the custom ID.
5450

5551
The following example defines the `introductionHeader` custom ID and description for a variable.
5652

57-
<!--todo: replace with code example -->
58-
59-
<docs-code language="typescript">
60-
53+
```ts
6154
variableText2 = $localize`:An introduction header for this sample@@introductionHeader:Hello i18n!`;
62-
63-
</docs-code>
55+
```
6456

6557
The following example adds a meaning.
6658

6759
<docs-code header="app.component.html" path="adev/src/content/examples/i18n/doc-files/app.component.html" visibleRegion="i18n-attribute-meaning-and-id"/>
6860

6961
The following example defines the `introductionHeader` custom ID for a variable.
7062

71-
<!--todo: replace with code example -->
72-
73-
<docs-code language="typescript">
74-
63+
```ts
7564
variableText3 = $localize`:site header|An introduction header for this sample@@introductionHeader:Hello i18n!`;
76-
77-
</docs-code>
65+
```
7866

7967
### Define unique custom IDs
8068

adev/src/content/guide/testing/component-harnesses-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Harnesses offer several benefits:
88
- They make tests become more readable and easier to maintain
99
- They can be used across multiple testing environments
1010

11-
<docs-code language="typescript">
11+
```ts
1212
// Example of test with a harness for a component called MyButtonComponent
1313
it('should load button with exact text', async () => {
1414
const button = await loader.getHarness(MyButtonComponentHarness);
1515
expect(await button.getText()).toBe('Confirm');
1616
});
17-
</docs-code>
17+
```
1818

1919
Component harnesses are especially useful for shared UI widgets. Developers often write tests that depend on private implementation details of widgets, such as DOM structure and CSS classes. Those dependencies make tests brittle and hard to maintain. Harnesses offer an alternative— a supported API that interacts with the widget the same way an end-user does. Widget implementation changes now become less likely to break user tests. For example, [Angular Material](https://material.angular.dev/components/categories) provides a test harness for each component in the library.
2020

adev/src/content/guide/testing/components-scenarios.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,10 @@ To enable it, set a global flag before importing `zone-testing`.
304304

305305
If you use the Angular CLI, configure this flag in `src/test.ts`.
306306

307-
<docs-code language="typescript">
308-
307+
```ts
309308
[window as any]('__zone_symbol__fakeAsyncPatchLock') = true;
310309
import 'zone.js/testing';
311-
312-
</docs-code>
310+
```
313311

314312
<docs-code path="adev/src/content/examples/testing/src/app/demo/async-helper.spec.ts" visibleRegion="fake-async-test-clock"/>
315313

adev/src/content/reference/migrations/inject-function.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ export class MyComp {
7878

7979
#### After
8080

81-
```typescript
81+
```ts
8282
import { Component } from '@angular/core';
8383
import { MyService } from './service';
8484

8585
@Component()
8686
export class MyComp {
8787
private service = inject(MyService);
8888

89-
/* Inserted by Angular inject() migration for backwards compatibility */
90-
constructor(...args: unknown[]);
89+
/\*_ Inserted by Angular inject() migration for backwards compatibility _/
90+
constructor(...args: unknown[]);
9191

92-
constructor() {}
92+
constructor() {}
9393
}
9494
```
9595

adev/src/content/tools/cli/schematics-authoring.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,25 @@ A change can be accepted or ignored, or throw an exception.
3636
When you create a new blank schematic with the [Schematics CLI](#schematics-cli), the generated entry function is a _rule factory_.
3737
A `RuleFactory` object defines a higher-order function that creates a `Rule`.
3838

39-
<docs-code header="index.ts" language="typescript">
40-
39+
```ts {header: "index.ts"}
4140
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
4241

4342
// You don't have to export the function as default.
4443
// You can also have more than one rule factory per file.
4544
export function helloWorld(\_options: any): Rule {
46-
return (tree: Tree,\_context: SchematicContext) => {
47-
return tree;
48-
};
45+
return (tree: Tree,\_context: SchematicContext) => {
46+
return tree;
47+
};
4948
}
50-
51-
</docs-code>
49+
```
5250

5351
Your rules can make changes to your projects by calling external tools and implementing logic.
5452
You need a rule, for example, to define how a template in the schematic is to be merged into the hosting project.
5553

5654
Rules can make use of utilities provided with the `@schematics/angular` package.
5755
Look for helper functions for working with modules, dependencies, TypeScript, AST, JSON, Angular CLI workspaces and projects, and more.
5856

59-
<docs-code header="index.ts" language="typescript">
57+
```ts {header: "index.ts"}
6058

6159
import {
6260
JsonAstObject,
@@ -67,8 +65,7 @@ normalize,
6765
parseJsonAst,
6866
strings,
6967
} from '@angular-devkit/core';
70-
71-
</docs-code>
68+
```
7269

7370
### Defining input options with a schema and interfaces
7471

0 commit comments

Comments
 (0)