Skip to content

Commit edfba88

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 ef53e73 commit edfba88

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/aria/BUILD.bazel

Lines changed: 18 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,26 @@ 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+
# TODO: Remove this once examples are created. It should never be empty at that point.
26+
allow_empty = True,
27+
),
28+
out = "resources/code-examples.db",
29+
path = "src/aria/examples",
30+
)
31+
1932
ng_package(
2033
name = "npm_package",
2134
package_name = "@angular/aria",
22-
srcs = ["package.json"],
35+
srcs = [
36+
"package.json",
37+
"resources/code-examples.db",
38+
],
2339
nested_packages = select({
2440
"//:snapshot_adev_assets": [":adev_assets"],
2541
"//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)