aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkendalllaneee <39970312+kendalllaneee@users.noreply.github.com>2019-07-26 13:24:10 -0400
committerc-parsons <cparsons@google.com>2019-07-26 13:24:10 -0400
commit2969f2f2486a67a47458b148e1631df47aa95593 (patch)
tree5a676969d1c5afe3df6752043ec5e6924f7fad79
parent12739a582549ee6f184885fffd4148a52cc0dec2 (diff)
downloadstardoc-2969f2f2486a67a47458b148e1631df47aa95593.tar.gz
Add Aspect Templates to Stardoc Rule (#214)
-rw-r--r--stardoc/BUILD1
-rw-r--r--stardoc/stardoc.bzl10
-rw-r--r--stardoc/templates/aspect.vm56
-rwxr-xr-xtest/self_doc_golden.md13
4 files changed, 76 insertions, 4 deletions
diff --git a/stardoc/BUILD b/stardoc/BUILD
index c49a67e..2c62d1c 100644
--- a/stardoc/BUILD
+++ b/stardoc/BUILD
@@ -3,6 +3,7 @@ licenses(["notice"]) # Apache 2.0
package(default_visibility = ["//visibility:public"])
exports_files([
+ "templates/aspect.vm",
"templates/header.vm",
"templates/func.vm",
"templates/provider.vm",
diff --git a/stardoc/stardoc.bzl b/stardoc/stardoc.bzl
index c511d22..4f17a0c 100644
--- a/stardoc/stardoc.bzl
+++ b/stardoc/stardoc.bzl
@@ -83,6 +83,7 @@ def _stardoc_impl(ctx):
renderer_args = ctx.actions.args()
renderer_args.add("--input=" + str(proto_file.path))
renderer_args.add("--output=" + str(ctx.outputs.out.path))
+ renderer_args.add("--aspect_template=" + str(ctx.file.aspect_template.path))
renderer_args.add("--header_template=" + str(ctx.file.header_template.path))
renderer_args.add("--func_template=" + str(ctx.file.func_template.path))
renderer_args.add("--provider_template=" + str(ctx.file.provider_template.path))
@@ -90,7 +91,7 @@ def _stardoc_impl(ctx):
renderer = ctx.executable.renderer
ctx.actions.run(
outputs = [out_file],
- inputs = [proto_file, ctx.file.header_template, ctx.file.func_template, ctx.file.provider_template, ctx.file.rule_template],
+ inputs = [proto_file, ctx.file.aspect_template, ctx.file.header_template, ctx.file.func_template, ctx.file.provider_template, ctx.file.rule_template],
executable = renderer,
arguments = [renderer_args],
mnemonic = "Renderer",
@@ -156,8 +157,13 @@ non-default semantic flags required to use the given Starlark symbols.
cfg = "host",
executable = True,
),
+ "aspect_template": attr.label(
+ doc = "The input file template for aspects generated in documentation.",
+ allow_single_file = [".vm"],
+ default = Label("//stardoc:templates/aspect.vm"),
+ ),
"header_template": attr.label(
- doc = "The input file template for header generated in documentation.",
+ doc = "The input file template for a header generated in documentation.",
allow_single_file = [".vm"],
default = Label("//stardoc:templates/header.vm"),
),
diff --git a/stardoc/templates/aspect.vm b/stardoc/templates/aspect.vm
new file mode 100644
index 0000000..35e5441
--- /dev/null
+++ b/stardoc/templates/aspect.vm
@@ -0,0 +1,56 @@
+<a name="#${aspectName}"></a>
+
+#[[##]]# ${aspectName}
+
+<pre>
+${util.aspectSummary($aspectName, $aspectInfo)}
+</pre>
+
+$aspectInfo.getDocString()
+
+#[[###]]# Aspect Attributes
+
+#if (!$aspectInfo.getAspectAttributeList().isEmpty())
+<table class="params-table">
+ <colgroup>
+ <col class="col-param" />
+ <col class="col-description" />
+ </colgroup>
+ <tbody>
+#foreach ($aspectAttribute in $aspectInfo.getAspectAttributeList())
+ <tr id="${aspectName}-${aspectAttribute}">
+ <td><code>${aspectAttribute}</code></td>
+ <td>
+ String; required.
+#end
+ </td>
+ </tr>
+#end
+ </tbody>
+</table>
+
+#[[###]]# Attributes
+
+#if (!$aspectInfo.getAttributeList().isEmpty())
+<table class="params-table">
+ <colgroup>
+ <col class="col-param" />
+ <col class="col-description" />
+ </colgroup>
+ <tbody>
+#foreach ($attribute in $aspectInfo.getAttributeList())
+ <tr id="${aspectName}-${attribute.name}">
+ <td><code>${attribute.name}</code></td>
+ <td>
+ ${util.attributeTypeString($attribute)}; ${util.mandatoryString($attribute)}
+#if (!$attribute.docString.isEmpty())
+ <p>
+ ${attribute.docString.trim()}
+ </p>
+#end
+ </td>
+ </tr>
+#end
+ </tbody>
+</table>
+#end
diff --git a/test/self_doc_golden.md b/test/self_doc_golden.md
index 937de4b..0982ae5 100755
--- a/test/self_doc_golden.md
+++ b/test/self_doc_golden.md
@@ -5,7 +5,7 @@
## stardoc
<pre>
-stardoc(<a href="#stardoc-name">name</a>, <a href="#stardoc-deps">deps</a>, <a href="#stardoc-format">format</a>, <a href="#stardoc-func_template">func_template</a>, <a href="#stardoc-header_template">header_template</a>, <a href="#stardoc-input">input</a>, <a href="#stardoc-out">out</a>, <a href="#stardoc-provider_template">provider_template</a>, <a href="#stardoc-renderer">renderer</a>, <a href="#stardoc-rule_template">rule_template</a>, <a href="#stardoc-semantic_flags">semantic_flags</a>, <a href="#stardoc-stardoc">stardoc</a>, <a href="#stardoc-symbol_names">symbol_names</a>)
+stardoc(<a href="#stardoc-name">name</a>, <a href="#stardoc-aspect_template">aspect_template</a>, <a href="#stardoc-deps">deps</a>, <a href="#stardoc-format">format</a>, <a href="#stardoc-func_template">func_template</a>, <a href="#stardoc-header_template">header_template</a>, <a href="#stardoc-input">input</a>, <a href="#stardoc-out">out</a>, <a href="#stardoc-provider_template">provider_template</a>, <a href="#stardoc-renderer">renderer</a>, <a href="#stardoc-rule_template">rule_template</a>, <a href="#stardoc-semantic_flags">semantic_flags</a>, <a href="#stardoc-stardoc">stardoc</a>, <a href="#stardoc-symbol_names">symbol_names</a>)
</pre>
@@ -31,6 +31,15 @@ This rule is an experimental replacement for the existing skylark_doc rule.
</p>
</td>
</tr>
+ <tr id="stardoc-aspect_template">
+ <td><code>aspect_template</code></td>
+ <td>
+ <a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; optional
+ <p>
+ The input file template for aspects generated in documentation.
+ </p>
+ </td>
+ </tr>
<tr id="stardoc-deps">
<td><code>deps</code></td>
<td>
@@ -63,7 +72,7 @@ This rule is an experimental replacement for the existing skylark_doc rule.
<td>
<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; optional
<p>
- The input file template for header generated in documentation.
+ The input file template for a header generated in documentation.
</p>
</td>
</tr>