Skip to content

Commit 8e713a0

Browse files
committed
Expose loadStatement in template
1 parent 6015ac8 commit 8e713a0

File tree

44 files changed

+114
-39
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+114
-39
lines changed

docs/stardoc_rule.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Starlark rule for stardoc: a documentation generator tool written in Java.
88

99
<pre>
1010
load("@stardoc//stardoc:stardoc.bzl", "stardoc")
11+
1112
stardoc(<a href="#stardoc-name">name</a>, <a href="#stardoc-input">input</a>, <a href="#stardoc-out">out</a>, <a href="#stardoc-deps">deps</a>, <a href="#stardoc-format">format</a>, <a href="#stardoc-symbol_names">symbol_names</a>, <a href="#stardoc-renderer">renderer</a>, <a href="#stardoc-aspect_template">aspect_template</a>, <a href="#stardoc-func_template">func_template</a>,
1213
<a href="#stardoc-header_template">header_template</a>, <a href="#stardoc-table_of_contents_template">table_of_contents_template</a>, <a href="#stardoc-provider_template">provider_template</a>, <a href="#stardoc-rule_template">rule_template</a>,
1314
<a href="#stardoc-repository_rule_template">repository_rule_template</a>, <a href="#stardoc-module_extension_template">module_extension_template</a>, <a href="#stardoc-footer_template">footer_template</a>, <a href="#stardoc-render_main_repo_name">render_main_repo_name</a>,

src/main/java/com/google/devtools/build/stardoc/rendering/MarkdownUtil.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public static String markdownCodeSpan(String code) {
219219
public String ruleSummary(String ruleName, RuleInfo ruleInfo) {
220220
ImmutableList<String> attributeNames =
221221
ruleInfo.getAttributeList().stream().map(AttributeInfo::getName).collect(toImmutableList());
222-
return maybeLoad(ruleName) + summary(ruleName, attributeNames);
222+
return summary(ruleName, attributeNames);
223223
}
224224

225225
/**
@@ -233,7 +233,7 @@ public String providerSummary(String providerName, ProviderInfo providerInfo) {
233233
providerInfo.getFieldInfoList().stream()
234234
.map(StardocOutputProtos.ProviderFieldInfo::getName)
235235
.collect(toImmutableList());
236-
return maybeLoad(providerName) + summary(providerName, fieldNames);
236+
return summary(providerName, fieldNames);
237237
}
238238

239239
/**
@@ -247,16 +247,7 @@ public String aspectSummary(String aspectName, AspectInfo aspectInfo) {
247247
aspectInfo.getAttributeList().stream()
248248
.map(AttributeInfo::getName)
249249
.collect(toImmutableList());
250-
String aspectFlag =
251-
entrypointBzlFile
252-
// Namespaced aspects can't be referenced on the command line.
253-
.filter(unused -> !aspectName.contains("."))
254-
.map(
255-
file ->
256-
String.format(
257-
"# or on the command line:\n# --aspects=%s%%%s\n", file, aspectName))
258-
.orElse("");
259-
return maybeLoad(aspectName) + aspectFlag + summary(aspectName, attributeNames);
250+
return summary(aspectName, attributeNames);
260251
}
261252

262253
/**
@@ -270,7 +261,7 @@ public String aspectSummary(String aspectName, AspectInfo aspectInfo) {
270261
public String repositoryRuleSummary(String ruleName, RepositoryRuleInfo ruleInfo) {
271262
ImmutableList<String> attributeNames =
272263
ruleInfo.getAttributeList().stream().map(AttributeInfo::getName).collect(toImmutableList());
273-
return maybeLoad(ruleName) + summary(ruleName, attributeNames);
264+
return summary(ruleName, attributeNames);
274265
}
275266

276267
/**
@@ -319,12 +310,13 @@ public String funcSummary(StarlarkFunctionInfo funcInfo) {
319310
funcInfo.getParameterList().stream()
320311
.map(FunctionParamInfo::getName)
321312
.collect(toImmutableList());
322-
return maybeLoad(funcInfo.getFunctionName()) + summary(funcInfo.getFunctionName(), paramNames);
313+
return summary(funcInfo.getFunctionName(), paramNames);
323314
}
324315

325-
private String maybeLoad(String name) {
316+
@SuppressWarnings("unused") // Used by markdown template.
317+
public String loadStatement(String name) {
326318
return entrypointBzlFile
327-
.map(file -> String.format("load(\"%s\", \"%s\")\n", file, name.split("\\.")[0]))
319+
.map(file -> String.format("load(\"%s\", \"%s\")", file, name.split("\\.")[0]))
328320
.orElse("");
329321
}
330322

stardoc/templates/html_tables/aspect.vm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#[[##]]# ${aspectName}
44

55
<pre>
6+
${util.loadStatement($aspectName)}
7+
68
${util.aspectSummary($aspectName, $aspectInfo)}
79
</pre>
810

stardoc/templates/html_tables/func.vm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#[[##]]# ${funcInfo.functionName}
44

55
<pre>
6+
${util.loadStatement($funcInfo.functionName)}
7+
68
${util.funcSummary($funcInfo)}
79
</pre>
810

stardoc/templates/html_tables/provider.vm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#[[##]]# ${providerName}
44

55
<pre>
6+
${util.loadStatement($providerName)}
7+
68
${util.providerSummary($providerName, $providerInfo)}
79
</pre>
810

stardoc/templates/html_tables/repository_rule.vm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#[[##]]# ${ruleName}
44

55
<pre>
6+
${util.loadStatement($ruleName)}
7+
68
${util.repositoryRuleSummary($ruleName, $ruleInfo)}
79
</pre>
810
#if (!$ruleInfo.docString.isEmpty())

stardoc/templates/html_tables/rule.vm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#[[##]]# ${ruleName}
44

55
<pre>
6+
${util.loadStatement($ruleName)}
7+
68
${util.ruleSummary($ruleName, $ruleInfo)}
79
</pre>
810

stardoc/templates/markdown_tables/aspect.vm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#[[##]]# ${aspectName}
44

55
<pre>
6+
${util.loadStatement($aspectName)}
7+
68
${util.aspectSummary($aspectName, $aspectInfo)}
79
</pre>
810

stardoc/templates/markdown_tables/func.vm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#[[##]]# ${funcInfo.functionName}
44

55
<pre>
6+
${util.loadStatement($funcInfo.functionName)}
7+
68
${util.funcSummary($funcInfo)}
79
</pre>
810

stardoc/templates/markdown_tables/provider.vm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#[[##]]# ${providerName}
44

55
<pre>
6+
${util.loadStatement($providerName)}
7+
68
${util.providerSummary($providerName, $providerInfo)}
79
</pre>
810

0 commit comments

Comments
 (0)