Skip to content

Commit

Permalink
Include Stdlib Modules in Generated ClaroDocs by Default
Browse files Browse the repository at this point in the history
This just closes the loop on seeing the definition of all non-primitive types in the one single source of truth.
  • Loading branch information
JasonSteving99 committed Oct 3, 2023
1 parent dbd4385 commit 361cfce
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/java/com/claro/module_system/clarodocs/clarodocs_rules.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load(
"//src/java/com/claro:claro_build_rules_internal.bzl",
_ClaroModuleInfo = "ClaroModuleInfo",
_CLARO_STDLIB_MODULES = "CLARO_STDLIB_MODULES",
)


Expand All @@ -17,19 +18,23 @@ def _clarodocs_impl(ctx):
for module in ctx.attr.root[_ClaroModuleInfo].info.files.to_list():
if module.extension == "claro_module":
args.add("--module", module)
for module in ctx.attr._stdlib_modules:
args.add("--module", module[_ClaroModuleInfo].info.path_to_claro_module_file)

treejs_deps = {name: path for path, name in ctx.attr.treejs_deps.items()}
treejs_deps = {name: path for path, name in ctx.attr._treejs_deps.items()}
args.add("--treejs", treejs_deps["tree.min.js"].files.to_list()[0])
args.add("--treejs_css", treejs_deps["treejs.min.css"].files.to_list()[0])

args.add("--out", ctx.outputs.out.path)

ctx.actions.run(
inputs = ctx.attr.root[_ClaroModuleInfo].info.files.to_list() + [treejs_dep.files.to_list()[0] for treejs_dep in ctx.attr.treejs_deps.keys()],
inputs = ctx.attr.root[_ClaroModuleInfo].info.files.to_list() +
[treejs_dep.files.to_list()[0] for treejs_dep in ctx.attr._treejs_deps.keys()] +
[stdlib_dep[_ClaroModuleInfo].info.path_to_claro_module_file for stdlib_dep in ctx.attr._stdlib_modules],
outputs = [ctx.outputs.out],
arguments = [args],
progress_message = "Generating ClaroDocs: " + ctx.outputs.out.path,
executable = ctx.executable.clarodocs_generator_bin,
executable = ctx.executable._clarodocs_generator_bin,
)

print("View auto-generated ClaroDocs by running the following command:\n\t$ open " + ctx.outputs.out.path)
Expand All @@ -47,13 +52,17 @@ _clarodocs_rule = rule(
doc = "The output file to write the generated ClaroDocs HTML to.",
mandatory = True,
),
"clarodocs_generator_bin": attr.label(
"_stdlib_modules": attr.label_list(
doc = "StdLib Modules that should be rendered in every ClaroDocs site since any types/procedures there will be used pervasively.",
default = _CLARO_STDLIB_MODULES.values(),
),
"_clarodocs_generator_bin": attr.label(
default = Label("//src/java/com/claro/module_system/clarodocs:clarodocs_generator"),
allow_files = True,
executable = True,
cfg = "host",
),
"treejs_deps": attr.label_keyed_string_dict(
"_treejs_deps": attr.label_keyed_string_dict(
doc = "Paths to the required treejs JS and CSS to include in generated HTML.",
allow_files = True,
default = {
Expand Down

0 comments on commit 361cfce

Please sign in to comment.