Add Aspect Templates to Stardoc Rule (#214)


diff --git a/stardoc/BUILD b/stardoc/BUILD
index c49a67e..2c62d1c 100644
--- a/stardoc/BUILD
+++ b/stardoc/BUILD
@@ -3,6 +3,7 @@
 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 @@
         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 @@
         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 @@
             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 @@
         </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 @@
       <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>