Skip to content

Commit 0158774

Browse files
committed
build: setup infrastructure for aria MCP code examples
This commit introduces the infrastructure for embedding code examples within Angular packages, enabling them to be consumed by the Angular CLI's MCP server. The `@angular/aria` package is the first to adopt this new feature. A new `ng_examples_db` Bazel rule is used to build a SQLite database from markdown files containing code examples. This database is then included in the published npm package. The `package.json` for `@angular/aria` has been updated with an `angular.examples` field to allow tooling to discover and use the code examples.
1 parent 2f44d40 commit 0158774

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/aria/BUILD.bazel

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
22
load("@npm//:defs.bzl", "npm_link_all_packages")
33
load("//src/aria:config.bzl", "ARIA_TARGETS")
4-
load("//tools:defaults.bzl", "ng_package", "ts_project")
4+
load("//tools:defaults.bzl", "ng_examples_db", "ng_package", "ts_project")
55

66
package(default_visibility = ["//visibility:public"])
77

@@ -16,10 +16,25 @@ ts_project(
1616
deps = ["//:node_modules/@angular/core"],
1717
)
1818

19+
ng_examples_db(
20+
name = "aria_example_database",
21+
srcs = glob(
22+
include = [
23+
"examples/**/*.md",
24+
],
25+
allow_empty = True,
26+
),
27+
out = "resources/code-examples.db",
28+
path = "src/aria/examples",
29+
)
30+
1931
ng_package(
2032
name = "npm_package",
2133
package_name = "@angular/aria",
22-
srcs = ["package.json"],
34+
srcs = [
35+
"package.json",
36+
"resources/code-examples.db",
37+
],
2338
nested_packages = select({
2439
"//:snapshot_adev_assets": [":adev_assets"],
2540
"//conditions:default": [],

src/aria/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
"dependencies": {
2222
"tslib": "^2.3.0"
2323
},
24+
"angular": {
25+
"examples": {
26+
"format": "sqlite",
27+
"path": "./resources/code-examples.db"
28+
}
29+
},
2430
"ng-update": {
2531
"packageGroup": "NG_UPDATE_PACKAGE_GROUP"
2632
},

tools/defaults.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ load("@aspect_rules_js//npm:defs.bzl", _npm_package = "npm_package")
55
load("@devinfra//bazel/http-server:index.bzl", _http_server = "http_server")
66
load("@devinfra//bazel/spec-bundling:index.bzl", _spec_bundle = "spec_bundle")
77
load("@devinfra//bazel/ts_project:index.bzl", "strict_deps_test")
8+
load("@rules_angular//src/ng_examples_db:index.bzl", _ng_examples_db = "ng_examples_db")
89
load("@rules_angular//src/ng_package:index.bzl", _ng_package = "ng_package")
910
load("@rules_angular//src/ng_package/text_replace:index.bzl", _text_replace = "text_replace")
1011
load("@rules_angular//src/ng_project:index.bzl", _ng_project = "ng_project")
@@ -26,6 +27,7 @@ extract_tokens = _extract_tokens
2627
ng_web_test_suite = _ng_web_test_suite
2728
spec_bundle = _spec_bundle
2829
http_server = _http_server
30+
ng_examples_db = _ng_examples_db
2931

3032
def sass_binary(sourcemap = False, include_paths = [], **kwargs):
3133
_sass_binary(

0 commit comments

Comments
 (0)