Skip to content

Commit 96ecb82

Browse files
eneajahothePunderWoman
authored andcommitted
docs: fix formatting and highlighting issues (angular#57144)
PR Close angular#57144
1 parent 79ab8c4 commit 96ecb82

File tree

42 files changed

+216
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+216
-191
lines changed

adev/src/content/best-practices/a11y.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,23 @@ The `RouterLinkActive` directive provides the `ariaCurrentWhenActive` input whic
128128
The following example shows how to apply the `active-page` class to active links as well as setting their `aria-current` attribute to `"page"` when they are active:
129129

130130
```angular-html
131-
<nav>
132-
<a routerLink="home"
133-
routerLinkActive="active-page"
134-
ariaCurrentWhenActive="page">
135-
Home
136-
</a>
137-
<a routerLink="about"
138-
routerLinkActive="active-page"
139-
ariaCurrentWhenActive="page">
140-
About
141-
</a>
142-
<a routerLink="shop"
143-
routerLinkActive="active-page"
144-
ariaCurrentWhenActive="page">
145-
Shop
146-
</a>
147-
</nav>
131+
<nav>
132+
<a routerLink="home"
133+
routerLinkActive="active-page"
134+
ariaCurrentWhenActive="page">
135+
Home
136+
</a>
137+
<a routerLink="about"
138+
routerLinkActive="active-page"
139+
ariaCurrentWhenActive="page">
140+
About
141+
</a>
142+
<a routerLink="shop"
143+
routerLinkActive="active-page"
144+
ariaCurrentWhenActive="page">
145+
Shop
146+
</a>
147+
</nav>
148148
```
149149

150150
<!-- vale Angular.Angular_Spelling = NO -->

adev/src/content/examples/router/src/app/app.component.1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ <h1>Angular Router</h1>
44
<a routerLink="/crisis-center" routerLinkActive="active" ariaCurrentWhenActive="page">Crisis Center</a>
55
<a routerLink="/heroes" routerLinkActive="active" ariaCurrentWhenActive="page">Heroes</a>
66
</nav>
7-
<router-outlet></router-outlet>
7+
<router-outlet></router-outlet>

adev/src/content/guide/components/advanced-configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ By default, Angular throws an error when it encounters an unknown HTML element.
3434
disable this behavior for a component by including `CUSTOM_ELEMENTS_SCHEMA` in the `schemas`
3535
property in your component metadata.
3636

37-
```ts
37+
```angular-ts
3838
import {Component, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
3939
4040
@Component({

adev/src/content/guide/components/anatomy-of-components.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Every component must have:
1111

1212
You provide Angular-specific information for a component by adding a `@Component` [decorator](https://www.typescriptlang.org/docs/handbook/decorators.html) on top of the TypeScript class:
1313

14-
<docs-code language="ts" highlight="[1, 2, 3, 4]">
14+
<docs-code language="angular-ts" highlight="[1, 2, 3, 4]">
1515
@Component({
1616
selector: 'profile-photo',
1717
template: `<img src="profile-photo.jpg" alt="Your profile photo">`,
@@ -25,7 +25,7 @@ The object passed to the `@Component` decorator is called the component's **meta
2525

2626
Components can optionally include a list of CSS styles that apply to that component's DOM:
2727

28-
<docs-code language="ts" highlight="[4]">
28+
<docs-code language="angular-ts" highlight="[4]">
2929
@Component({
3030
selector: 'profile-photo',
3131
template: `<img src="profile-photo.jpg" alt="Your profile photo">`,
@@ -38,7 +38,7 @@ By default, a component's styles only affect elements defined in that component'
3838

3939
You can alternatively choose to write your template and styles in separate files:
4040

41-
<docs-code language="ts" highlight="[3, 4]">
41+
<docs-code language="angular-ts" highlight="[3, 4]">
4242
@Component({
4343
selector: 'profile-photo',
4444
templateUrl: 'profile-photo.html',
@@ -55,7 +55,7 @@ Both `templateUrl` and `styleUrl` are relative to the directory in which the com
5555

5656
Every component defines a [CSS selector](https://developer.mozilla.org/docs/Learn/CSS/Building_blocks/Selectors):
5757

58-
<docs-code language="ts" highlight="[2]">
58+
<docs-code language="angular-ts" highlight="[2]">
5959
@Component({
6060
selector: 'profile-photo',
6161
...
@@ -67,7 +67,7 @@ See [Component Selectors](guide/components/selectors) for details about which ty
6767

6868
You use a component by creating a matching HTML element in the template of _other_ components:
6969

70-
<docs-code language="ts" highlight="[4]">
70+
<docs-code language="angular-ts" highlight="[4]">
7171
@Component({
7272
selector: 'user-profile',
7373
template: `

adev/src/content/guide/components/content-projection.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tip: This guide assumes you've already read the [Essentials Guide](essentials).
55
You often need to create components that act as containers for different types of content. For
66
example, you may want to create a custom card component:
77

8-
```ts
8+
```angular-ts
99
@Component({
1010
selector: 'custom-card',
1111
template: '<div class="card-shadow"> <!-- card content goes here --> </div>',
@@ -15,7 +15,7 @@ export class CustomCard {/* ... */}
1515

1616
**You can use the `<ng-content>` element as a placeholder to mark where content should go**:
1717

18-
```ts
18+
```angular-ts
1919
@Component({
2020
selector: 'custom-card',
2121
template: '<div class="card-shadow"> <ng-content></ng-content> </div>',
@@ -30,7 +30,7 @@ but with some Angular-specific functionality.
3030
When you use a component with `<ng-content>`, any children of the component host element are
3131
rendered, or **projected**, at the location of that `<ng-content>`:
3232

33-
```ts
33+
```angular-ts
3434
// Component source
3535
@Component({
3636
selector: 'custom-card',

adev/src/content/guide/components/host-elements.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Angular creates an instance of a component for every HTML element that matches t
66
selector. The DOM element that matches a component's selector is that component's **host element**.
77
The contents of a component's template are rendered inside its host element.
88

9-
```ts
9+
```angular-ts
1010
// Component source
1111
@Component({
1212
selector: 'profile-photo',
@@ -41,7 +41,7 @@ A component can bind properties, attributes, and events to its host element. Thi
4141
identically to bindings on elements inside the component's template, but instead defined with
4242
the `host` property in the `@Component` decorator:
4343

44-
```ts
44+
```angular-ts
4545
@Component({
4646
...,
4747
host: {
@@ -68,7 +68,7 @@ decorator to class members.
6868

6969
`@HostBinding` lets you bind host properties and attributes to properties and methods:
7070

71-
```ts
71+
```angular-ts
7272
@Component({
7373
/* ... */
7474
})
@@ -105,7 +105,7 @@ decorators exist exclusively for backwards compatibility.
105105
When you use a component in a template, you can add bindings to that component instance's element.
106106
The component may _also_ define host bindings for the same properties or attributes.
107107

108-
```ts
108+
```angular-ts
109109
@Component({
110110
...,
111111
host: {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A **standalone component** is a component that sets `standalone: true` in its co
1010
Standalone components directly import other components, directives, and pipes used in their
1111
templates:
1212

13-
<docs-code language="ts" highlight="[2, [8, 9]]">
13+
<docs-code language="angular-ts" highlight="[2, [8, 9]]">
1414
@Component({
1515
standalone: true,
1616
selector: 'profile-photo',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ When a component extends another component or a directive, it inherits all the m
2424
the base class's decorator and the base class's decorated members. This includes the selector,
2525
template, styles, host bindings, inputs, outputs, lifecycle methods, and any other settings.
2626

27-
```ts
27+
```angular-ts
2828
@Component({
2929
selector: 'base-listbox',
3030
template: `

adev/src/content/guide/components/programmatic-rendering.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ or in your TypeScript code with `ViewContainerRef`.
1111
`NgComponentOutlet` is a structural directive that dynamically renders a given component in a
1212
template.
1313

14-
```ts
14+
```angular-ts
1515
@Component({ ... })
1616
export class AdminBio { /* ... */ }
1717
@@ -46,7 +46,7 @@ You can use the `createComponent`method on `ViewContainerRef` to dynamically cre
4646
component. When you create a new component with a `ViewContainerRef`, Angular appends it into the
4747
DOM as the next sibling of the component or directive that injected the `ViewContainerRef`.
4848

49-
```ts
49+
```angular-ts
5050
@Component({
5151
selector: 'leaf-content',
5252
template: `
@@ -99,7 +99,7 @@ You can use both of the approaches described above, `NgComponentOutlet` and `Vie
9999
render components that are lazy-loaded with a standard
100100
JavaScript [dynamic import](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/import).
101101

102-
```ts
102+
```angular-ts
103103
@Component({
104104
...,
105105
template: `
@@ -113,7 +113,8 @@ JavaScript [dynamic import](https://developer.mozilla.org/docs/Web/JavaScript/Re
113113
Load advanced settings
114114
</button>
115115
<ng-container *ngComponentOutlet="advancedSettings" />
116-
</section>`
116+
</section>
117+
`
117118
})
118119
export class AdminSettings {
119120
advancedSettings: {new(): AdminSettings} | undefined;

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ There are two categories of query: **view queries** and **content queries.**
1212

1313
View queries retrieve results from the elements in the component's _view_ — the elements defined in the component's own template. You can query for a single result with the `@ViewChild` decorator.
1414

15-
<docs-code language="ts" highlight="[14, 16, 17, 18]">
15+
<docs-code language="angular-ts" highlight="[14, 16, 17, 18]">
1616
@Component({
1717
selector: 'custom-card-header',
1818
...
@@ -42,7 +42,7 @@ If the query does not find a result, its value is `undefined`. This may occur if
4242

4343
You can also query for multiple results with the `@ViewChildren` decorator.
4444

45-
<docs-code language="ts" highlight="[17, 19, 20, 21, 22, 23]">
45+
<docs-code language="angular-ts" highlight="[17, 19, 20, 21, 22, 23]">
4646
@Component({
4747
selector: 'custom-card-action',
4848
...,
@@ -77,7 +77,7 @@ export class CustomCard {
7777

7878
Content queries retrieve results from the elements in the component's _content_— the elements nested inside the component in the template where it's used. You can query for a single result with the `@ContentChild` decorator.
7979

80-
<docs-code language="ts" highlight="[14, 16, 17, 18, 25]">
80+
<docs-code language="angular-ts" highlight="[14, 16, 17, 18, 25]">
8181
@Component({
8282
selector: 'custom-toggle',
8383
...
@@ -106,6 +106,7 @@ export class CustomExpando {
106106
</custom-expando>
107107
`
108108
})
109+
export class UserProfile { }
109110
</docs-code>
110111

111112
In this example, the `CustomExpando` component queries for a child `CustomToggle` and accesses the result in `ngAfterContentInit`.
@@ -118,7 +119,7 @@ By default, content queries find only _direct_ children of the component and do
118119

119120
You can also query for multiple results with the `@ContentChildren` decorator.
120121

121-
<docs-code language="ts" highlight="[14, 16, 17, 18, 19, 20]">
122+
<docs-code language="angular-ts" highlight="[14, 16, 17, 18, 19, 20]">
122123
@Component({
123124
selector: 'custom-menu-item',
124125
...
@@ -150,6 +151,7 @@ export class CustomMenu {
150151
</custom-menu>
151152
`
152153
})
154+
export class UserProfile { }
153155
</docs-code>
154156

155157
`@ContentChildren` creates a `QueryList` object that contains the query results. You can subscribe to changes to the query results over time via the `changes` property.
@@ -165,7 +167,7 @@ Most of the time, you want to use a component or directive as your locator.
165167
You can alternatively specify a string locator corresponding to
166168
a [template reference variable](guide/templates/reference-variables).
167169

168-
```ts
170+
```angular-ts
169171
@Component({
170172
...,
171173
template: `
@@ -188,7 +190,7 @@ Tip: See [Dependency Injection](guide/di) for background on providers and Angula
188190

189191
For more advanced cases, you can use any `ProviderToken` as a locator. This lets you locate elements based on component and directive providers.
190192

191-
```ts
193+
```angular-ts
192194
const SUB_ITEM = new InjectionToken<string>('sub-item');
193195
194196
@Component({
@@ -213,7 +215,7 @@ All query decorators accept an options object as a second parameter. These optio
213215

214216
`@ViewChild` and `@ContentChild` queries accept the `static` option.
215217

216-
```ts
218+
```angular-ts
217219
@Component({
218220
selector: 'custom-card',
219221
template: '<custom-card-header>Visit sunny California!</custom-card-header>',
@@ -237,7 +239,7 @@ The `static` option is not available for `@ViewChildren` and `@ContentChildren`
237239

238240
By default, content queries find only _direct_ children of the component and do not traverse into descendants.
239241

240-
<docs-code language="ts" highlight="[13, 14, 15, 16]">
242+
<docs-code language="angular-ts" highlight="[13, 14, 15, 16]">
241243
@Component({
242244
selector: 'custom-expando',
243245
...
@@ -257,6 +259,7 @@ export class CustomExpando {
257259
</custom-expando>
258260
`
259261
})
262+
export class UserProfile { }
260263
</docs-code>
261264

262265
In the example above, `CustomExpando` cannot find `<custom-toggle>` because it is not a direct child of `<custom-expando>`. By setting `descendants: true`, you configure the query to traverse all descendants in the same template. Queries, however, _never_ pierce into components to traverse elements in other templates.

0 commit comments

Comments
 (0)