docs: Plumb new reference page for the UI plugins API
This is just to set up all the build rules and the plumbing, for now
don't to anything clever and just dump the whole ui/src/public/index.ts
file (e.g. most of the core interfaces with the nice comments) into a
new docs page.
In future we'll do something cleverer and autogenerate a nice reference
page using one of the available tools for TypeScript.
Change-Id: Id06a0c473a32e6b5177077d7f14f82629b79a223
diff --git a/docs/toc.md b/docs/toc.md
index d7c34e3..2ac2751 100644
--- a/docs/toc.md
+++ b/docs/toc.md
@@ -72,6 +72,7 @@
* [Trace Packet proto](reference/trace-packet-proto.autogen)
* [perfetto cmdline](reference/perfetto-cli.md)
* [heap_profile cmdline](reference/heap_profile-cli.md)
+ * [UI Plugin API](reference/ui-plugin-api.autogen)
* [Synthetic TrackEvent](reference/synthetic-track-event.md)
* [Android Version Notes](reference/android-version-notes.md)
* [Stats table](analysis/sql-stats.autogen)
diff --git a/infra/perfetto.dev/BUILD.gn b/infra/perfetto.dev/BUILD.gn
index 75f69b7..7b9d1f5 100644
--- a/infra/perfetto.dev/BUILD.gn
+++ b/infra/perfetto.dev/BUILD.gn
@@ -37,6 +37,7 @@
":gen_toc",
":gen_trace_config_proto",
":gen_trace_packet_proto",
+ ":gen_ui_plugin_api_html",
":node_assets",
":readme",
":style_scss",
@@ -190,6 +191,31 @@
out_html = "docs/analysis/sql-stats"
}
+ui_plugin_api_md = "${target_gen_dir}/ui-plugin-api.md"
+
+nodejs_script("gen_ui_plugin_api_md") {
+ script = "src/gen_ui_reference.js"
+ input = "../../ui/src/public/index.ts"
+ inputs = [ input ]
+ outputs = [ ui_plugin_api_md ]
+ args = [
+ "-i",
+ rebase_path(input, root_build_dir),
+ "-o",
+ rebase_path(ui_plugin_api_md, root_build_dir),
+ ]
+}
+
+md_to_html("gen_ui_plugin_api_html") {
+ markdown = ui_plugin_api_md
+ html_template = "src/template_markdown.html"
+ deps = [
+ ":gen_toc",
+ ":gen_ui_plugin_api_md",
+ ]
+ out_html = "docs/reference/ui-plugin-api"
+}
+
# Generates a html reference for a proto
# Args:
# * proto: The path to a .proto file
diff --git a/infra/perfetto.dev/src/gen_ui_reference.js b/infra/perfetto.dev/src/gen_ui_reference.js
new file mode 100644
index 0000000..f6c2571
--- /dev/null
+++ b/infra/perfetto.dev/src/gen_ui_reference.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Generation of UI API references
+
+'use strict';
+
+const fs = require('fs');
+const path = require('path');
+const argv = require('yargs').argv
+
+const PROJECT_ROOT =
+ path.dirname(path.dirname(path.dirname(path.dirname(__filename))));
+
+function main() {
+ const inputPath = argv['i'];
+ const outputPath = argv['o'];
+ if (!inputPath) {
+ console.error('Usage: -i ui/src/public/index.ts [-o out.md]');
+ process.exit(1);
+ }
+
+ const text = fs.readFileSync(inputPath, 'UTF8');
+
+ const generatedMd = '```\n' + text + '```\n';
+
+ if (outputPath) {
+ fs.writeFileSync(outputPath, generatedMd);
+ } else {
+ console.log(generatedMd);
+ }
+ process.exit(0);
+}
+
+main();