Skip to content

Commit 2d8635d

Browse files
josephperrottthePunderWoman
authored andcommitted
refactor(docs-infra): migrate @angular/docs from dev-infra into adev directory (angular#57132)
To increase the ease of development we are moving @angular/docs into the adev directory within this repo. While we are doing this to improve our development experience in the short term, efforts are also in place to maintain a division between this @angular/docs (shared) code and adev itself, so that it can be extracted back out in the future when components is ready to leverage it as well. PR Close angular#57132
1 parent dd56270 commit 2d8635d

File tree

353 files changed

+28243
-90
lines changed

Some content is hidden

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

353 files changed

+28243
-90
lines changed

adev/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ APPLICATION_DEPS = [
8181
"@npm//@lezer/common",
8282
"@npm//@stackblitz/sdk",
8383
"@npm//open-in-idx",
84+
"@npm//@webcontainer/api",
8485
"@npm//@xterm/xterm",
8586
"@npm//@xterm/addon-fit",
8687
"@npm//algoliasearch",

adev/shared-docs/BUILD.bazel

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
load("//tools:defaults.bzl", "ng_module", "ng_package")
2+
3+
package(default_visibility = ["//visibility:private"])
4+
5+
ng_module(
6+
name = "docs",
7+
srcs = [
8+
"index.ts",
9+
],
10+
module_name = "@angular/docs",
11+
deps = [
12+
"//adev/shared-docs/components",
13+
"//adev/shared-docs/constants",
14+
"//adev/shared-docs/directives",
15+
"//adev/shared-docs/interfaces",
16+
"//adev/shared-docs/pipes",
17+
"//adev/shared-docs/providers",
18+
"//adev/shared-docs/services",
19+
"//adev/shared-docs/utils",
20+
],
21+
)
22+
23+
ng_package(
24+
name = "npm_package",
25+
srcs = [
26+
"package.json",
27+
"//adev/shared-docs/icons",
28+
"//adev/shared-docs/pipeline:BUILD.bazel",
29+
"//adev/shared-docs/pipeline:_guides.bzl",
30+
"//adev/shared-docs/pipeline:_playground.bzl",
31+
"//adev/shared-docs/pipeline:_stackblitz.bzl",
32+
"//adev/shared-docs/pipeline:_tutorial.bzl",
33+
"//adev/shared-docs/pipeline:guides.mjs",
34+
"//adev/shared-docs/pipeline:guides-no-mermaid.mjs",
35+
"//adev/shared-docs/pipeline:playground.mjs",
36+
"//adev/shared-docs/pipeline:stackblitz.mjs",
37+
"//adev/shared-docs/pipeline:tutorial.mjs",
38+
"//adev/shared-docs/pipeline/examples/template:files",
39+
"//adev/shared-docs/pipeline/tutorials/common:files",
40+
"//adev/shared-docs/styles",
41+
"//adev/shared-docs/testing",
42+
],
43+
visibility = [
44+
"//adev:__pkg__",
45+
],
46+
deps = [
47+
":docs",
48+
],
49+
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
load("//tools:defaults.bzl", "ts_library")
2+
3+
package(default_visibility = ["//visibility:private"])
4+
5+
ts_library(
6+
name = "components",
7+
srcs = [
8+
"index.ts",
9+
],
10+
visibility = [
11+
"//adev/shared-docs:__pkg__",
12+
],
13+
deps = [
14+
"//adev/shared-docs/components/algolia-icon",
15+
"//adev/shared-docs/components/breadcrumb",
16+
"//adev/shared-docs/components/cookie-popup",
17+
"//adev/shared-docs/components/copy-source-code-button",
18+
"//adev/shared-docs/components/icon",
19+
"//adev/shared-docs/components/navigation-list",
20+
"//adev/shared-docs/components/search-dialog",
21+
"//adev/shared-docs/components/select",
22+
"//adev/shared-docs/components/slide-toggle",
23+
"//adev/shared-docs/components/table-of-contents",
24+
"//adev/shared-docs/components/text-field",
25+
"//adev/shared-docs/components/viewers",
26+
],
27+
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("//tools:defaults.bzl", "ng_module")
2+
3+
package(default_visibility = ["//visibility:private"])
4+
5+
ng_module(
6+
name = "algolia-icon",
7+
srcs = [
8+
"algolia-icon.component.ts",
9+
],
10+
assets = [
11+
"algolia-icon.component.html",
12+
],
13+
visibility = [
14+
"//adev/shared-docs/components:__pkg__",
15+
"//adev/shared-docs/components/search-dialog:__pkg__",
16+
],
17+
deps = [
18+
"//packages/core",
19+
],
20+
)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!-- Algolia logo -->
2+
<svg
3+
id="Layer_1"
4+
class="docs-algolia-logo"
5+
xmlns="http://www.w3.org/2000/svg"
6+
viewBox="0 0 2196.2 500"
7+
>
8+
<defs>
9+
<style>
10+
.cls-1,
11+
.cls-2 {
12+
fill: #003dff;
13+
}
14+
.cls-2 {
15+
fill-rule: evenodd;
16+
}
17+
</style>
18+
</defs>
19+
<path
20+
class="cls-2"
21+
d="M1070.38,275.3V5.91c0-3.63-3.24-6.39-6.82-5.83l-50.46,7.94c-2.87,.45-4.99,2.93-4.99,5.84l.17,273.22c0,12.92,0,92.7,95.97,95.49,3.33,.1,6.09-2.58,6.09-5.91v-40.78c0-2.96-2.19-5.51-5.12-5.84-34.85-4.01-34.85-47.57-34.85-54.72Z"
22+
/>
23+
<rect class="cls-1" x="1845.88" y="104.73" width="62.58" height="277.9" rx="5.9" ry="5.9" />
24+
<path
25+
class="cls-2"
26+
d="M1851.78,71.38h50.77c3.26,0,5.9-2.64,5.9-5.9V5.9c0-3.62-3.24-6.39-6.82-5.83l-50.77,7.95c-2.87,.45-4.99,2.92-4.99,5.83v51.62c0,3.26,2.64,5.9,5.9,5.9Z"
27+
/>
28+
<path
29+
class="cls-2"
30+
d="M1764.03,275.3V5.91c0-3.63-3.24-6.39-6.82-5.83l-50.46,7.94c-2.87,.45-4.99,2.93-4.99,5.84l.17,273.22c0,12.92,0,92.7,95.97,95.49,3.33,.1,6.09-2.58,6.09-5.91v-40.78c0-2.96-2.19-5.51-5.12-5.84-34.85-4.01-34.85-47.57-34.85-54.72Z"
31+
/>
32+
<path
33+
class="cls-2"
34+
d="M1631.95,142.72c-11.14-12.25-24.83-21.65-40.78-28.31-15.92-6.53-33.26-9.85-52.07-9.85-18.78,0-36.15,3.17-51.92,9.85-15.59,6.66-29.29,16.05-40.76,28.31-11.47,12.23-20.38,26.87-26.76,44.03-6.38,17.17-9.24,37.37-9.24,58.36,0,20.99,3.19,36.87,9.55,54.21,6.38,17.32,15.14,32.11,26.45,44.36,11.29,12.23,24.83,21.62,40.6,28.46,15.77,6.83,40.12,10.33,52.4,10.48,12.25,0,36.78-3.82,52.7-10.48,15.92-6.68,29.46-16.23,40.78-28.46,11.29-12.25,20.05-27.04,26.25-44.36,6.22-17.34,9.24-33.22,9.24-54.21,0-20.99-3.34-41.19-10.03-58.36-6.38-17.17-15.14-31.8-26.43-44.03Zm-44.43,163.75c-11.47,15.75-27.56,23.7-48.09,23.7-20.55,0-36.63-7.8-48.1-23.7-11.47-15.75-17.21-34.01-17.21-61.2,0-26.89,5.59-49.14,17.06-64.87,11.45-15.75,27.54-23.52,48.07-23.52,20.55,0,36.63,7.78,48.09,23.52,11.47,15.57,17.36,37.98,17.36,64.87,0,27.19-5.72,45.3-17.19,61.2Z"
35+
/>
36+
<path
37+
class="cls-2"
38+
d="M894.42,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-14.52,22.58-22.99,49.63-22.99,78.73,0,44.89,20.13,84.92,51.59,111.1,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47,1.23,0,2.46-.03,3.68-.09,.36-.02,.71-.05,1.07-.07,.87-.05,1.75-.11,2.62-.2,.34-.03,.68-.08,1.02-.12,.91-.1,1.82-.21,2.73-.34,.21-.03,.42-.07,.63-.1,32.89-5.07,61.56-30.82,70.9-62.81v57.83c0,3.26,2.64,5.9,5.9,5.9h50.42c3.26,0,5.9-2.64,5.9-5.9V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,206.92c-12.2,10.16-27.97,13.98-44.84,15.12-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-42.24,0-77.12-35.89-77.12-79.37,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33v142.83Z"
39+
/>
40+
<path
41+
class="cls-2"
42+
d="M2133.97,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-14.52,22.58-22.99,49.63-22.99,78.73,0,44.89,20.13,84.92,51.59,111.1,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47,1.23,0,2.46-.03,3.68-.09,.36-.02,.71-.05,1.07-.07,.87-.05,1.75-.11,2.62-.2,.34-.03,.68-.08,1.02-.12,.91-.1,1.82-.21,2.73-.34,.21-.03,.42-.07,.63-.1,32.89-5.07,61.56-30.82,70.9-62.81v57.83c0,3.26,2.64,5.9,5.9,5.9h50.42c3.26,0,5.9-2.64,5.9-5.9V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,206.92c-12.2,10.16-27.97,13.98-44.84,15.12-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-42.24,0-77.12-35.89-77.12-79.37,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33v142.83Z"
43+
/>
44+
<path
45+
class="cls-2"
46+
d="M1314.05,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-11.79,18.34-19.6,39.64-22.11,62.59-.58,5.3-.88,10.68-.88,16.14s.31,11.15,.93,16.59c4.28,38.09,23.14,71.61,50.66,94.52,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47h0c17.99,0,34.61-5.93,48.16-15.97,16.29-11.58,28.88-28.54,34.48-47.75v50.26h-.11v11.08c0,21.84-5.71,38.27-17.34,49.36-11.61,11.08-31.04,16.63-58.25,16.63-11.12,0-28.79-.59-46.6-2.41-2.83-.29-5.46,1.5-6.27,4.22l-12.78,43.11c-1.02,3.46,1.27,7.02,4.83,7.53,21.52,3.08,42.52,4.68,54.65,4.68,48.91,0,85.16-10.75,108.89-32.21,21.48-19.41,33.15-48.89,35.2-88.52V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,64.1s.65,139.13,0,143.36c-12.08,9.77-27.11,13.59-43.49,14.7-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-1.32,0-2.63-.03-3.94-.1-40.41-2.11-74.52-37.26-74.52-79.38,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33Z"
47+
/>
48+
<path
49+
class="cls-1"
50+
d="M249.83,0C113.3,0,2,110.09,.03,246.16c-2,138.19,110.12,252.7,248.33,253.5,42.68,.25,83.79-10.19,120.3-30.03,3.56-1.93,4.11-6.83,1.08-9.51l-23.38-20.72c-4.75-4.21-11.51-5.4-17.36-2.92-25.48,10.84-53.17,16.38-81.71,16.03-111.68-1.37-201.91-94.29-200.13-205.96,1.76-110.26,92-199.41,202.67-199.41h202.69V407.41l-115-102.18c-3.72-3.31-9.42-2.66-12.42,1.31-18.46,24.44-48.53,39.64-81.93,37.34-46.33-3.2-83.87-40.5-87.34-86.81-4.15-55.24,39.63-101.52,94-101.52,49.18,0,89.68,37.85,93.91,85.95,.38,4.28,2.31,8.27,5.52,11.12l29.95,26.55c3.4,3.01,8.79,1.17,9.63-3.3,2.16-11.55,2.92-23.58,2.07-35.92-4.82-70.34-61.8-126.93-132.17-131.26-80.68-4.97-148.13,58.14-150.27,137.25-2.09,77.1,61.08,143.56,138.19,145.26,32.19,.71,62.03-9.41,86.14-26.95l150.26,133.2c6.44,5.71,16.61,1.14,16.61-7.47V9.48C499.66,4.25,495.42,0,490.18,0H249.83Z"
51+
/>
52+
</svg>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*!
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
8+
9+
import {ChangeDetectionStrategy, Component} from '@angular/core';
10+
11+
@Component({
12+
selector: 'docs-algolia-icon',
13+
standalone: true,
14+
changeDetection: ChangeDetectionStrategy.OnPush,
15+
imports: [],
16+
templateUrl: './algolia-icon.component.html',
17+
})
18+
export class AlgoliaIcon {}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
load("//tools:defaults.bzl", "karma_web_test_suite", "ng_module", "ts_library")
2+
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
3+
4+
package(default_visibility = ["//visibility:private"])
5+
6+
ng_module(
7+
name = "breadcrumb",
8+
srcs = [
9+
"breadcrumb.component.ts",
10+
],
11+
assets = [
12+
":breadcrumb.component.css",
13+
"breadcrumb.component.html",
14+
],
15+
visibility = [
16+
"//adev/shared-docs/components:__pkg__",
17+
"//adev/shared-docs/components/viewers:__pkg__",
18+
],
19+
deps = [
20+
"//adev/shared-docs/interfaces",
21+
"//adev/shared-docs/services",
22+
"//packages/common",
23+
"//packages/core",
24+
"//packages/router",
25+
],
26+
)
27+
28+
sass_binary(
29+
name = "style",
30+
src = "breadcrumb.component.scss",
31+
)
32+
33+
ts_library(
34+
name = "test_lib",
35+
testonly = True,
36+
srcs = glob(
37+
["*.spec.ts"],
38+
),
39+
deps = [
40+
":breadcrumb",
41+
"//adev/shared-docs/interfaces",
42+
"//adev/shared-docs/services",
43+
"//packages/core",
44+
"//packages/core/testing",
45+
"//packages/platform-browser",
46+
"//packages/router",
47+
"//packages/router/testing",
48+
],
49+
)
50+
51+
karma_web_test_suite(
52+
name = "test",
53+
deps = [":test_lib"],
54+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@for (breadcrumb of breadcrumbItems(); track breadcrumb) {
2+
<div class="docs-breadcrumb">
3+
@if (breadcrumb.path) {
4+
@if (breadcrumb.isExternal) {
5+
<a [href]="breadcrumb.path">{{ breadcrumb.label }}</a>
6+
} @else {
7+
<a [routerLink]="'/' + breadcrumb.path">{{ breadcrumb.label }}</a>
8+
}
9+
} @else {
10+
<span>{{ breadcrumb.label }}</span>
11+
}
12+
</div>
13+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
:host {
2+
display: flex;
3+
align-items: center;
4+
padding-block-end: 1.5rem;
5+
}
6+
7+
.docs-breadcrumb {
8+
span {
9+
color: var(--quaternary-contrast);
10+
font-size: 0.875rem;
11+
display: flex;
12+
align-items: center;
13+
}
14+
15+
&:not(:last-child) {
16+
span {
17+
&::after {
18+
content: 'chevron_right';
19+
font-family: var(--icons);
20+
margin-inline: 0.5rem;
21+
color: var(--quinary-contrast);
22+
}
23+
}
24+
}
25+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*!
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
8+
9+
import {ComponentFixture, TestBed} from '@angular/core/testing';
10+
11+
import {Breadcrumb} from './breadcrumb.component';
12+
import {NavigationState} from '../../services';
13+
import {NavigationItem} from '../../interfaces';
14+
import {By} from '@angular/platform-browser';
15+
import {RouterTestingModule} from '@angular/router/testing';
16+
import {provideExperimentalZonelessChangeDetection} from '@angular/core';
17+
18+
describe('Breadcrumb', () => {
19+
let fixture: ComponentFixture<Breadcrumb>;
20+
let navigationStateSpy: jasmine.SpyObj<NavigationState>;
21+
22+
beforeEach(() => {
23+
navigationStateSpy = jasmine.createSpyObj('NavigationState', ['activeNavigationItem']);
24+
25+
TestBed.configureTestingModule({
26+
imports: [Breadcrumb, RouterTestingModule],
27+
providers: [
28+
provideExperimentalZonelessChangeDetection(),
29+
{
30+
provide: NavigationState,
31+
useValue: navigationStateSpy,
32+
},
33+
],
34+
});
35+
fixture = TestBed.createComponent(Breadcrumb);
36+
});
37+
38+
it('should display proper breadcrumb structure based on navigation state', () => {
39+
navigationStateSpy.activeNavigationItem.and.returnValue(item);
40+
41+
fixture.detectChanges();
42+
const breadcrumbs = fixture.debugElement.queryAll(By.css('.docs-breadcrumb span'));
43+
44+
expect(breadcrumbs.length).toBe(2);
45+
expect(breadcrumbs[0].nativeElement.innerText).toEqual('Grandparent');
46+
expect(breadcrumbs[1].nativeElement.innerText).toEqual('Parent');
47+
});
48+
49+
it('should display breadcrumb links when navigation item has got path', () => {
50+
navigationStateSpy.activeNavigationItem.and.returnValue(exampleItemWithPath);
51+
52+
fixture.detectChanges();
53+
const breadcrumbs = fixture.debugElement.queryAll(By.css('.docs-breadcrumb a'));
54+
55+
expect(breadcrumbs.length).toBe(1);
56+
expect(breadcrumbs[0].nativeElement.innerText).toEqual('Parent');
57+
expect(breadcrumbs[0].nativeElement.href).toEqual(`${window.origin}/example`);
58+
});
59+
});
60+
61+
const grandparent: NavigationItem = {
62+
label: 'Grandparent',
63+
};
64+
65+
const parent: NavigationItem = {
66+
label: 'Parent',
67+
parent: grandparent,
68+
};
69+
70+
const item: NavigationItem = {
71+
label: 'Active Item',
72+
parent: parent,
73+
};
74+
75+
const parentWithPath: NavigationItem = {
76+
label: 'Parent',
77+
path: '/example',
78+
};
79+
80+
const exampleItemWithPath: NavigationItem = {
81+
label: 'Active Item',
82+
parent: parentWithPath,
83+
};

0 commit comments

Comments
 (0)