mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
docs: Add back script to generate example previews map (#60778)
Restores the ability to have example components rendered alongside the code. This functionality was broken a while back by #53511. To enable the embedded preview for an example, add `preview` and `path=adev/src/content/expamples/component/to/render.ts` attributes to the `<docs-code>` or `<docs-code-multifile>` tag. Tested with one of the accessibility examples and it seems to work now. PR Close #60778
This commit is contained in:
@@ -1,15 +1,7 @@
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
|
||||
load("//adev/shared-docs:index.bzl", "generate_previews")
|
||||
|
||||
# TODO(josephperrott): Generate previews from source instead of using already generated files
|
||||
|
||||
exports_files(
|
||||
glob(["*"]),
|
||||
)
|
||||
|
||||
copy_to_bin(
|
||||
generate_previews(
|
||||
name = "previews",
|
||||
srcs = glob(["*"]),
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
example_srcs = "//adev/src/content/examples",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/*!
|
||||
* @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
|
||||
*/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* DO NOT MANUALLY EDIT THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
import {Type} from '@angular/core';
|
||||
|
||||
/**
|
||||
* Map of the previews components, values are functions which returns the promise of the component type, which will be displayed as preview in the ExampleViewer component.
|
||||
* Keys has to be equal to paths written down in the docs markdown files.
|
||||
*/
|
||||
export const PREVIEWS_COMPONENTS_MAP: Record<string, () => Promise<Type<unknown>>> = {};
|
||||
@@ -0,0 +1,7 @@
|
||||
filegroup(
|
||||
name = "examples",
|
||||
srcs = [
|
||||
"//adev/src/content/examples/accessibility:ts_files",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -1,5 +1,26 @@
|
||||
load("//tools:defaults.bzl", "ng_module")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "ts_files",
|
||||
srcs = glob(["src/app/**/*.ts"]),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
ng_module(
|
||||
name = "example",
|
||||
srcs = [":ts_files"],
|
||||
assets = glob([
|
||||
"src/app/**/*.html",
|
||||
"src/app/**/*.css",
|
||||
]),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"@npm//@angular/core",
|
||||
],
|
||||
)
|
||||
|
||||
exports_files([
|
||||
"src/app/app.component.html",
|
||||
"src/app/app.component.ts",
|
||||
|
||||
Reference in New Issue
Block a user