-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rules_openapi: add rule to build HTML doc (#4338)
Add openapi_build_doc rule to build the API documentation as zero-dependency HTML file. This replaces separate genrules in the build files for the individual tools. These had all been using the `redoc-cli` command which is deprecated (in favor of redocly/cli) and had been creating broken HTML files since #4323. Fix the link in the dummy index.html page from the private/mgmtapi package, used when not bundling the generated documentation page, to point to openapi.json (not spec.json). Drop the yarn dependency on `redoc-cli` and update all dependencies.
- Loading branch information
Showing
16 changed files
with
248 additions
and
1,292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
load("@bazel_skylib//lib:shell.bzl", "shell") | ||
|
||
def _openapi_build_docs_impl(ctx): | ||
cmd = "{bin} build-docs --output {out} {src}".format( | ||
bin = ctx.executable._openapi_cli.path, | ||
out = shell.quote(ctx.outputs.out.path), | ||
src = shell.quote(ctx.file.src.path), | ||
) | ||
|
||
ctx.actions.run_shell( | ||
outputs = [ctx.outputs.out], | ||
inputs = [ctx.file.src], | ||
tools = [ctx.executable._openapi_cli], | ||
command = cmd, | ||
mnemonic = "OpenAPIBuildDocs", | ||
use_default_shell_env = True, | ||
) | ||
return [DefaultInfo( | ||
files = depset([ctx.outputs.out]), | ||
)] | ||
|
||
openapi_build_docs = rule( | ||
implementation = _openapi_build_docs_impl, | ||
doc = "This rule can be used to create API documentation as a single, zero-dependency HTML file.", | ||
attrs = { | ||
"src": attr.label( | ||
doc = "The API definition file", | ||
allow_single_file = [".yml"], | ||
), | ||
"out": attr.output( | ||
doc = "The output HTML file generated by this rule", | ||
), | ||
"_openapi_cli": attr.label( | ||
default = "@rules_openapi_npm//@redocly/cli/bin:openapi", | ||
executable = True, | ||
cfg = "target", | ||
), | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.