Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 286f9f5

Browse files
JeanMecheAndrewKushnir
authored andcommitted
docs: embeded best practices in page (#62173)
PR Close #62173
1 parent fec2ee1 commit 286f9f5

File tree

6 files changed

+30
-1
lines changed

6 files changed

+30
-1
lines changed

‎adev/shared-docs/pipeline/guides/extensions/docs-code/docs-code.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const singleFileCodeRule =
2222
/^\s*<docs-code((?:\s+[\w-]+(?:="[^"]*"|='[^']*'|=[^\s>]*)?)*)\s*(?:\/>|>(.*?)<\/docs-code>)/s;
2323

2424
const pathRule = /path="([^"]*)"/;
25+
const classRule = /class="([^"]*)"/;
2526
const headerRule = /header="([^"]*)"/;
2627
const linenumsRule = /linenums/;
2728
const highlightRule = /highlight="([^"]*)"/;
@@ -51,6 +52,7 @@ export const docsCodeExtension = {
5152
const visibleLines = visibleLinesRule.exec(attr);
5253
const visibleRegion = visibleRegionRule.exec(attr);
5354
const preview = previewRule.exec(attr) ? true : false;
55+
const classes = classRule.exec(attr);
5456

5557
let code = match[2]?.trim() ?? '';
5658
if (path && path[1]) {
@@ -73,6 +75,7 @@ export const docsCodeExtension = {
7375
visibleLines: visibleLines?.[1],
7476
visibleRegion: visibleRegion?.[1],
7577
preview: preview,
78+
classes: classes?.[1]?.split(' '),
7679
};
7780
return token;
7881
}

‎adev/shared-docs/pipeline/guides/extensions/docs-code/format/index.mts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export interface CodeToken extends Tokens.Generic {
3939

4040
/** The generated diff metadata if created in the code formating process. */
4141
diffMetadata?: DiffMetadata;
42+
43+
// additional classes for the element
44+
classes?: string[];
4245
}
4346

4447
export function formatCode(token: CodeToken) {
@@ -97,4 +100,8 @@ function applyContainerAttributesAndClasses(el: Element, token: CodeToken) {
97100
if (token.language === 'shell') {
98101
el.classList.add('shell');
99102
}
103+
104+
if (token.classes) {
105+
el.classList.add(...token.classes);
106+
}
100107
}

‎adev/shared-docs/styles/docs/_code.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ $code-font-size: 0.875rem;
111111
font-size: $code-font-size;
112112
counter-reset: line;
113113
}
114+
115+
&.compact {
116+
pre {
117+
max-height: 300px;
118+
}
119+
}
114120
}
115121

116122
// shell doesn't have a header, for commands only

‎adev/src/content/ai/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ generate_guides(
77
]),
88
data = [
99
"//adev/src/assets/images:what_is_angular.svg",
10+
"//adev/src/context",
1011
],
1112
visibility = ["//adev:__subpackages__"],
1213
)

‎adev/src/content/ai/develop-with-ai.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ Improve your experience generating code with LLMs by using one of the following
88

99
NOTE: These files will be updated on a regular basis staying up to date with Angular's conventions.
1010

11-
* <a href="/context/best-practices.md" target="_blank">best-practices.md</a> - a set of instructions to help LLMs generate correct code that follows Angular best practices. This file can be included as system instructions to your AI tooling or included along with your prompt as context.
11+
Here is a set of instructions to help LLMs generate correct code that follows Angular best practices. This file can be included as system instructions to your AI tooling or included along with your prompt as context.
12+
13+
<docs-code language="md" path="adev/src/context/best-practices.md" class="compact"/>
14+
15+
<!-- Note: download doesnt work in devmode but is fine when deployed -->
16+
<a download href="/context/best-practices.md" target="_blank">Click here to download the best-practices.md file.</a>
1217

1318
## Rules Files
1419
Several editors, such as <a href="https://studio.firebase.google.com?utm_source=adev&utm_medium=website&utm_campaign=BUILD_WITH_AI_ANGULAR&utm_term=angular_devrel&utm_content=build_with_ai_angular_firebase_studio">Firebase Studio</a> have rules files useful for providing critical context to LLMs.

‎adev/src/context/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package(default_visibility = ["//adev:__subpackages__"])
2+
3+
filegroup(
4+
name = "context",
5+
srcs = glob(["**"]),
6+
visibility = ["//visibility:public"],
7+
)

0 commit comments

Comments
 (0)