diff options
author | Yifan Hong <elsk@google.com> | 2023-12-13 01:55:23 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-12-13 01:55:23 +0000 |
commit | c8d5e8315176c240919e77ce336ec6c916d63184 (patch) | |
tree | 6ef7bd86804eeb65cd4b180b666c43a09d6c6a1b | |
parent | 024cd9ef4e4648ba32eca318043b289753769f32 (diff) | |
parent | 950baad5d60e2d28e7fbaab9ea1707e4678e3564 (diff) | |
download | bazel_common_rules-c8d5e8315176c240919e77ce336ec6c916d63184.tar.gz |
docs: fix title. am: d7a8224156 am: ec24bf1e9f am: 950baad5d6
Original change: https://android-review.googlesource.com/c/platform/build/bazel_common_rules/+/2865913
Change-Id: I28b86f00d545c4e5abe0b505c271c19b9331a1b7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | docs/docs.bzl | 34 | ||||
-rwxr-xr-x | docs/insert_resource.py | 7 |
2 files changed, 21 insertions, 20 deletions
diff --git a/docs/docs.bzl b/docs/docs.bzl index 50097d2..cafc19d 100644 --- a/docs/docs.bzl +++ b/docs/docs.bzl @@ -76,23 +76,21 @@ def docs( srcs = all_deps, ) - all_markdown_files = [] + # Key: label to bzl. Value: label to markdown. + bzl_md = {} + for src in srcs: + stardoc_target_name = name + "-" + _sanitize_label_as_filename(src) stardoc( - name = name + "-" + _sanitize_label_as_filename(src), - out = name + "/" + _sanitize_label_as_filename(src), + name = stardoc_target_name, + out = name + "/" + _sanitize_label_as_filename(src) + ".md", input = src, deps = [":" + name + "_deps"], func_template = func_template, provider_template = provider_template, rule_template = rule_template, ) - all_markdown_files.append((name + "/" + _sanitize_label_as_filename(src), src)) - - native.filegroup( - name = name + "_markdown_files", - srcs = [target for target, _ in all_markdown_files], - ) + bzl_md[src] = stardoc_target_name default_file_cmd = """touch $@ && """ for src in srcs: @@ -118,18 +116,20 @@ def docs( srcs = [ "//build/bazel_common_rules/docs:index.html", ":{name}_default_file.html.frag".format(name = name), - ":{name}_markdown_files".format(name = name), - ], + ] + bzl_md.keys() + bzl_md.values(), outs = [ name + "/root/index.html", ], cmd = """ - $(location //build/bazel_common_rules/docs:insert_resource.py) \ - --infile $(location //build/bazel_common_rules/docs:index.html) \ - --outfile $(location {name}/root/index.html) \ - $(location :{name}_default_file.html.frag) \ - $(locations :{name}_markdown_files) - """.format(name = name), + $(location //build/bazel_common_rules/docs:insert_resource.py) \\ + --infile $(location //build/bazel_common_rules/docs:index.html) \\ + --outfile $(location {name}/root/index.html) \\ + default_file.html.frag:$(location :{name}_default_file.html.frag) \\ + {bzl_md} + """.format( + name = name, + bzl_md = " ".join(["$(location {}):$(location {})".format(bzl, md) for bzl, md in bzl_md.items()]), + ), tools = [ "//build/bazel_common_rules/docs:insert_resource.py", ], diff --git a/docs/insert_resource.py b/docs/insert_resource.py index 02260c2..09c9ef1 100755 --- a/docs/insert_resource.py +++ b/docs/insert_resource.py @@ -14,9 +14,10 @@ def main(infile, outfile, resources): magic = inlines.index(MAGIC) outlines = inlines[:magic] - for resource_name in resources: + for resource in resources: + resource_name, path = resource.rsplit(":", 1) outlines.append('<div hidden class="embedded_resource" id="{}-res">\n'.format(os.path.basename(resource_name))) - with open(resource_name, 'rb') as resource: + with open(path, 'rb') as resource: # Resources need to be base64 encoded. For example, the resource file may be in # markdown format: # `<name>` @@ -35,6 +36,6 @@ if __name__ == '__main__': parser = argparse.ArgumentParser(description=main.__doc__) parser.add_argument("--infile", required=True, type=argparse.FileType('r'), help="input file") parser.add_argument("--outfile", required=True, type=argparse.FileType('w'), help="output file") - parser.add_argument("resources", nargs='+', help="resource files") + parser.add_argument("resources", metavar="NAME:PATH", nargs='+', help="resource files") args = parser.parse_args() main(**vars(args)) |