_id
stringlengths 21
254
| text
stringlengths 1
93.7k
| metadata
dict |
---|---|---|
angular/adev/shared-docs/pipeline/guides/testing/docs-workflow/docs-workflow.md_0_177 | <docs-workflow>
<docs-step title="Step 1">
Do the first thing.
</docs-step>
<docs-step title="Step B">
Do another thing after that.
</docs-step>
</docs-workflow> | {
"end_byte": 177,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-workflow/docs-workflow.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-workflow/docs-workflow.spec.ts_0_763 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-workflow/docs-workflow.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('create an ordered list container around the docs-steps', () => {
const docsWorkflowEl = markdownDocument.querySelector('.docs-steps')!;
expect(docsWorkflowEl.tagName).toBe('OL');
expect(docsWorkflowEl.children.length).toBe(2);
});
});
| {
"end_byte": 763,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-workflow/docs-workflow.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-pill-row/docs-pill-row.md_0_122 | <docs-pill-row>
<docs-pill href="#pill-row" title="Link"/>
<docs-pill href="#pill-row" title="Link"/>
</docs-pill-row> | {
"end_byte": 122,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-pill-row/docs-pill-row.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-pill-row/docs-pill-row.spec.ts_0_766 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-pill-row/docs-pill-row.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('should create a nav container with all of the docs pills inside', () => {
const navEl = markdownDocument.querySelector('nav');
expect(navEl?.children.length).toBe(2);
expect(navEl?.classList.contains('docs-pill-row')).toBeTrue();
});
});
| {
"end_byte": 766,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-pill-row/docs-pill-row.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-callout/docs-callout.spec.ts_0_732 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-callout/docs-callout.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it(`defaults to a helpful callout`, () => {
const calloutDiv =
markdownDocument.querySelector('#default-marker')!.parentElement?.parentElement;
calloutDiv?.classList.contains('docs-callout-helpful');
});
});
| {
"end_byte": 732,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-callout/docs-callout.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-callout/docs-callout.md_0_570 | <docs-callout title="Default callout title" id="test">
<span id="default-marker"></span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</docs-callout>
<docs-callout critical title="Callout title for critical">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</docs-callout>
<docs-callout important title="Callout title for important">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</docs-callout>
<docs-callout helpful title="Callout title for helpful">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</docs-callout> | {
"end_byte": 570,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-callout/docs-callout.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/heading/heading.md_0_405 | # Top Header (h1)
## Headers (h2)
### Smaller headers (h3)
#### Even smaller (h4)
##### Even more smaller (h5)
###### The smallest! (h6)
##### Another "more smaller" (h5)
## Duplicate Anchor
## Duplicate Anchor
## `myClass.myMethod` is the best
## ステップ 2 - アプリケーションのレイアウトに新しいコンポーネントを追加
## My heading {# my-custom-id }
## Query for the `<h1>` | {
"end_byte": 405,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/heading/heading.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/heading/heading.spec.ts_0_3372 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(runfiles.resolvePackageRelative('heading/heading.md'), {
encoding: 'utf-8',
});
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('should treat # as document headers', () => {
const header = markdownDocument.querySelector('header');
expect(header?.classList.contains('docs-header')).toBeTrue();
});
it('should create a self referential link for non document headers', () => {
const h2 = markdownDocument.querySelector('h2');
const h2Anchor = h2?.firstElementChild;
const h2HeaderId = h2?.getAttribute('id');
const h2AnchorHref = h2Anchor?.getAttribute('href');
expect(h2HeaderId).toContain('headers-h2');
expect(h2AnchorHref).toBe(`#${h2HeaderId}`);
});
it('should make the docs anchors unreachable by tab', () => {
const docsAnchors = markdownDocument.querySelectorAll('.docs-anchor');
for (const anchor of docsAnchors) {
expect(anchor.getAttribute('tabindex')).toBe('-1');
}
});
it('increments when multiple duplicate header names are found', () => {
const headers = markdownDocument.querySelectorAll('a.docs-anchor');
const knownRefs = new Set<string>();
for (const el of headers) {
const href = el.getAttribute('href');
expect(knownRefs.has(href!)).toBeFalse();
knownRefs.add(href!);
}
});
it('should remove code block markups', () => {
const h2List = markdownDocument.querySelectorAll('h2');
const h2 = h2List[3];
const h2Anchor = h2?.firstElementChild;
const h2HeaderId = h2?.getAttribute('id');
const h2AnchorHref = h2Anchor?.getAttribute('href');
expect(h2HeaderId).toContain('myclassmymethod-is-the-best');
expect(h2AnchorHref).toBe(`#${h2HeaderId}`);
});
it('should be able to extract non-ascii ids', () => {
const h2List = markdownDocument.querySelectorAll('h2');
const h2 = h2List[4];
const h2Anchor = h2?.firstElementChild;
const h2HeaderId = h2?.getAttribute('id');
const h2AnchorHref = h2Anchor?.getAttribute('href');
expect(h2HeaderId).toContain(
'ステップ-2---アプリケーションのレイアウトに新しいコンポーネントを追加',
);
expect(h2AnchorHref).toBe(`#${h2HeaderId}`);
});
it('should be able to extract custom ids', () => {
const h2List = markdownDocument.querySelectorAll('h2');
const h2 = h2List[5];
const h2Anchor = h2?.firstElementChild;
const h2HeaderId = h2?.getAttribute('id');
const h2AnchorHref = h2Anchor?.getAttribute('href');
expect(h2HeaderId).toBe('my-custom-id');
expect(h2AnchorHref).toBe(`#${h2HeaderId}`);
});
it('should be able to parse heading with a valid tag in a code block', () => {
const h2List = markdownDocument.querySelectorAll('h2');
const h2 = h2List[6];
// The anchor element should be to only child
expect(h2.children.length).toBe(1);
expect(h2.firstElementChild?.tagName).toBe('A');
expect(h2.firstElementChild!.innerHTML).toBe('Query for the <code><h1></code>');
});
});
| {
"end_byte": 3372,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/heading/heading.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/image/image.md_0_105 | 
 | {
"end_byte": 105,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/image/image.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/image/image.spec.ts_0_898 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(runfiles.resolvePackageRelative('image/image.md'), {
encoding: 'utf-8',
});
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('should wrap images in custom classes', () => {
const image = markdownDocument.querySelector('img');
expect(image?.classList.contains('docs-image')).toBeTrue();
});
it('should handle images hosted internal to the application', () => {
const image = markdownDocument.querySelector('img[title="Local Image"]');
expect(image?.getAttribute('src')).toBe('unknown/some-image.png');
});
});
| {
"end_byte": 898,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/image/image.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/docs-decorative-header.md_0_179 | <docs-decorative-header title="Custom Title" imgSrc="adev/shared-docs/pipeline/guides/testing/docs-decorative-header/decoration.svg">
This is header text
</docs-decorative-header> | {
"end_byte": 179,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/docs-decorative-header.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/decoration.svg_0_3985 | <svg
width="284"
height="203"
viewBox="0 0 284 203"
fill="none"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<path
d="M278.586 54.3613H199.578C196.588 54.3613 194.164 56.7851 194.164 59.7749V114.527C194.164 117.517 196.588 119.941 199.578 119.941H278.586C281.576 119.941 284 117.517 284 114.527V59.7749C284 56.7851 281.576 54.3613 278.586 54.3613Z"
fill="var(--senary-contrast)"
/>
<path
d="M68.481 157.675C103.787 157.675 132.408 129.054 132.408 93.7484C132.408 58.4426 103.787 29.8215 68.481 29.8215C33.1751 29.8215 4.55408 58.4426 4.55408 93.7484C4.55408 129.054 33.1751 157.675 68.481 157.675Z"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M68.481 157.675C90.5812 157.675 108.497 129.054 108.497 93.7484C108.497 58.4426 90.5812 29.8215 68.481 29.8215C46.3808 29.8215 28.465 58.4426 28.465 93.7484C28.465 129.054 46.3808 157.675 68.481 157.675Z"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M116.956 52.08C105.254 58.924 88.2362 63.2277 69.2949 63.2277C50.3536 63.2277 32.2878 58.6527 20.5605 51.4387"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M21.288 136.428C33.003 129.473 50.1686 125.083 69.2949 125.083C88.4211 125.083 104.797 129.276 116.488 135.947"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M4.96106 93.7483H132.075"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M69.2949 157.503V30.0803"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M32.3618 42.5598C32.3618 33.3975 24.6546 26.0232 15.3566 26.6028C7.37802 27.096 0.891605 33.5948 0.398342 41.5733C0.287358 43.4354 0.497003 45.2481 0.965603 46.9376C1.31089 48.146 1.79181 49.2806 2.38373 50.3534L2.45772 50.489C2.45772 50.489 2.45772 50.5137 2.47005 50.5137L14.6413 72.5256C15.3935 73.8821 17.3296 73.8821 18.0818 72.5256L30.3394 50.3534C31.6219 48.0474 32.3618 45.3961 32.3618 42.5722V42.5598ZM16.3677 48.7873C13.2848 48.7873 10.7939 46.2963 10.7939 43.2134C10.7939 40.1305 13.2848 37.6395 16.3677 37.6395C19.4506 37.6395 21.9416 40.1305 21.9416 43.2134C21.9416 46.2963 19.4506 48.7873 16.3677 48.7873Z"
fill="#F637E3"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M174.311 179.256H144.542V198.629H174.311V179.256Z"
fill="#EFEFF1"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M192.598 197.136H126.242V201.983H192.598V197.136Z"
fill="#EFEFF1"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M234.735 81.281H84.1175C80.8893 81.281 78.2723 83.898 78.2723 87.1262V175.371C78.2723 178.599 80.8893 181.216 84.1175 181.216H234.735C237.964 181.216 240.581 178.599 240.581 175.371V87.1262C240.581 83.898 237.964 81.281 234.735 81.281Z"
fill="#EFEFF1"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M228.767 87.4963H90.0859C87.3481 87.4963 85.1286 89.7158 85.1286 92.4536V170.044C85.1286 172.782 87.3481 175.001 90.0859 175.001H228.767C231.505 175.001 233.724 172.782 233.724 170.044V92.4536C233.724 89.7158 231.505 87.4963 228.767 87.4963Z"
fill="white"
/>
<path
d="M228.767 87.8046C231.332 87.8046 233.416 89.8886 233.416 92.4536V170.044C233.416 172.609 231.332 174.693 228.767 174.693H90.0859C87.5209 174.693 85.4369 172.609 85.4369 170.044V92.4536C85.4369 89.8886 87.5209 87.8046 90.0859 87.8046H228.767ZM228.767 87.188H90.0859C87.1756 87.188 84.8203 89.5433 84.8203 92.4536V170.044C84.8203 172.954 87.1756 175.309 90.0859 175.309H228.767C231.677 175.309 234.032 172.954 234.032 170.044V92.4536C234.032 89.5433 231.677 87.188 228.767 87.188Z"
fill="black"
/>
<path | {
"end_byte": 3985,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/decoration.svg"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/decoration.svg_3986_8599 | d="M85.1533 95.4748V90.6408C85.1533 88.7418 86.6947 87.188 88.6061 87.188H230.826C232.701 87.188 234.242 88.6924 234.279 90.5668L234.378 95.4748H85.1656H85.1533Z"
fill="white"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M91.2698 92.8236C92.0939 92.8236 92.7619 92.1556 92.7619 91.3315C92.7619 90.5074 92.0939 89.8394 91.2698 89.8394C90.4457 89.8394 89.7776 90.5074 89.7776 91.3315C89.7776 92.1556 90.4457 92.8236 91.2698 92.8236Z"
fill="white"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M96.9422 92.8236C97.7663 92.8236 98.4344 92.1556 98.4344 91.3315C98.4344 90.5074 97.7663 89.8394 96.9422 89.8394C96.1182 89.8394 95.4501 90.5074 95.4501 91.3315C95.4501 92.1556 96.1182 92.8236 96.9422 92.8236Z"
fill="white"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M102.615 92.8236C103.439 92.8236 104.107 92.1556 104.107 91.3315C104.107 90.5074 103.439 89.8394 102.615 89.8394C101.791 89.8394 101.123 90.5074 101.123 91.3315C101.123 92.1556 101.791 92.8236 102.615 92.8236Z"
fill="white"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M222.009 105.821H175.223C173.909 105.821 172.843 106.887 172.843 108.201V128.856C172.843 130.171 173.909 131.236 175.223 131.236H222.009C223.324 131.236 224.389 130.171 224.389 128.856V108.201C224.389 106.887 223.324 105.821 222.009 105.821Z"
fill="#8514F5"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M246.574 22.0156H237.473V31.1163H246.574V22.0156Z"
fill="var(--page-background)"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M257.265 1.13818H252.431V5.97216H257.265V1.13818Z"
fill="var(--page-background)"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M270.892 112.233L262.321 89.6543L253.763 112.233"
fill="var(--senary-contrast)"
/>
<path
d="M224.327 70.1951C224.327 70.1951 221.516 81.5525 207.199 86.9044Z"
fill="var(--senary-contrast)"
/>
<path
d="M207.199 70.1951C207.199 70.1951 210.01 81.5525 224.327 86.9044Z"
fill="var(--senary-contrast)"
/>
<path
d="M215.757 95.7954V98.9523C215.757 103.774 219.666 107.671 224.475 107.671H238.435"
fill="var(--senary-contrast)"
/>
<path
d="M262.321 82.0704V78.9135C262.321 74.0918 258.412 70.1951 253.603 70.1951H239.643"
fill="var(--senary-contrast)"
/>
<path
d="M27.8361 155.073H23.0021V159.907H27.8361V155.073Z"
fill="var(--page-background)"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M105.032 17.3665H100.198V22.2004H105.032V17.3665Z"
fill="var(--page-background)"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M14.1481 181.216H4.96106V190.403H14.1481V181.216Z"
fill="var(--page-background)"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M273.531 49.3054H194.522C191.532 49.3054 189.109 51.7292 189.109 54.719V109.471C189.109 112.461 191.532 114.885 194.522 114.885H273.531C276.52 114.885 278.944 112.461 278.944 109.471V54.719C278.944 51.7292 276.52 49.3054 273.531 49.3054Z"
fill="#F11653"
stroke="black"
stroke-miterlimit="10"
/>
<path
d="M265.836 107.178L257.277 84.5984L248.707 107.178"
stroke="black"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M251.901 99.4331H262.383"
stroke="black"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M197.383 65.1392H224.032"
stroke="black"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M210.713 58.5293V65.139"
stroke="black"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M219.272 65.1392C219.272 65.1392 216.46 76.4965 202.143 81.8485"
stroke="black"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M202.143 65.1392C202.143 65.1392 204.955 76.4965 219.272 81.8485"
stroke="black"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M210.713 90.7395V93.8964C210.713 98.718 214.623 102.615 219.432 102.615H233.391"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
stroke-linecap="round"
/>
<path | {
"end_byte": 8599,
"start_byte": 3986,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/decoration.svg"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/decoration.svg_8600_12988 | d="M232.75 104.761L236.486 102.615L232.75 100.457V104.761Z"
fill="black"
/>
<path
d="M257.277 77.0145V73.8576C257.277 69.0359 253.368 65.1392 248.559 65.1392H234.6"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
stroke-linecap="round"
/>
<path
d="M235.229 62.9934L231.504 65.1391L235.229 67.2971V62.9934Z"
fill="black"
/>
<path
d="M154.901 6.10782C154.901 6.10782 161.646 -1.05682 170.426 9.573C170.932 10.1896 170.291 11.0775 169.551 10.7938C166.221 9.51134 160.758 8.06855 159.032 11.5461"
fill="#F11653"
/>
<path
d="M154.901 6.10782C154.901 6.10782 161.646 -1.05682 170.426 9.573C170.932 10.1896 170.291 11.0775 169.551 10.7938C166.221 9.51134 160.758 8.06855 159.032 11.5461"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M153.796 4.62465L141.696 13.8323L149.141 23.6162L161.241 14.4086L153.796 4.62465Z"
fill="#F11653"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M137.721 16.8531L132.834 20.572L140.279 30.3559L145.166 26.637L137.721 16.8531Z"
fill="#F11653"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M147.773 21.8305C143.802 20.992 143.815 24.8394 143.815 24.8394L138.857 18.316C138.857 18.316 142.557 19.3642 142.816 15.3071L147.773 21.8305Z"
fill="#F11653"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M158.669 16.3557L151.986 21.4412L173.037 49.105L179.72 44.0195L158.669 16.3557Z"
fill="white"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M164.539 37.7437L171.133 32.7254L182.267 47.3571C183.649 49.1726 183.295 51.782 181.479 53.1635C179.664 54.545 177.054 54.1908 175.673 52.3754L164.539 37.7437Z"
fill="white"
stroke="var(--primary-contrast)"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<g style="mix-blend-mode: multiply;">
<path
d="M171.129 32.7317L164.593 37.7753L167.109 41.0802L173.521 35.8762L171.129 32.7317Z"
fill="var(--senary-contrast)"
/>
</g>
<g style="mix-blend-mode: multiply;">
<path
d="M158.785 16.4541L152.04 21.3251L153.828 23.3105L160.475 18.3038L158.785 16.4541Z"
fill="var(--senary-contrast)"
/>
</g>
<path
d="M157.305 45.1127L183.165 24.6176C186.235 26.2083 190.095 25.9617 192.981 23.668C195.583 21.6087 196.742 18.4148 196.335 15.3565L190.218 20.2029L184.447 12.9149L190.564 8.06859C187.678 6.97107 184.299 7.37802 181.697 9.43739C178.812 11.7311 177.689 15.4305 178.54 18.7847L152.681 39.2798C149.61 37.689 145.751 37.9357 142.865 40.2293C140.263 42.2887 139.104 45.4826 139.511 48.5408L145.627 43.6945L151.398 50.9825L145.282 55.8288C148.168 56.9263 151.546 56.5194 154.148 54.46C157.034 52.1663 158.156 48.4668 157.305 45.1127Z"
fill="#5C44E4"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M100.617 159.981H139.844"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M100.617 153.84H151.288"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M172.991 159.981H212.218"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M172.991 153.84H223.649"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M172.991 147.292H223.649"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<path
d="M172.991 140.756H223.649"
stroke="black"
stroke-width="0.5"
stroke-miterlimit="10"
/>
<mask
id="mask0_33_2012"
style="mask-type: luminance;"
maskUnits="userSpaceOnUse"
x="100"
y="106"
width="32"
height="34"
>
<path
d="M131.791 111.839L130.657 129.683L119.793 106.302L131.791 111.851V111.839ZM122.592 130.866H109.52L107.843 134.911L116.056 139.585L124.269 134.911L122.592 130.866ZM111.752 125.613H120.348L116.044 115.156L111.74 125.613H111.752ZM112.32 106.29C107.979 108.3 100.321 111.839 100.321 111.839L101.456 129.683L112.32 106.302V106.29Z"
fill="white"
/>
</mask>
<g mask="url(#mask0_33_2012)">
<mask
id="mask1_33_2012"
style="mask-type: luminance;"
maskUnits="userSpaceOnUse"
x="95"
y="102"
width="41"
height="41"
>
<path | {
"end_byte": 12988,
"start_byte": 8600,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/decoration.svg"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/decoration.svg_12989_14587 | d="M115.501 142.187C126.453 142.187 135.33 133.309 135.33 122.358C135.33 111.406 126.453 102.528 115.501 102.528C104.55 102.528 95.6721 111.406 95.6721 122.358C95.6721 133.309 104.55 142.187 115.501 142.187Z"
fill="white"
/>
</mask>
<g mask="url(#mask1_33_2012)">
<mask
id="mask2_33_2012"
style="mask-type: luminance;"
maskUnits="userSpaceOnUse"
x="89"
y="96"
width="53"
height="53"
>
<path
d="M141.484 96.3625H89.5063V148.365H141.484V96.3625Z"
fill="white"
/>
</mask>
<g mask="url(#mask2_33_2012)">
<mask
id="mask3_33_2012"
style="mask-type: luminance;"
maskUnits="userSpaceOnUse"
x="89"
y="96"
width="53"
height="53"
>
<path
d="M141.484 96.3625H89.5063V148.365H141.484V96.3625Z"
fill="white"
/>
</mask>
<g mask="url(#mask3_33_2012)">
<rect
x="89.3461"
y="95.9556"
width="52.6805"
height="52.6805"
fill="url(#pattern0)"
/>
</g>
</g>
</g>
</g>
<defs>
<pattern
id="pattern0"
patternContentUnits="objectBoundingBox"
width="1"
height="1"
>
<use
xlink:href="#image0_33_2012"
transform="scale(0.0113636 0.0114943)"
/>
</pattern>
<image
id="image0_33_2012"
width="88"
height="87"
xlink:href=""
/>
</defs>
</svg>
| {
"end_byte": 14587,
"start_byte": 12989,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/decoration.svg"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/docs-decorative-header.spec.ts_0_941 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-decorative-header/docs-decorative-header.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('sets the custom title in the header', () => {
expect(markdownDocument.querySelector('h1')?.textContent).toBe('Custom Title');
});
it('includes provided svgs', () => {
expect(markdownDocument.querySelector('svg')).toBeTruthy();
});
it('passes the header text to the content', () => {
expect(markdownDocument.querySelector('p')?.textContent?.trim()).toBe('This is header text');
});
});
| {
"end_byte": 941,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-decorative-header/docs-decorative-header.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-card/angular.svg_0_1261 | <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 223 236"><g clip-path="url(#a)"><path fill="url(#b)" d="m222.077 39.192-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z"/><path fill="url(#c)" d="m222.077 39.192-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z"/></g><defs><linearGradient id="b" x1="49.009" x2="225.829" y1="213.75" y2="129.722" gradientUnits="userSpaceOnUse"><stop stop-color="#E40035"/><stop offset=".24" stop-color="#F60A48"/><stop offset=".352" stop-color="#F20755"/><stop offset=".494" stop-color="#DC087D"/><stop offset=".745" stop-color="#9717E7"/><stop offset="1" stop-color="#6C00F5"/></linearGradient><linearGradient id="c" x1="41.025" x2="156.741" y1="28.344" y2="160.344" gradientUnits="userSpaceOnUse"><stop stop-color="#FF31D9"/><stop offset="1" stop-color="#FF5BE1" stop-opacity="0"/></linearGradient><clipPath id="a"><path fill="#fff" d="M0 0h223v236H0z"/></clipPath></defs></svg> | {
"end_byte": 1261,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-card/angular.svg"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-card/docs-card.md_0_266 | <docs-card title="No Link Card">Card Content</docs-card>
<docs-card title="Link Card" link="Try It Now" href="in/app/link">
Card Content
</docs-card>
<docs-card title="Image Card" imgSrc="adev/shared-docs/pipeline/guides/testing/docs-card/angular.svg"></docs-card> | {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-card/docs-card.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-card/docs-card.spec.ts_0_1309 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-card/docs-card.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('creates cards with no links', () => {
const cardEl = markdownDocument.querySelectorAll('.docs-card')[0];
expect(cardEl.querySelector('h3')?.textContent?.trim()).toBe('No Link Card');
expect(cardEl.tagName).not.toBe('A');
});
it('creates cards withs links', () => {
const cardEl = markdownDocument.querySelectorAll('.docs-card')[1];
expect(cardEl.querySelector('h3')?.textContent?.trim()).toBe('Link Card');
expect(cardEl.tagName).toBe('A');
expect(cardEl.getAttribute('href')).toBe('in/app/link');
});
it('creates cards with svg images', () => {
const cardEl = markdownDocument.querySelectorAll('.docs-card')[2];
expect(cardEl.querySelector('h3')?.textContent?.trim()).toBe('Image Card');
expect(cardEl.querySelector('svg')).toBeTruthy();
});
});
| {
"end_byte": 1309,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-card/docs-card.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-alert/docs-alert.spec.ts_0_1286 | import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
import {AlertSeverityLevel} from '../../../guides/extensions/docs-alert';
import {parseMarkdown} from '../../../guides/parse';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-alert/docs-alert.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
for (let level in AlertSeverityLevel) {
it(`should create a docs-alert for ${level}:`, () => {
const noteEl = markdownDocument.querySelector(`.docs-alert-${level.toLowerCase()}`);
// TLDR is written without a semi colon in the markdown, but is rendered
// with a colon, as such we have to adjust our expectation here.
if (level === AlertSeverityLevel.TLDR) {
level = 'TL;DR';
}
expect(noteEl?.textContent?.trim()).toMatch(`^${level}:`);
});
}
it(`should handle multi-line alerts`, () => {
const noteEl = markdownDocument.querySelector(`.docs-alert-note`);
expect(noteEl?.textContent?.trim()).toContain(`This is a multiline note`);
});
});
| {
"end_byte": 1286,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-alert/docs-alert.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-alert/docs-alert.md_0_1239 | Note: Use Note for ancillary/additional information that's not _essential_ to the main text.
This is a multiline note
Tip: Use Tip to call out a specific task/action users can perform, or a fact that plays directly into a task/action.
TODO: Use TODO for incomplete documentation that you plan to expand soon. You can also assign the TODO, e.g. TODO(emmatwersky): Text.
QUESTION: Use Question to pose a question to the reader, kind of like a mini-quiz that they should be able to answer.
Summary: Use Summary to provide a two- or three-sentence synopsis of the page or section content, so readers can figure out whether this is the right place for them.
TLDR: Use TLDR if you can provide the essential information about a page or section in a sentence or two.
CRITICAL: Use Critical to call out potential bad stuff or alert the reader they ought to be careful before doing something. For example, Warning: Running `rm` with the `-f` option will delete write-protected files or directories without prompting you.
IMPORTANT: Use Important for information that's crucial to comprehending the text or to completing some task.
HELPFUL: Use Best practice to call out practices that are known to be successful or better than alternatives.
| {
"end_byte": 1239,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-alert/docs-alert.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/link/link.spec.ts_0_912 | import {readFile} from 'fs/promises';
import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
describe('markdown to html', () => {
let parsedMarkdown: string;
beforeAll(async () => {
const markdownContent = await readFile(runfiles.resolvePackageRelative('link/link.md'), {
encoding: 'utf-8',
});
parsedMarkdown = await parseMarkdown(markdownContent, {});
});
it('should render external links with _blank target', () => {
expect(parsedMarkdown).toContain(
'<a href="https://angular.dev" target="_blank">Angular Site</a>',
);
});
it('should render links to anchors on the same page', () => {
expect(parsedMarkdown).toContain('<a href="#test">same page</a>');
});
it('should render internal links that are relative paths', () => {
expect(parsedMarkdown).toContain('<a href="../other/page">same site</a>');
});
});
| {
"end_byte": 912,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/link/link.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/link/link.md_0_81 | [Angular Site](https://angular.dev)
[same page](#test)
[same site](../other/page) | {
"end_byte": 81,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/link/link.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/table/table.spec.ts_0_971 | import {readFile} from 'fs/promises';
import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
describe('markdown to html', () => {
let parsedMarkdown: string;
beforeAll(async () => {
const markdownContent = await readFile(runfiles.resolvePackageRelative('table/table.md'), {
encoding: 'utf-8',
});
parsedMarkdown = await parseMarkdown(markdownContent, {});
});
it('should wrap the table in custom div', () => {
expect(parsedMarkdown).toContain('<div class="docs-table docs-scroll-track-transparent">');
});
it('should place the initial row as table header cells', () => {
expect(parsedMarkdown).toContain('<th>Sports</th>');
expect(parsedMarkdown).toContain('<th>Season</th>');
});
it('should place the subsequent rows as regular table cells', () => {
expect(parsedMarkdown).toContain('<td>Baseball</td>');
expect(parsedMarkdown).toContain('<td>Year Round</td>');
});
});
| {
"end_byte": 971,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/table/table.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/table/table.md_0_137 | | Sports | Season |
| ---------------- | ------ |
| Skiing | Winter |
| Baseball | Summer |
| Running | Year Round | | {
"end_byte": 137,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/table/table.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-card-container/angular.svg_0_1261 | <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 223 236"><g clip-path="url(#a)"><path fill="url(#b)" d="m222.077 39.192-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z"/><path fill="url(#c)" d="m222.077 39.192-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z"/></g><defs><linearGradient id="b" x1="49.009" x2="225.829" y1="213.75" y2="129.722" gradientUnits="userSpaceOnUse"><stop stop-color="#E40035"/><stop offset=".24" stop-color="#F60A48"/><stop offset=".352" stop-color="#F20755"/><stop offset=".494" stop-color="#DC087D"/><stop offset=".745" stop-color="#9717E7"/><stop offset="1" stop-color="#6C00F5"/></linearGradient><linearGradient id="c" x1="41.025" x2="156.741" y1="28.344" y2="160.344" gradientUnits="userSpaceOnUse"><stop stop-color="#FF31D9"/><stop offset="1" stop-color="#FF5BE1" stop-opacity="0"/></linearGradient><clipPath id="a"><path fill="#fff" d="M0 0h223v236H0z"/></clipPath></defs></svg> | {
"end_byte": 1261,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-card-container/angular.svg"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-card-container/docs-card-container.md_0_98 | <docs-card-container>
<docs-card ></docs-card>
<docs-card ></docs-card>
</docs-card-container> | {
"end_byte": 98,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-card-container/docs-card-container.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-card-container/docs-card-container.spec.ts_0_796 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-card-container/docs-card-container.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('creates card containers containing multiple cards', () => {
const containerEl = markdownDocument.querySelector('.docs-card-grid');
expect(containerEl!.children.length).toBe(2);
expect(containerEl!.classList.contains('docs-card-grid')).toBeTrue();
});
});
| {
"end_byte": 796,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-card-container/docs-card-container.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/list/list.md_0_173 | # Ordered List
1. First Item
2. Another Item
3. Last in order
# Unordered List
- Order
- here
- matter
- doesn't
- [some link](https://angular.dev)
- Code block `SomeClass` | {
"end_byte": 173,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/list/list.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/list/list.spec.ts_0_1370 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(runfiles.resolvePackageRelative('list/list.md'), {
encoding: 'utf-8',
});
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('should wrap lists in custom classes', () => {
const orderedList = markdownDocument.querySelector('ol');
expect(orderedList?.className).toBe('docs-ordered-list');
expect(orderedList?.childElementCount).toBe(3);
expect(orderedList?.textContent).toContain('First Item');
const unorderedList = markdownDocument.querySelector('ul');
expect(unorderedList?.className).toBe('docs-list');
expect(unorderedList?.childElementCount).toBe(6);
expect(unorderedList?.textContent).toContain('matter');
});
it('should render list items', () => {
const unorderedList = markdownDocument.querySelector('ul');
const linkItem = unorderedList!.children[4];
expect(linkItem.outerHTML).toContain('href="https://angular.dev"');
const codeItem = unorderedList!.children[5];
expect(codeItem.outerHTML).toContain('<code>SomeClass</code>');
});
});
| {
"end_byte": 1370,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/list/list.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code-block/docs-code-block.md_0_38 | ```typescript
this is a code block
``` | {
"end_byte": 38,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code-block/docs-code-block.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code-block/docs-code-block.spec.ts_0_855 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
import {initHighlighter} from '../../extensions/docs-code/format/highlight';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
await initHighlighter();
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-code-block/docs-code-block.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('converts triple ticks into a code block', () => {
const codeBlock = markdownDocument.querySelector('code');
expect(codeBlock).toBeTruthy();
expect(codeBlock?.textContent?.trim()).toBe('this is a code block');
});
});
| {
"end_byte": 855,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code-block/docs-code-block.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/mermaid/mermaid.spec.ts_0_1128 | import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
import {marked} from 'marked';
import {docsCodeBlockExtension} from '../../extensions/docs-code/docs-code-block';
import {walkTokens} from '../../walk-tokens';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
// Extend the timeout interval tyo 15 seconds because we were seeing issues with not being able to run marked
// within the default timeframe.
jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000;
const markdownContent = await readFile(runfiles.resolvePackageRelative('./mermaid.md'), {
encoding: 'utf-8',
});
marked.use({
async: true,
extensions: [docsCodeBlockExtension],
walkTokens,
});
markdownDocument = JSDOM.fragment(await marked.parse(markdownContent));
});
it('should create an svg for each mermaid code block', () => {
const svgs = markdownDocument.querySelectorAll('svg');
expect(svgs.length).toBe(2);
});
afterAll(() => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
});
});
| {
"end_byte": 1128,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/mermaid/mermaid.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/mermaid/bootstrap.init.ts_0_92 | // Set HANDLE_MERMAID to true to test mermaid usage.
(global as any).HANDLE_MERMAID = true;
| {
"end_byte": 92,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/mermaid/bootstrap.init.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/mermaid/BUILD.bazel_0_1140 | load("//tools:defaults.bzl", "esbuild_jasmine_node_test", "ts_library")
ts_library(
name = "unit_test_lib",
testonly = True,
srcs = glob([
"*.spec.ts",
]),
deps = [
"//adev/shared-docs/pipeline/guides",
"@npm//@bazel/runfiles",
"@npm//@types/jsdom",
"@npm//jsdom",
"@npm//marked",
],
)
ts_library(
name = "bootstrap",
testonly = True,
srcs = [
"bootstrap.init.ts",
],
)
esbuild_jasmine_node_test(
name = "unit_tests",
bootstrap = [
":bootstrap",
],
data = [
"@npm//@angular/build-tooling/bazel/browsers/chromium:chromium-for-generation",
"@npm//jsdom",
"@npm//mermaid",
"@npm//playwright-core",
] + glob([
"**/*.md",
"**/*.svg",
"**/*.ts",
]),
env = {
"CHROME_BIN": "$(CHROMIUM)",
},
external = [
"playwright-core",
"jsdom",
],
tags = [
"no-remote-exec",
],
toolchains = [
"@npm//@angular/build-tooling/bazel/browsers/chromium:toolchain_alias",
],
deps = [":unit_test_lib"],
)
| {
"end_byte": 1140,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/mermaid/BUILD.bazel"
} |
angular/adev/shared-docs/pipeline/guides/testing/mermaid/mermaid.md_0_190 | ```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
```mermaid
pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 15
``` | {
"end_byte": 190,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/mermaid/mermaid.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-video/docs-video.spec.ts_0_985 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-video/docs-video.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('should create an iframe in a container', () => {
const videoContainerEl = markdownDocument.querySelector('.docs-video-container')!;
const iframeEl = videoContainerEl.children[0];
expect(videoContainerEl.children.length).toBe(1);
expect(iframeEl.nodeName).toBe('IFRAME');
expect(iframeEl.getAttribute('src')).toBeTruthy();
expect(iframeEl.classList.contains('docs-video')).toBeTrue();
expect(iframeEl.getAttribute('title')).toBeTruthy();
});
});
| {
"end_byte": 985,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-video/docs-video.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-video/docs-video.md_0_123 | This is a video:
<docs-video src="https://www.youtube.com/embed/O47uUnJjbJc" alt="Expression Changed After Checked Video"/> | {
"end_byte": 123,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-video/docs-video.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/text/text.md_0_149 | This is a string that contains an emoji, 😎. See there it was;
# This header causes there to be two text areas
This is a string without an emoji. | {
"end_byte": 149,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/text/text.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/text/text.spec.ts_0_929 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(runfiles.resolvePackageRelative('text/text.md'), {
encoding: 'utf-8',
});
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('should wrap emoji in custom classes', () => {
const emoji = markdownDocument.querySelector('span.docs-emoji');
expect(emoji).toBeTruthy();
expect(emoji?.textContent).toContain('😎');
});
it('should not apply a custom class if no emoji is present', () => {
const [, noemoji] = markdownDocument.querySelectorAll('p');
expect(noemoji).toBeTruthy();
expect(noemoji?.textContent).not.toContain('😎');
});
});
| {
"end_byte": 929,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/text/text.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-pill/docs-pill.spec.ts_0_1309 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-pill/docs-pill.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('should render links to anchors on the same page', () => {
const samePageEl = markdownDocument.querySelectorAll('a.docs-pill')[0];
expect(samePageEl.textContent?.trim()).toBe('Same Page');
});
it('should render external links with _blank target and iconography', () => {
const samePageEl = markdownDocument.querySelectorAll('a.docs-pill')[1];
expect(samePageEl.getAttribute('target')).toBe('_blank');
expect(samePageEl.textContent?.trim()).toContain('External Page');
expect(samePageEl.querySelector('docs-icon')?.textContent).toBe('open_in_new');
});
it('should render internal links that are relative paths', () => {
const samePageEl = markdownDocument.querySelectorAll('a.docs-pill')[2];
expect(samePageEl.textContent?.trim()).toBe('Another Page');
});
});
| {
"end_byte": 1309,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-pill/docs-pill.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-pill/docs-pill.md_0_197 | Text to force this as inline.
<docs-pill href="#pill-row" title="Same Page"/>
<docs-pill href="http://angular.dev" title="External Page"/>
<docs-pill href="./this-other-page" title="Another Page"/> | {
"end_byte": 197,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-pill/docs-pill.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code/example-with-eslint-comment.ts_0_41 | // eslint-disable-next-line
const x = 1;
| {
"end_byte": 41,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code/example-with-eslint-comment.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code/example-with-region.ts_0_82 | // #docregion something
const x = 'within the region';
// #enddocregion something
| {
"end_byte": 82,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code/example-with-region.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code/messages.fr.xlf.html_0_4552 | <!-- The `messages.fr.xlf` after translation for documentation purposes -->
<!-- #docregion -->
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="ng2.template">
<body>
<!-- #docregion translated-hello-before -->
<trans-unit id="introductionHeader" datatype="html">
<source>Hello i18n!</source>
<note priority="1" from="description">An introduction header for this sample</note>
<note priority="1" from="meaning">User welcome</note>
</trans-unit>
<!-- #enddocregion translated-hello-before -->
<!-- #docregion translated-hello -->
<!-- #docregion custom-id -->
<trans-unit id="introductionHeader" datatype="html">
<!-- #enddocregion custom-id -->
<source>Hello i18n!</source>
<target>Bonjour i18n !</target>
<note priority="1" from="description">An introduction header for this sample</note>
<note priority="1" from="meaning">User welcome</note>
</trans-unit>
<!-- #enddocregion translated-hello -->
<!-- #docregion translated-other-nodes -->
<!-- #docregion generated-id -->
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
<!-- #enddocregion generated-id -->
<source>I don't output any element</source>
<target>Je n'affiche aucun élément</target>
</trans-unit>
<trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
<source>Angular logo</source>
<target>Logo d'Angular</target>
</trans-unit>
<!-- #enddocregion translated-other-nodes -->
<!-- #docregion translated-plural -->
<trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
<source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
<target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
</trans-unit>
<!-- #enddocregion translated-plural -->
<!-- #docregion translated-select -->
<!-- #docregion translate-select-1 -->
<trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
<source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
<target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
</trans-unit>
<!-- #enddocregion translate-select-1 -->
<!-- #docregion translate-select-2 -->
<trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
<source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
<target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
</trans-unit>
<!-- #enddocregion translate-select-2 -->
<!-- #enddocregion translated-select -->
<!-- #docregion translate-nested -->
<!-- #docregion translate-nested-1 -->
<trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
<source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
<target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
</trans-unit>
<!-- #enddocregion translate-nested-1 -->
<!-- #docregion translate-nested-2 -->
<trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
<source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
<target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
</trans-unit>
<!-- #enddocregion translate-nested-2 -->
<!-- #enddocregion translate-nested -->
<!-- #docregion i18n-duplicate-custom-id -->
<trans-unit id="myId" datatype="html">
<source>Hello</source>
<target state="new">Bonjour</target>
</trans-unit>
<!-- #enddocregion i18n-duplicate-custom-id -->
</body>
</file>
</xliff> | {
"end_byte": 4552,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code/messages.fr.xlf.html"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code/docs-code.md_0_550 | <docs-code >
this is code
</docs-code>
<docs-code path="adev/shared-docs/pipeline/guides/testing/docs-code/example-with-eslint-comment.ts" />
<docs-code path="adev/shared-docs/pipeline/guides/testing/docs-code/example-with-region.ts" />
<docs-code path="adev/shared-docs/pipeline/guides/testing/docs-code/new-code.ts"
diff="adev/shared-docs/pipeline/guides/testing/docs-code/old-code.ts" />
<docs-code header="src/locale/messages.fr.xlf (<trans-unit>)" path="adev/shared-docs/pipeline/guides/testing/docs-code/messages.fr.xlf.html" />
| {
"end_byte": 550,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code/docs-code.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code/new-code.ts_0_89 | function newName(param: boolean) {
if (param) {
return false;
}
return true;
}
| {
"end_byte": 89,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code/new-code.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code/docs-code.spec.ts_0_2364 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
import {initHighlighter} from '../../extensions/docs-code/format/highlight';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
await initHighlighter();
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-code/docs-code.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('converts docs-code elements into a code block', () => {
const codeBlock = markdownDocument.querySelectorAll('code')[0];
expect(codeBlock).toBeTruthy();
expect(codeBlock?.textContent?.trim()).toBe('this is code');
});
it('removes eslint comments from the code', () => {
const codeBlock = markdownDocument.querySelectorAll('code')[1];
expect(codeBlock).toBeTruthy();
expect(codeBlock?.textContent?.trim()).not.toContain('// eslint');
});
it('extract regions from the code', () => {
// This unit test is sensible to additional node, like text nodes between the lines.
// The specific index here makes sure there is no space/linebreak between the code lines
const codeBlock = markdownDocument.querySelectorAll('code')[2];
expect(codeBlock).toBeTruthy();
expect(codeBlock?.textContent?.trim()).toContain(`const x = 'within the region';`);
expect(codeBlock?.textContent?.trim()).not.toContain('docregion');
});
it('properly shows the diff of two provided file paths', () => {
const codeBlock = markdownDocument.querySelectorAll('code')[3];
expect(codeBlock).toBeTruthy();
const codeLines = codeBlock.querySelectorAll('.line');
expect(codeLines[0].textContent).toContain('oldFuncName');
expect(codeLines[0].classList.contains('remove')).toBeTrue();
expect(codeLines[1].textContent).toContain('newName');
expect(codeLines[1].classList.contains('add')).toBeTrue();
expect(codeLines[2].classList.contains('add')).toBeFalse();
expect(codeLines[2].classList.contains('remove')).toBeFalse();
});
it('should load header and html code', () => {
const codeBlock = markdownDocument.querySelectorAll('code')[4];
expect(codeBlock).toBeTruthy();
});
});
| {
"end_byte": 2364,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code/docs-code.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code/old-code.ts_0_95 | function oldFuncName(param: boolean) {
if (param) {
return false;
}
return 'yay!';
}
| {
"end_byte": 95,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code/old-code.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-step/docs-step.md_0_132 | <docs-step title="Step 1">
Do the first thing.
</docs-step>
<docs-step title="Step B">
Do another thing after that.
</docs-step> | {
"end_byte": 132,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-step/docs-step.md"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-step/docs-step.spec.ts_0_2164 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-step/docs-step.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('should create a list item for each step', () => {
const stepEls = markdownDocument.querySelectorAll('li')!;
expect(stepEls.length).toBe(2);
});
it('should render each step with the provided information', () => {
const [firstStepEl, secondStepEl] = markdownDocument.querySelectorAll('li');
const firstStepAEl = firstStepEl.querySelector('a')!;
const firstStepTextContentEl = firstStepEl.querySelector('p')!;
const firstStepHeadingEl = firstStepEl.querySelector('h3')!;
expect(firstStepHeadingEl.textContent?.trim()).toBe('Step 1');
expect(firstStepTextContentEl.textContent).toContain('first thing');
expect(firstStepAEl.getAttribute('href')).toBe(`#${firstStepHeadingEl.getAttribute('id')}`);
expect(firstStepAEl.getAttribute('tabindex')).toBe('-1');
expect(secondStepEl.querySelector('h3')?.textContent?.trim()).toBe('Step B');
expect(secondStepEl.querySelector('p')?.textContent).toContain('another thing');
});
it('should create a self referencial anchor for the step', () => {
const firstStepEl = markdownDocument.querySelector('li')!;
const firstStepAEl = firstStepEl.querySelector('a')!;
const firstStepHeadingEl = firstStepEl.querySelector('h3')!;
expect(firstStepAEl.getAttribute('href')).toBe(`#${firstStepHeadingEl.getAttribute('id')}`);
expect(firstStepAEl.getAttribute('tabindex')).toBe('-1');
});
it('should create a a link that is not reachable via tab', () => {
const firstStepEl = markdownDocument.querySelector('li')!;
const firstStepAEl = firstStepEl.querySelector('a')!;
expect(firstStepAEl.getAttribute('tabindex')).toBe('-1');
});
});
| {
"end_byte": 2164,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-step/docs-step.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code-multifile/docs-code-multifile.spec.ts_0_1135 | import {parseMarkdown} from '../../../guides/parse';
import {runfiles} from '@bazel/runfiles';
import {readFile} from 'fs/promises';
import {JSDOM} from 'jsdom';
import {initHighlighter} from '../../extensions/docs-code/format/highlight';
describe('markdown to html', () => {
let markdownDocument: DocumentFragment;
beforeAll(async () => {
await initHighlighter();
const markdownContent = await readFile(
runfiles.resolvePackageRelative('docs-code-multifile/docs-code-multifile.md'),
{encoding: 'utf-8'},
);
markdownDocument = JSDOM.fragment(await parseMarkdown(markdownContent, {}));
});
it('converts triple ticks into a code block', () => {
const multiFileEl = markdownDocument.querySelector('.docs-code-multifile');
expect(multiFileEl).toBeTruthy();
const codeBlockOne = multiFileEl!.children[0]!;
expect(codeBlockOne).toBeTruthy();
expect(codeBlockOne?.textContent?.trim()).toBe('this is code');
const codeBlockTwo = multiFileEl!.children[1]!;
expect(codeBlockTwo).toBeTruthy();
expect(codeBlockTwo?.textContent?.trim()).toBe('this is also code');
});
});
| {
"end_byte": 1135,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code-multifile/docs-code-multifile.spec.ts"
} |
angular/adev/shared-docs/pipeline/guides/testing/docs-code-multifile/docs-code-multifile.md_0_123 | <docs-code-multifile>
<docs-code >this is code</docs-code>
<docs-code >this is also code</docs-code>
</docs-code-multifile> | {
"end_byte": 123,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/testing/docs-code-multifile/docs-code-multifile.md"
} |
angular/adev/shared-docs/pipeline/guides/mermaid/index.ts_0_2725 | import {DocsCodeToken} from '../extensions/docs-code/docs-code';
import {chromium} from 'playwright-core';
import {Mermaid, MermaidConfig} from 'mermaid';
import {runfiles} from '@bazel/runfiles';
// Declare mermarid in the context of this file so that typescript doesn't get upset when we
// access it within the `page.evaluate` function. At runtime the context in with the method
// is run difference than this file, but this makes typescript happy.
declare const mermaid: Mermaid;
/** Mermaid configuration to use when creating mermaid svgs. */
const mermaidConfig: MermaidConfig = {
// The `base` theme is the only configurable theme provided by mermaid.
theme: 'base',
};
/** The full path to the mermaid script. */
let mermaidScriptTagData: {path: string} | undefined;
/** Get the mermaid script file path, resolving it if necessary first. */
function getMermaidScriptTagData() {
if (mermaidScriptTagData) {
return mermaidScriptTagData;
}
return (mermaidScriptTagData = {
path: runfiles.resolve('npm/node_modules/mermaid/dist/mermaid.js'),
});
}
/** Replace the code block content with the mermaid generated SVG element string in place. */
export async function processMermaidCodeBlock(token: DocsCodeToken) {
/**
* The diagram source code contents. Marked reuses the token object, causing the need for
* extracting the value before async actions occur in the function.
*/
const diagram = token.code;
// TODO(josephperrott): Determine if we can reuse the browser across token processing.
/** Browser instance to run mermaid within. */
const browser = await chromium.launch({
headless: true,
// The browser binary needs to be discoverable in a build and test environment, which seems to only
// work when provided at the execroot path. We choose to resolve it using the runfiles helper due
// to this requirement.
executablePath: runfiles.resolveWorkspaceRelative(process.env['CHROME_BIN']!),
args: ['--no-sandbox'],
});
/** Page to run mermaid in. */
const page = await browser.newPage();
try {
// We goto a data URI so that we don't have to manage an html file and loading an html file.
await page.goto(`data:text/html,<html></html>`);
await page.addScriptTag(getMermaidScriptTagData());
/** The generated SVG element string for the provided token's code. */
let {svg} = await page.evaluate(
({diagram, config}) => {
mermaid.initialize(config);
return mermaid.render('mermaid-generated-diagram', diagram);
},
{diagram, config: mermaidConfig},
);
// Replace the token's code content with the generated SVG.
token.code = svg;
} finally {
await browser.close();
}
}
| {
"end_byte": 2725,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/mermaid/index.ts"
} |
angular/adev/shared-docs/pipeline/guides/tranformations/image.ts_0_707 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {normalize} from 'path';
import {Renderer, Tokens} from 'marked';
// TODO(josephperrott): Determine how we can define/know the image content base path.
const imageContentBasePath = 'unknown';
export function imageRender(this: Renderer, {href, title, text}: Tokens.Image) {
const isRelativeSrc = href?.startsWith('./');
const src = isRelativeSrc ? `${imageContentBasePath}/${normalize(href)}` : href;
return `
<img src="${src}" alt="${text}" title="${title}" class="docs-image">
`;
}
| {
"end_byte": 707,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/tranformations/image.ts"
} |
angular/adev/shared-docs/pipeline/guides/tranformations/table.ts_0_782 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Renderer, Tokens} from 'marked';
export function tableRender(this: Renderer, {header, rows}: Tokens.Table) {
return `
<div class="docs-table docs-scroll-track-transparent">
<table>
<thead>
${this.tablerow({
text: header.map((cell) => this.tablecell(cell)).join(''),
})}
</thead>
<tbody>
${rows
.map((row) =>
this.tablerow({
text: row.map((cell) => this.tablecell(cell)).join(''),
}),
)
.join('')}
</tbody>
</table>
</div>
`;
}
| {
"end_byte": 782,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/tranformations/table.ts"
} |
angular/adev/shared-docs/pipeline/guides/tranformations/text.ts_0_709 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Renderer, Tokens} from 'marked';
import emojiRegex from 'emoji-regex';
/** Regex to find unicode emojis. */
const UNICODE_EMOJI_REGEX = /&#x[\dA-Fa-f]+;/g;
/** Regex to find emojis. */
const regex = emojiRegex();
export function textRender(this: Renderer, token: Tokens.Text) {
const text = token.tokens ? this.parser.parseInline(token.tokens) : token.text;
return regex.test(token.text) || UNICODE_EMOJI_REGEX.test(token.text)
? `<span class="docs-emoji">${text}</span>`
: text;
}
| {
"end_byte": 709,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/tranformations/text.ts"
} |
angular/adev/shared-docs/pipeline/guides/tranformations/heading.ts_0_1547 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Renderer, Tokens} from 'marked';
import {getHeaderId} from '../state';
import {getPageTitle} from '../utils';
export function headingRender(this: Renderer, {depth, tokens}: Tokens.Heading): string {
const text = this?.parser.parseInline(tokens);
return formatHeading({text, depth});
}
export function formatHeading({text, depth}: {text: string; depth: number}): string {
if (depth === 1) {
return `
<header class="docs-header">
<docs-breadcrumb></docs-breadcrumb>
${getPageTitle(text)}
</header>
`;
}
// Nested anchor elements are invalid in HTML
// They might happen when we have a code block in a heading
// regex aren't perfect for that but this one should be "good enough"
const regex = /<a\s+(?:[^>]*?\s+)?href.*?>(.*?)<\/a>/gi;
const anchorLessText = text.replace(regex, '$1');
// extract the extended markdown heading id
// ex: ## MyHeading {# myId}
const customIdRegex = /{#\s*([\w-]+)\s*}/g;
const customId = customIdRegex.exec(anchorLessText)?.[1];
const link = customId ?? getHeaderId(anchorLessText);
const label = anchorLessText.replace(/`(.*?)`/g, '<code>$1</code>').replace(customIdRegex, '');
return `
<h${depth} id="${link}">
<a href="#${link}" class="docs-anchor" tabindex="-1" aria-label="Link to ${label}">${label}</a>
</h${depth}>
`;
}
| {
"end_byte": 1547,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/tranformations/heading.ts"
} |
angular/adev/shared-docs/pipeline/guides/tranformations/list.ts_0_575 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Renderer, Tokens} from 'marked';
export function listRender(this: Renderer, {items, ordered}: Tokens.List) {
if (ordered) {
return `
<ol class="docs-ordered-list">
${items.map((item) => this.listitem(item)).join('')}
</ol>
`;
}
return `
<ul class="docs-list">
${items.map((item) => this.listitem(item)).join('')}
</ul>
`;
}
| {
"end_byte": 575,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/tranformations/list.ts"
} |
angular/adev/shared-docs/pipeline/guides/tranformations/link.ts_0_534 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {anchorTarget} from '../helpers';
import {Renderer, Tokens} from 'marked';
export function linkRender(this: Renderer, {href, title, tokens}: Tokens.Link) {
const titleAttribute = title ? ` title=${title}` : '';
return `<a href="${href}"${titleAttribute}${anchorTarget(href)}>${this.parser.parseInline(tokens)}</a>`;
}
| {
"end_byte": 534,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/guides/tranformations/link.ts"
} |
angular/adev/shared-docs/pipeline/examples/template/karma.conf.js_0_1405 | // Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma'),
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true, // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage/example-app'),
subdir: '.',
reporters: [{type: 'html'}, {type: 'text-summary'}],
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true,
});
};
| {
"end_byte": 1405,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/template/karma.conf.js"
} |
angular/adev/shared-docs/pipeline/examples/template/package.json.template_0_1075 | {
"name": "example-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^16.1.1",
"@angular/common": "^16.1.1",
"@angular/compiler": "^16.1.1",
"@angular/core": "^16.1.1",
"@angular/forms": "^16.1.1",
"@angular/platform-browser": "^16.1.1",
"@angular/platform-browser-dynamic": "^16.1.1",
"@angular/router": "^16.1.1",
"rxjs": "~7.4.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16.1.0",
"@angular/cli": "^16.1.0",
"@angular/compiler-cli": "^16.1.1",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"jasmine-core": "~3.10.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.0.3"
}
}
| {
"end_byte": 1075,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/template/package.json.template"
} |
angular/adev/shared-docs/pipeline/examples/template/BUILD.bazel_0_102 | filegroup(
name = "files",
srcs = glob(["**/*"]),
visibility = ["//visibility:public"],
)
| {
"end_byte": 102,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/template/BUILD.bazel"
} |
angular/adev/shared-docs/pipeline/examples/template/src/index.html_0_434 | <!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>
| {
"end_byte": 434,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/template/src/index.html"
} |
angular/adev/shared-docs/pipeline/examples/template/src/main.ts_0_479 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser';
import {AppComponent} from './app/app.component';
bootstrapApplication(AppComponent, {
providers: [provideProtractorTestingSupport()],
}).catch((err) => console.error(err));
| {
"end_byte": 479,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/template/src/main.ts"
} |
angular/adev/shared-docs/pipeline/examples/template/src/styles.css_0_124 | body {
font-family: Roboto, 'Helvetica Neue', sans-serif;
margin: 0;
padding: 30px;
}
html, body {
height: 100%;
}
| {
"end_byte": 124,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/template/src/styles.css"
} |
angular/adev/shared-docs/pipeline/examples/template/src/app/app.component.ts_0_446 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component} from '@angular/core';
@Component({
standalone: true,
selector: 'app-root',
template: '<h2>Example template</h2>',
styles: [
`
h2 {
color: blue;
}
`,
],
})
export class AppComponent {}
| {
"end_byte": 446,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/template/src/app/app.component.ts"
} |
angular/adev/shared-docs/pipeline/examples/shared/file-system.ts_0_2373 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {existsSync} from 'fs';
import {copyFile, mkdir, readdir, rm, stat} from 'fs/promises';
import {join} from 'path';
// TODO(josephperrott): Determine if we can use the fs default version of copying directories.
// TODO(josephperrott): Find a way to not require blank renaming of certain files during copying.
/** Files which must be renamed to remove the .template suffix. */
const knownTemplateFilesForRename = [
// package.json.template must be used as ng_package does not allow floating package.json
// files within the npm package contents.
'package.json.template',
];
/**
* Recursively copy folder and contents to the destigation, creating the destination folder
* if necessary.
**/
export async function copyFolder(source: string, destination: string) {
if (!existsSync(destination)) {
await mkdir(destination, {recursive: true});
}
const files = await readdir(source);
for (const file of files) {
// If the file/dirname starts with `TMP_` we ignore it as we use `TMP_` to start the name of
// our temp directory. Since our temp directory is a subdirectory of the provided example,
// we would end up copying recursively forever.
if (file.startsWith('TMP_')) {
continue;
}
const sourcePath = join(source, file);
let destPath = join(destination, file);
// Rename the destination file path if the file needs to be renamed.
if (knownTemplateFilesForRename.includes(file)) {
destPath = join(destination, file.replace(/.template$/, ''));
}
const stats = await stat(sourcePath);
const isDirectory = await stats.isDirectory();
if (isDirectory) {
await copyFolder(sourcePath, destPath);
} else {
await copyFile(sourcePath, destPath);
}
}
}
/** Create folder at the provided path if it does not already exist. */
export async function createFolder(path: string): Promise<void> {
if (!existsSync(path)) {
await mkdir(path, {recursive: true});
}
}
/** Remove folder at the provided path if it exists. */
export async function removeFolder(path: string): Promise<void> {
if (existsSync(path)) {
await rm(path, {recursive: true});
}
}
| {
"end_byte": 2373,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/shared/file-system.ts"
} |
angular/adev/shared-docs/pipeline/examples/shared/BUILD.bazel_0_248 | load("//tools:defaults.bzl", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "shared",
srcs = glob(
[
"*.ts",
],
),
deps = [
"@npm//@types/node",
],
)
| {
"end_byte": 248,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/shared/BUILD.bazel"
} |
angular/adev/shared-docs/pipeline/examples/shared/copyright.ts_0_1292 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
/** The pad used around the copyright blocks. */
const PAD = '\n\n';
/** The standard copyright block used throughout Angular. */
const COPYRIGHT = `
@license
Copyright Google LLC All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE file at https://angular.dev/license
`;
/** Copyright comment for CSS and Javascript/Typescript files. */
const CSS_TS_COPYRIGHT = `/*${COPYRIGHT}*/${PAD}`;
/** Copyright comment for HTML files. */
const HTML_COPYRIGHT = `<!--${COPYRIGHT}-->${PAD}`;
/**
* Append the copyright using the appropriate commenting structure based on the file extension.
*
* No copyright is appended if the type is unrecognized.
*/
export function appendCopyrightToFile(filename: string, content: string): string {
const extension = filename.split('.').pop();
switch (extension) {
case 'html':
case 'ng':
return `${HTML_COPYRIGHT}${content}`;
case 'js':
case 'ts':
case 'css':
case 'scss':
return `${CSS_TS_COPYRIGHT}${content}`;
default:
return content;
}
}
| {
"end_byte": 1292,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/shared/copyright.ts"
} |
angular/adev/shared-docs/pipeline/examples/zip/defaults.ts_0_716 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export const TEST_FILES_EXTENSION_SUFFIX = '.spec.ts';
export const TEST_FILES_E2E_EXTENSION_SUFFIX = '.e2e-spec.ts';
export const BUILD_BAZEL_FILENAME = 'BUILD.bazel';
export const EXAMPLE_CONFIG_FILENAME = 'example-config.json';
export const CONFIG_FILENAME = 'zip.json';
/** Default file paths to be excluded from stackblitz examples. */
export const EXCLUDE_FILES = [
CONFIG_FILENAME,
BUILD_BAZEL_FILENAME,
EXAMPLE_CONFIG_FILENAME,
TEST_FILES_EXTENSION_SUFFIX,
TEST_FILES_E2E_EXTENSION_SUFFIX,
];
| {
"end_byte": 716,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/zip/defaults.ts"
} |
angular/adev/shared-docs/pipeline/examples/zip/builder.ts_0_3279 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {join} from 'path';
import {readFile} from 'fs/promises';
import {copyFolder, createFolder} from '../shared/file-system';
import {glob} from 'fast-glob';
import {regionParser} from '../../guides/extensions/docs-code/regions/region-parser';
import {appendCopyrightToFile} from '../shared/copyright';
import {FileType} from '../../guides/extensions/docs-code/sanitizers/eslint';
import {EXCLUDE_FILES, CONFIG_FILENAME} from './defaults';
import {zip, strToU8} from 'fflate';
import {FileAndContent} from '../../../interfaces';
interface ZipConfig {
ignore: string[];
files: string[];
}
export async function generateZipExample(
exampleDir: string,
workingDir: string,
templateDir: string,
) {
const config = await readFile(join(exampleDir, CONFIG_FILENAME), 'utf-8');
const stackblitzConfig: ZipConfig = JSON.parse(config) as ZipConfig;
await createFolder(workingDir);
// Copy template files to TEMP folder
await copyFolder(templateDir, workingDir);
// Copy example files to TEMP folder
await copyFolder(exampleDir, workingDir);
const includedPaths = await getIncludedPaths(workingDir, stackblitzConfig);
const filesObj: Record<string, Uint8Array> = {};
for (const path of includedPaths) {
const file = await getFileAndContent(workingDir, path);
filesObj[file.path] = typeof file.content === 'string' ? strToU8(file.content) : file.content;
}
return new Promise<Uint8Array>((resolve, reject) => {
zip(filesObj, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
}
async function getIncludedPaths(workingDir: string, config: ZipConfig): Promise<string[]> {
const defaultIncludes = [
'**/*.ts',
'**/*.js',
'**/*.css',
'**/*.html',
'**/*.md',
'**/*.json',
'**/*.svg',
];
return glob(defaultIncludes, {
cwd: workingDir,
onlyFiles: true,
dot: true,
ignore: config.ignore,
});
}
async function getFileAndContent(workingDir: string, path: string): Promise<FileAndContent> {
let content = await readFile(join(workingDir, path), 'utf-8');
content = appendCopyrightToFile(path, content);
content = extractRegions(path, content);
return {content, path};
}
async function createPostData(
exampleDir: string,
config: ZipConfig,
exampleFilePaths: string[],
): Promise<Record<string, string>> {
const postData: Record<string, string> = {};
for (const filePath of exampleFilePaths) {
if (EXCLUDE_FILES.some((excludedFile) => filePath.endsWith(excludedFile))) {
continue;
}
let content = await readFile(join(exampleDir, filePath), 'utf-8');
content = appendCopyrightToFile(filePath, content);
content = extractRegions(filePath, content);
postData[`project[files][${filePath}]`] = content;
}
return postData;
}
function extractRegions(path: string, contents: string): string {
const fileType: FileType | undefined = path?.split('.').pop() as FileType;
const regionParserResult = regionParser(contents, fileType);
return regionParserResult.contents;
}
| {
"end_byte": 3279,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/zip/builder.ts"
} |
angular/adev/shared-docs/pipeline/examples/zip/BUILD.bazel_0_741 | load("//tools:defaults.bzl", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "zip",
srcs = glob(
[
"*.ts",
],
exclude = [
"index.ts",
],
),
deps = [
"//adev/shared-docs/interfaces",
"//adev/shared-docs/pipeline/examples/shared",
"//adev/shared-docs/pipeline/guides",
"@npm//@types/node",
"@npm//fast-glob",
"@npm//fflate",
],
)
ts_library(
name = "index",
srcs = [
"index.ts",
],
visibility = [
"//adev/shared-docs:__subpackages__",
],
deps = [
":zip",
"@npm//@types/node",
],
)
exports_files([
"index.ts",
])
| {
"end_byte": 741,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/zip/BUILD.bazel"
} |
angular/adev/shared-docs/pipeline/examples/zip/index.ts_0_488 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {writeFileSync} from 'fs';
import {generateZipExample} from './builder';
const [exampleDir, tmpDir, templateDir, outputFilePath] = process.argv.slice(2);
const zipContent = await generateZipExample(exampleDir, tmpDir, templateDir);
writeFileSync(outputFilePath, zipContent);
| {
"end_byte": 488,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/zip/index.ts"
} |
angular/adev/shared-docs/pipeline/examples/stackblitz/defaults.ts_0_760 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export const TEST_FILES_EXTENSION_SUFFIX = '.spec.ts';
export const TEST_FILES_E2E_EXTENSION_SUFFIX = '.e2e-spec.ts';
export const BUILD_BAZEL_FILENAME = 'BUILD.bazel';
export const EXAMPLE_CONFIG_FILENAME = 'example-config.json';
export const STACKBLITZ_CONFIG_FILENAME = 'stackblitz.json';
/** Default file paths to be excluded from stackblitz examples. */
export const EXCLUDE_FILES_FOR_STACKBLITZ = [
STACKBLITZ_CONFIG_FILENAME,
BUILD_BAZEL_FILENAME,
EXAMPLE_CONFIG_FILENAME,
TEST_FILES_EXTENSION_SUFFIX,
TEST_FILES_E2E_EXTENSION_SUFFIX,
];
| {
"end_byte": 760,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/stackblitz/defaults.ts"
} |
angular/adev/shared-docs/pipeline/examples/stackblitz/builder.ts_0_5698 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {join} from 'path';
import {readFile} from 'fs/promises';
import {copyFolder, createFolder, removeFolder} from '../shared/file-system';
import jsdom from 'jsdom';
import {glob} from 'fast-glob';
import {regionParser} from '../../guides/extensions/docs-code/regions/region-parser';
import {appendCopyrightToFile} from '../shared/copyright';
import {FileType} from '../../guides/extensions/docs-code/sanitizers/eslint';
import {EXCLUDE_FILES_FOR_STACKBLITZ, STACKBLITZ_CONFIG_FILENAME} from './defaults';
interface StackblitzConfig {
title: string;
ignore: string[];
file: string;
tags: string[];
description: string;
}
export async function generateStackblitzExample(
exampleDir: string,
temporaryExampleDir: string,
stackblitzTemplateDir: string,
) {
const config = await readFile(join(exampleDir, STACKBLITZ_CONFIG_FILENAME), 'utf-8');
const stackblitzConfig: StackblitzConfig = JSON.parse(config) as StackblitzConfig;
await createFolder(temporaryExampleDir);
// Copy template files to TEMP folder
await copyFolder(stackblitzTemplateDir, temporaryExampleDir);
// Copy example files to TEMP folder
await copyFolder(exampleDir, temporaryExampleDir);
const result = await generateStackblitzHtml(temporaryExampleDir, stackblitzConfig);
await removeFolder(temporaryExampleDir);
return result;
}
async function generateStackblitzHtml(
temporaryExampleDir: string,
stackBlitzConfig: StackblitzConfig,
): Promise<string> {
const defaultIncludes = [
'**/*.ts',
'**/*.js',
'**/*.css',
'**/*.html',
'**/*.md',
'**/*.json',
'**/*.svg',
];
const exampleFilePaths = await glob(defaultIncludes, {
cwd: temporaryExampleDir,
onlyFiles: true,
dot: true,
ignore: stackBlitzConfig.ignore,
});
const postData = await createPostData(temporaryExampleDir, stackBlitzConfig, exampleFilePaths);
const primaryFile = getPrimaryFile(stackBlitzConfig.file, exampleFilePaths);
return createStackblitzHtml(postData, primaryFile);
}
function getPrimaryFile(primaryFilePath: string, exampleFilePaths: string[]): string {
if (primaryFilePath) {
if (!exampleFilePaths.some((filePath) => filePath === primaryFilePath)) {
throw new Error(`The specified primary file (${primaryFilePath}) does not exist!`);
}
return primaryFilePath;
} else {
const defaultPrimaryFilePaths = [
'src/app/app.component.html',
'src/app/app.component.ts',
'src/app/main.ts',
];
const primaryFile = defaultPrimaryFilePaths.find((path) =>
exampleFilePaths.some((filePath) => filePath === path),
);
if (!primaryFile) {
throw new Error(
`None of the default primary files (${defaultPrimaryFilePaths.join(', ')}) exists.`,
);
}
return primaryFile;
}
}
async function createPostData(
exampleDir: string,
config: StackblitzConfig,
exampleFilePaths: string[],
): Promise<Record<string, string>> {
const postData: Record<string, string> = {};
for (const filePath of exampleFilePaths) {
if (EXCLUDE_FILES_FOR_STACKBLITZ.some((excludedFile) => filePath.endsWith(excludedFile))) {
continue;
}
let content = await readFile(join(exampleDir, filePath), 'utf-8');
content = appendCopyrightToFile(filePath, content);
content = extractRegions(filePath, content);
postData[`project[files][${filePath}]`] = content;
}
const tags = ['angular', 'example', ...(config.tags || [])];
tags.forEach((tag, index) => (postData[`project[tags][${index}]`] = tag));
postData['project[description]'] = `Angular Example - ${config.description}`;
postData['project[template]'] = 'node';
postData['project[title]'] = config.title ?? 'Angular Example';
return postData;
}
function createStackblitzHtml(postData: Record<string, string>, primaryFile: string): string {
const baseHtml = createBaseStackblitzHtml(primaryFile);
const doc = new jsdom.JSDOM(baseHtml).window.document;
const form = doc.querySelector('form');
for (const [key, value] of Object.entries(postData)) {
const element = htmlToElement(doc, `<input type="hidden" name="${key}">`);
if (element && form) {
element.setAttribute('value', value as string);
form.appendChild(element);
}
}
return doc.documentElement.outerHTML;
}
function createBaseStackblitzHtml(primaryFile: string) {
const action = `https://stackblitz.com/run?file=${primaryFile}`;
return `
<!DOCTYPE html><html lang="en"><body>
<form id="mainForm" method="post" action="${action}" target="_self"></form>
<script>
var embedded = 'ctl=1';
var isEmbedded = window.location.search.indexOf(embedded) > -1;
if (isEmbedded) {
var form = document.getElementById('mainForm');
var action = form.action;
var actionHasParams = action.indexOf('?') > -1;
var symbol = actionHasParams ? '&' : '?'
form.action = form.action + symbol + embedded;
}
document.getElementById("mainForm").submit();
</script>
</body></html>
`.trim();
}
function htmlToElement(document: Document, html: string) {
const div = document.createElement('div');
div.innerHTML = html;
return div.firstElementChild;
}
function extractRegions(path: string, contents: string): string {
const fileType: FileType | undefined = path?.split('.').pop() as FileType;
const regionParserResult = regionParser(contents, fileType);
return regionParserResult.contents;
}
| {
"end_byte": 5698,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/stackblitz/builder.ts"
} |
angular/adev/shared-docs/pipeline/examples/stackblitz/BUILD.bazel_0_743 | load("//tools:defaults.bzl", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "stackblitz",
srcs = glob(
[
"*.ts",
],
exclude = [
"index.ts",
],
),
deps = [
"//adev/shared-docs/pipeline/examples/shared",
"//adev/shared-docs/pipeline/guides",
"@npm//@types/jsdom",
"@npm//@types/node",
"@npm//fast-glob",
"@npm//jsdom",
],
)
ts_library(
name = "index",
srcs = [
"index.ts",
],
visibility = [
"//adev/shared-docs:__subpackages__",
],
deps = [
":stackblitz",
"@npm//@types/node",
],
)
exports_files([
"index.ts",
])
| {
"end_byte": 743,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/stackblitz/BUILD.bazel"
} |
angular/adev/shared-docs/pipeline/examples/stackblitz/index.ts_0_536 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {writeFileSync} from 'fs';
import {generateStackblitzExample} from './builder';
const [exampleDir, tmpDir, templateDir, outputFilePath] = process.argv.slice(2);
const htmlOutputContent = await generateStackblitzExample(exampleDir, tmpDir, templateDir);
writeFileSync(outputFilePath, htmlOutputContent, {encoding: 'utf8'});
| {
"end_byte": 536,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/examples/stackblitz/index.ts"
} |
angular/adev/shared-docs/pipeline/tutorials/routes.ts_0_2008 | import {
PlaygroundRouteData,
TutorialConfig,
TutorialNavigationItemWithStep,
TutorialNavigationItem,
} from '../../interfaces';
export async function generatePlaygroundRoutes(
configs: Record<string, TutorialConfig>,
): Promise<PlaygroundRouteData> {
const templates = Object.entries(configs).map(([path, config]) => ({
path: `playground/${path}`,
label: config.title,
}));
return {
templates,
defaultTemplate: templates[0],
starterTemplate: templates[templates.length - 1],
};
}
export async function generateTutorialRoutes(
tutorialName: string,
introConfig: TutorialConfig,
stepConfigs: Record<string, TutorialConfig>,
): Promise<TutorialNavigationItemWithStep> {
const children: TutorialNavigationItem[] = Object.entries(stepConfigs)
// Sort using the number prefix from the step directory name.
.sort(([pathA], [pathB]) =>
Number(pathA.split('-')[0]) > Number(pathB.split('-')[0]) ? 1 : -1,
)
.map(([path, config], idx) => {
return {
label: config.title,
path: `tutorials/${tutorialName}/${path}`,
contentPath: `tutorials/${tutorialName}/steps/${path}/README`,
tutorialData: {
title: config.title,
type: config.type,
step: idx + 1,
},
};
});
children.forEach((child, idx, childrenArr) => {
if (idx > 0) {
const prevStep = childrenArr.at(idx - 1);
if (prevStep) {
child.tutorialData.previousStep = prevStep.path;
}
}
if (idx < childrenArr.length - 1) {
const nextStep = childrenArr.at(idx + 1);
if (nextStep) {
child.tutorialData.nextStep = nextStep.path;
}
}
});
return {
path: `tutorials/${tutorialName}`,
label: introConfig.title,
contentPath: `tutorials/${tutorialName}/intro/README`,
tutorialData: {
step: 0,
title: introConfig.title,
type: introConfig.type,
nextStep: children[0].path,
},
children: children,
};
}
| {
"end_byte": 2008,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/routes.ts"
} |
angular/adev/shared-docs/pipeline/tutorials/webcontainers.ts_0_2311 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {basename, dirname, extname} from 'path';
import type {DirectoryNode, FileNode, FileSystemTree} from '@webcontainer/api';
import {FileAndContent, FileAndContentRecord} from '../../interfaces';
/**
* Create a WebContainer's FileSystemTree from a list of files and its contents
*/
export function getFileSystemTree(files: string[], filesContents: FileAndContentRecord) {
const fileSystemTree: FileSystemTree = {};
for (let filepath of files) {
const dir = dirname(filepath);
const filename = basename(filepath);
if (dir === '.') {
const fileNode: FileNode = {file: {contents: filesContents[filepath]}};
fileSystemTree[filename] = fileNode;
} else {
const dirParts = dir.split('/');
buildFileSystemTree(fileSystemTree, dirParts, filename, filesContents[filepath]);
}
}
return fileSystemTree;
}
/**
* Builds a WebContainer's file system tree object recursively, mutating the
* `fileSystemTree` parameter.
*
* @see https://webcontainers.io/api#filesystemtree
*/
function buildFileSystemTree(
fileSystemTree: FileSystemTree,
fileDirectories: string[],
filename: FileAndContent['path'],
fileContents: FileAndContent['content'],
): void {
if (fileDirectories.length === 1) {
const directory = fileDirectories[0];
const fileNode: FileNode = {file: {contents: fileContents}};
fileSystemTree[directory] = {
...fileSystemTree[directory],
directory: {
...(fileSystemTree[directory]
? (fileSystemTree[directory] as DirectoryNode).directory
: undefined),
[filename]: fileNode,
},
};
return;
}
const nextDirectory = fileDirectories.shift();
if (!nextDirectory) return;
if (!fileSystemTree[nextDirectory]) {
fileSystemTree[nextDirectory] = {directory: {}};
}
buildFileSystemTree(
(fileSystemTree[nextDirectory] as DirectoryNode).directory,
fileDirectories,
filename,
fileContents,
);
}
export function shouldUseFileInWebContainer(filename: string) {
return ['.md', '.png', '.jpg'].includes(extname(filename)) === false;
}
| {
"end_byte": 2311,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/webcontainers.ts"
} |
angular/adev/shared-docs/pipeline/tutorials/utils.ts_0_3000 | import {glob} from 'fast-glob';
import {FileAndContentRecord, TutorialConfig} from '../../interfaces';
import {dirname, join} from 'path';
import {existsSync, readFileSync} from 'fs';
// See https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files for details
// on identifying file types with initial bytes.
/** Initial bytes of the buffer(aka magic numbers) to see if it's a JPG file. */
const jpgSignature = [0xff, 0xd8, 0xff];
/** Initial bytes of the buffer(aka magic numbers) to see if it's a GIF file. */
const gifSignature = [0x47, 0x49, 0x46];
/** Initial bytes of the buffer(aka magic numbers) to see if it's a PNG file. */
const pngSignature = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
/** List of initial bytes to check for matching files. */
const SIGNATURES = [jpgSignature, gifSignature, pngSignature];
/**
* Get the contents for the provided file, returning a string or Buffer as appropriate.
*/
export function getFileContents<T extends string | Uint8Array>(path: string): T;
export function getFileContents(path: string): string | Uint8Array {
const fileBuffer = readFileSync(path);
if (checkBufferMatchForSignatures(fileBuffer)) {
return fileBuffer;
}
return fileBuffer.toString();
}
/**
* Determine if the initial bytes of a buffer matches the expected bytes.
*/
function checkBufferMatchForSignatures(buffer: Uint8Array): boolean {
for (const initialByes of SIGNATURES) {
for (const [index, byte] of initialByes.entries()) {
if (buffer[index] !== byte) return false;
}
}
return true;
}
/**
* Add all files found in the provided directory into the provided object of file and contents.
* This overwrite already existing files in the object when encountered.
*/
export async function addDirectoryToFilesRecord(
files: FileAndContentRecord,
dir: string,
): Promise<void> {
const exampleFilePaths = await glob('**/*', {
cwd: dir,
onlyFiles: true,
});
for (let path of exampleFilePaths) {
files[path] = await getFileContents(join(dir, path));
}
}
/**
* Collect all of the config.json files in the provided directory and subdirectories.
*/
export async function findAllConfigs(dir: string): Promise<Record<string, TutorialConfig>> {
const configs: Record<string, TutorialConfig> = {};
const paths = await glob('**/config.json', {
cwd: dir,
onlyFiles: true,
});
for (const path of paths) {
const content = await getFileContents<string>(join(dir, path));
configs[dirname(path)] = JSON.parse(content) as TutorialConfig;
}
return configs;
}
/**
* Collect a single of the config.json file at the provided directory.
*/
export async function findConfig(dir: string): Promise<TutorialConfig> {
const configPath = join(dir, 'config.json');
if (!existsSync(configPath)) {
throw Error(`Unable config.json file found at: ${dir}`);
}
const content = await getFileContents<string>(configPath);
return JSON.parse(content) as TutorialConfig;
}
| {
"end_byte": 3000,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/utils.ts"
} |
angular/adev/shared-docs/pipeline/tutorials/BUILD.bazel_0_994 | load("//tools:defaults.bzl", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "editor",
srcs = glob(
[
"*.ts",
],
exclude = [
"playground.ts",
"tutorial.ts",
],
),
deps = [
"//adev/shared-docs/interfaces",
"@npm//@types/node",
"@npm//@webcontainer/api",
"@npm//fast-glob",
],
)
ts_library(
name = "playground",
srcs = [
"playground.ts",
],
visibility = [
"//adev/shared-docs:__subpackages__",
],
deps = [
":editor",
"//adev/shared-docs/interfaces",
"@npm//@types/node",
"@npm//fast-glob",
],
)
ts_library(
name = "tutorials",
srcs = [
"tutorial.ts",
],
visibility = [
"//adev/shared-docs:__subpackages__",
],
deps = [
":editor",
"//adev/shared-docs/interfaces",
"@npm//@types/node",
],
)
| {
"end_byte": 994,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/BUILD.bazel"
} |
angular/adev/shared-docs/pipeline/tutorials/tutorial.ts_0_3649 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {basename, join} from 'path';
import {FileAndContentRecord} from '../../interfaces';
import {existsSync, mkdirSync, writeFileSync} from 'fs';
import {addDirectoryToFilesRecord, findAllConfigs, findConfig} from './utils';
import {generateMetadata} from './metadata';
import {generateSourceCode} from './source-code';
import {generateTutorialRoutes} from './routes';
/**
* Generates the files for the provided tutorial directory.
*
* Creates a routes file for the tutorial, and metadata and soure-code files for
* each of the tutorial steps.
*/
async function generateTutorialFiles(tutorialDir: string, commonDir: string, outputDir: string) {
/** All files available in the tutorial entries. */
const files: FileAndContentRecord = {};
/** List of configs for each step in the tutorial. */
const stepConfigs = await findAllConfigs(join(tutorialDir, 'steps'));
/** Directory of the intro. */
const introDir = join(tutorialDir, 'intro');
/** The configuration for the intro (landing page) of the tutorial. */
const introConfig = await findConfig(introDir);
/** The name of the tutorial, as determined by the tutorial directory name. */
const tutorialName = basename(tutorialDir);
// Add all of the files from the common directory into the files record
await addDirectoryToFilesRecord(files, commonDir);
// If the tutorial directory provides additional common files, add them to the files record.
const commonTutorialDir = join(tutorialDir, 'common');
if (existsSync(commonTutorialDir)) {
await addDirectoryToFilesRecord(files, commonTutorialDir);
}
/** Duplication of the common shared files to add the tutorial intro files in. */
const introFiles = {...files};
await addDirectoryToFilesRecord(introFiles, introDir);
// Ensure the directory for the tutorial exists, then write the metadata and source-code
// files for the intro.
mkdirSync(join(outputDir), {recursive: true});
writeFileSync(
join(outputDir, 'metadata.json'),
JSON.stringify(await generateMetadata(introDir, introConfig, introFiles)),
);
writeFileSync(
join(outputDir, 'source-code.json'),
JSON.stringify(await generateSourceCode(introConfig, introFiles)),
);
// For each tutorial step, generate the metadata and source-code files.
for (const [path, config] of Object.entries(stepConfigs)) {
/** Duplication of the common shared files to add the tutorial step files in. */
const itemFiles = {...files};
/** Directory of the current step. */
const stepDir = join(tutorialDir, 'steps', path);
await addDirectoryToFilesRecord(itemFiles, stepDir);
// Ensure the directory for the tutorial step exists, then write the metadata
// and source-code files.
mkdirSync(join(outputDir, path), {recursive: true});
writeFileSync(
join(outputDir, path, 'metadata.json'),
JSON.stringify(await generateMetadata(stepDir, config, itemFiles)),
);
writeFileSync(
join(outputDir, path, 'source-code.json'),
JSON.stringify(await generateSourceCode(config, itemFiles)),
);
}
// Generate the tutorial routes, and write the file.
writeFileSync(
join(outputDir, 'routes.json'),
JSON.stringify(await generateTutorialRoutes(tutorialName, introConfig, stepConfigs)),
);
}
(async () => {
const [tutorialDir, commonDir, outputDir] = process.argv.slice(2);
await generateTutorialFiles(tutorialDir, commonDir, outputDir);
})();
| {
"end_byte": 3649,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/tutorial.ts"
} |
angular/adev/shared-docs/pipeline/tutorials/metadata.ts_0_2029 | import {join, dirname} from 'path';
import {glob} from 'fast-glob';
import {
FileAndContentRecord,
PackageJson,
TutorialConfig,
TutorialMetadata,
} from '../../interfaces';
import {getFileContents} from './utils';
/** Generate the metadata.json content for a provided tutorial config. */
export async function generateMetadata(
path: string,
config: TutorialConfig,
files: FileAndContentRecord,
): Promise<TutorialMetadata> {
const tutorialFiles: FileAndContentRecord = {};
const {dependencies, devDependencies} = JSON.parse(<string>files['package.json']) as PackageJson;
config.openFiles?.forEach((file) => (tutorialFiles[file] = files[file]));
return {
type: config.type,
openFiles: config.openFiles || [],
allFiles: Object.keys(files),
tutorialFiles,
answerFiles: await getAnswerFiles(path, config, files),
hiddenFiles: config.openFiles
? Object.keys(files).filter((filename) => !config.openFiles!.includes(filename))
: [],
dependencies: {
...dependencies,
...devDependencies,
},
};
}
/** Generate the answer files for the metadata.json. */
async function getAnswerFiles(
path: string,
config: TutorialConfig,
files: FileAndContentRecord,
): Promise<FileAndContentRecord> {
const answerFiles: FileAndContentRecord = {};
const answerPrefix = /answer[\\/]/;
if (config.answerSrc) {
const answersDir = join(path, config.answerSrc);
const answerFilePaths = await glob('**/*', {
cwd: answersDir,
onlyFiles: true,
absolute: false,
});
for (const answerFile of answerFilePaths) {
// We use the absolute file in order to read the content, but the key
// needs to be a relative path within the project.
answerFiles[answerFile] = getFileContents(join(answersDir, answerFile));
}
} else {
for (const file of Object.keys(files)) {
if (answerPrefix.test(file)) {
answerFiles[file.replace(answerPrefix, '')] = files[file];
}
}
}
return answerFiles;
}
| {
"end_byte": 2029,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/metadata.ts"
} |
angular/adev/shared-docs/pipeline/tutorials/playground.ts_0_2737 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {join} from 'path';
import {FileAndContentRecord} from '../../interfaces';
import {existsSync, mkdirSync, writeFileSync} from 'fs';
import {addDirectoryToFilesRecord, findAllConfigs} from './utils';
import {generateMetadata} from './metadata';
import {generateSourceCode} from './source-code';
import {generatePlaygroundRoutes} from './routes';
/**
* Generates the playground files for the playground directory.
*
* Creates a routes file for the overall playground, and metadata and soure-code files for
* each of the plaground entries.
*/
async function generatePlaygroundFiles(
playgroundDir: string,
commonDir: string,
outputDir: string,
) {
/** All files available in the playground entries. */
const files: FileAndContentRecord = {};
/** All of the configs, one for each playground entry. */
const configs = await findAllConfigs(playgroundDir);
// Add all of the files from the common directory into the files record.
await addDirectoryToFilesRecord(files, commonDir);
// If the playground directory provides additional common files, add them to the files record.
const commonPlaygroundDir = join(playgroundDir, 'common');
if (existsSync(commonPlaygroundDir)) {
await addDirectoryToFilesRecord(files, commonPlaygroundDir);
}
// For each playground entry, generate the metadata and source-code files.
for (const [path, config] of Object.entries(configs)) {
/** Duplication of the common shared files to add the playground entry files in. */
const itemFiles = {...files};
/** Directory of the current config. */
const configDir = join(playgroundDir, path);
await addDirectoryToFilesRecord(itemFiles, configDir);
// Ensure the directory for the playground entry exists, then write the metadata
// and source-code files.
mkdirSync(join(outputDir, path), {recursive: true});
writeFileSync(
join(outputDir, path, 'metadata.json'),
JSON.stringify(await generateMetadata(configDir, config, itemFiles)),
);
writeFileSync(
join(outputDir, path, 'source-code.json'),
JSON.stringify(await generateSourceCode(config, itemFiles)),
);
}
// Generate the playground routes, and write the file.
writeFileSync(
join(outputDir, 'routes.json'),
JSON.stringify(await generatePlaygroundRoutes(configs)),
);
}
// Immediately invoke the generation.
(async () => {
const [playgroundDir, commonDir, outputDir] = process.argv.slice(2);
await generatePlaygroundFiles(playgroundDir, commonDir, outputDir);
})();
| {
"end_byte": 2737,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/playground.ts"
} |
angular/adev/shared-docs/pipeline/tutorials/source-code.ts_0_534 | import {FileSystemTree} from '@webcontainer/api';
import {FileAndContentRecord, TutorialConfig} from '../../interfaces';
import {getFileSystemTree} from './webcontainers';
/** Generate the source-code.json content for a provided tutorial config. */
export async function generateSourceCode(
config: TutorialConfig,
files: FileAndContentRecord,
): Promise<FileSystemTree> {
// TODO(josephperrott): figure out if filtering is needed for this.
const allFiles = Object.keys(files);
return getFileSystemTree(allFiles, files);
}
| {
"end_byte": 534,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/source-code.ts"
} |
angular/adev/shared-docs/pipeline/tutorials/common/package.json.template_0_688 | {
"name": "angular.dev",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "NG_BUILD_PARALLEL_TS=0 ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development"
},
"private": true,
"dependencies": {
"@angular/common": "^17.0.0-rc.1",
"@angular/compiler": "^17.0.0-rc.1",
"@angular/core": "^17.0.0-rc.1",
"@angular/platform-browser": "^17.0.0-rc.1",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.0-rc.2",
"@angular/cli": "^17.0.0-rc.2",
"@angular/compiler-cli": "^17.0.0-rc.1",
"typescript": "~5.2.0"
}
}
| {
"end_byte": 688,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/common/package.json.template"
} |
angular/adev/shared-docs/pipeline/tutorials/common/BUILD.bazel_0_102 | filegroup(
name = "files",
srcs = glob(["**/*"]),
visibility = ["//visibility:public"],
)
| {
"end_byte": 102,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/common/BUILD.bazel"
} |
angular/adev/shared-docs/pipeline/tutorials/common/src/index.html_0_320 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Common</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<app-root></app-root>
</body>
</html>
| {
"end_byte": 320,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/common/src/index.html"
} |
angular/adev/shared-docs/pipeline/tutorials/common/src/main.ts_0_445 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {bootstrapApplication} from '@angular/platform-browser';
import {appConfig} from './app/app.config';
import {AppComponent} from './app/app.component';
bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
| {
"end_byte": 445,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/common/src/main.ts"
} |
angular/adev/shared-docs/pipeline/tutorials/common/src/styles.css_0_133 | /* You can add global styles to this file, and also import other style files */
body {
font-family: 'Be Vietnam Pro', sans-serif;
} | {
"end_byte": 133,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/common/src/styles.css"
} |
angular/adev/shared-docs/pipeline/tutorials/common/src/app/app.config.ts_0_320 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {ApplicationConfig} from '@angular/core';
export const appConfig: ApplicationConfig = {
providers: [],
};
| {
"end_byte": 320,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/common/src/app/app.config.ts"
} |
angular/adev/shared-docs/pipeline/tutorials/common/src/assets/angular.svg_0_1261 | <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 223 236"><g clip-path="url(#a)"><path fill="url(#b)" d="m222.077 39.192-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z"/><path fill="url(#c)" d="m222.077 39.192-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z"/></g><defs><linearGradient id="b" x1="49.009" x2="225.829" y1="213.75" y2="129.722" gradientUnits="userSpaceOnUse"><stop stop-color="#E40035"/><stop offset=".24" stop-color="#F60A48"/><stop offset=".352" stop-color="#F20755"/><stop offset=".494" stop-color="#DC087D"/><stop offset=".745" stop-color="#9717E7"/><stop offset="1" stop-color="#6C00F5"/></linearGradient><linearGradient id="c" x1="41.025" x2="156.741" y1="28.344" y2="160.344" gradientUnits="userSpaceOnUse"><stop stop-color="#FF31D9"/><stop offset="1" stop-color="#FF5BE1" stop-opacity="0"/></linearGradient><clipPath id="a"><path fill="#fff" d="M0 0h223v236H0z"/></clipPath></defs></svg> | {
"end_byte": 1261,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/pipeline/tutorials/common/src/assets/angular.svg"
} |
angular/adev/shared-docs/constants/delay.ts_0_376 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// Used for both the table of contents and the home animation
export const RESIZE_EVENT_DELAY = 500;
// Used for the home animation
export const WEBGL_LOADED_DELAY = 250;
| {
"end_byte": 376,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/constants/delay.ts"
} |
angular/adev/shared-docs/constants/BUILD.bazel_0_439 | load("//tools:defaults.bzl", "ts_library")
package(default_visibility = ["//visibility:private"])
ts_library(
name = "constants",
srcs = [
"index.ts",
],
visibility = [
"//adev/shared-docs:__subpackages__",
],
deps = [
":lib",
],
)
ts_library(
name = "lib",
srcs = glob(
[
"*.ts",
],
exclude = [
"index.ts",
],
),
)
| {
"end_byte": 439,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/constants/BUILD.bazel"
} |
angular/adev/shared-docs/constants/index.ts_0_229 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export * from './delay';
| {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/constants/index.ts"
} |
angular/adev/shared-docs/providers/previews-components.ts_0_399 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {InjectionToken} from '@angular/core';
import {CodeExamplesMap} from '../interfaces/index';
export const PREVIEWS_COMPONENTS = new InjectionToken<CodeExamplesMap>('PREVIEWS_COMPONENTS');
| {
"end_byte": 399,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/providers/previews-components.ts"
} |
angular/adev/shared-docs/providers/is-search-dialog-open.ts_0_379 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {InjectionToken, signal} from '@angular/core';
export const IS_SEARCH_DIALOG_OPEN = new InjectionToken('', {
providedIn: 'root',
factory: () => signal(false),
});
| {
"end_byte": 379,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/providers/is-search-dialog-open.ts"
} |
angular/adev/shared-docs/providers/environment.ts_0_375 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {InjectionToken} from '@angular/core';
import {Environment} from '../interfaces/index';
export const ENVIRONMENT = new InjectionToken<Environment>('ENVIRONMENT');
| {
"end_byte": 375,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/providers/environment.ts"
} |
angular/adev/shared-docs/providers/local-storage.ts_0_1596 | /*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {isPlatformBrowser} from '@angular/common';
import {InjectionToken, PLATFORM_ID, inject} from '@angular/core';
export const LOCAL_STORAGE = new InjectionToken<Storage | null>('LOCAL_STORAGE', {
providedIn: 'root',
factory: () => getStorage(inject(PLATFORM_ID)),
});
const getStorage = (platformId: Object): Storage | null => {
// Prerendering: localStorage is undefined for prerender build
return isPlatformBrowser(platformId) ? new LocalStorage() : null;
};
/**
* LocalStorage is wrapper class for localStorage, operations can fail due to various reasons,
* such as browser restrictions or storage limits being exceeded. A wrapper is providing error handling.
*/
class LocalStorage implements Storage {
get length(): number {
try {
return localStorage.length;
} catch {
return 0;
}
}
clear(): void {
try {
localStorage.clear();
} catch {}
}
getItem(key: string): string | null {
try {
return localStorage.getItem(key);
} catch {
return null;
}
}
key(index: number): string | null {
try {
return localStorage.key(index);
} catch {
return null;
}
}
removeItem(key: string): void {
try {
localStorage.removeItem(key);
} catch {}
}
setItem(key: string, value: string): void {
try {
localStorage.setItem(key, value);
} catch {}
}
}
| {
"end_byte": 1596,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/shared-docs/providers/local-storage.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.