Skip to content

Commit b3b1257

Browse files
committed
add flags
1 parent 394bfe1 commit b3b1257

File tree

9 files changed

+16498
-0
lines changed

9 files changed

+16498
-0
lines changed

8.0.1/flags.mdx

Lines changed: 9302 additions & 0 deletions
Large diffs are not rendered by default.

flags-converter.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
# Ask Bazel to dump the flags as a binary protobuf, and save in our repo for later rendering.
3+
set -o errexit -o nounset -o pipefail
4+
5+
cd "$(dirname "${BASH_SOURCE[0]}")"
6+
7+
if [ -z "${USE_BAZEL_VERSION:-}" ]; then
8+
export USE_BAZEL_VERSION=rolling
9+
OUTPUT_FILE=flags.mdx
10+
else
11+
OUTPUT_FILE=${USE_BAZEL_VERSION}/flags.mdx
12+
fi
13+
bazel help flags-as-proto | node flags_to_markdown_converter/convert.js > ${OUTPUT_FILE}

flags.mdx

Lines changed: 7008 additions & 0 deletions
Large diffs are not rendered by default.

flags/index.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: 'Flags'
3+
---
4+
5+
import { BazelFlags } from "/snippets/color-generator.jsx"
6+
7+
<BazelFlags />
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { FlagCollectionSchema } from '@buf/bazel_bazel.bufbuild_es/bazel_flags/bazel_flags_pb.js';
2+
import { fromBinary } from '@bufbuild/protobuf'
3+
4+
const writeLine = (line) => process.stdout.write(line + '\n');
5+
function escapeHtml(str) {
6+
return str
7+
.replace(/&/g, "&amp;")
8+
.replace(/</g, "&lt;")
9+
.replace(/>/g, "&gt;");
10+
}
11+
12+
// Read stdin as a stream
13+
let base64String = '';
14+
process.stdin.setEncoding('utf8');
15+
for await (const chunk of process.stdin) {
16+
base64String += chunk;
17+
}
18+
19+
const flags = fromBinary(FlagCollectionSchema, Buffer.from(base64String.trim(), 'base64'));
20+
21+
// Write header
22+
writeLine('---');
23+
writeLine('title: Bazel flags');
24+
writeLine('---');
25+
writeLine('');
26+
27+
// Write each flag
28+
for (const flag of flags.flagInfos) {
29+
const abbrev = flag.abbreviation ? `(-${flag.abbreviation})` : '';
30+
writeLine(`## --${flag.name} ${abbrev}`);
31+
writeLine('');
32+
// TODO: add history - what version of Bazel introduced this flag?
33+
// TODO: this is wrapped in a <pre> tag to avoid invalid markdown like bare html tags
34+
writeLine(escapeHtml(flag.documentation));
35+
36+
if (flag.commands.length > 0) {
37+
writeLine('');
38+
writeLine(`_May apply to commands: ${flag.commands.join(', ')}_`);
39+
}
40+
41+
writeLine('');
42+
}

flags_to_markdown_converter/package-lock.json

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
3+
"type": "module",
4+
"dependencies": {
5+
"@buf/bazel_bazel.bufbuild_es": "^2.10.1-20251112223041-697bc75dbe09.1"
6+
},
7+
"scripts": {
8+
"convert": "node convert.js"
9+
}
10+
}

reference-docs.zip

515 KB
Binary file not shown.

snippets/render_flags.jsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
export const BazelFlags = () => {
2+
// const [hue, setHue] = useState(180)
3+
// const [saturation, setSaturation] = useState(50)
4+
// const [lightness, setLightness] = useState(50)
5+
// const [colors, setColors] = useState([])
6+
7+
// useEffect(() => {
8+
// const newColors = []
9+
// for (let i = 0; i < 5; i++) {
10+
// const l = Math.max(10, Math.min(90, lightness - 20 + i * 10))
11+
// newColors.push(`hsl(${hue}, ${saturation}%, ${l}%)`)
12+
// }
13+
// setColors(newColors)
14+
// }, [hue, saturation, lightness])
15+
16+
// const copyToClipboard = (color) => {
17+
// navigator.clipboard
18+
// .writeText(color)
19+
// .then(() => {
20+
// console.log(`Copied ${color} to clipboard!`)
21+
// })
22+
// .catch((err) => {
23+
// console.error("Failed to copy: ", err)
24+
// })
25+
// }
26+
27+
return (
28+
<div className="p-4 border dark:border-zinc-950/80 rounded-xl not-prose">
29+
Flag documentation goes here.
30+
</div>
31+
)
32+
}

0 commit comments

Comments
 (0)