Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include additional rule info while exporting builtins #21135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,11 @@ private static Value.Builder collectRuleInfo(RuleDocumentation rule)
// to be added separately.
callable.addParam(newParam("name", true));
for (RuleDocumentationAttribute attr : rule.getAttributes()) {
callable.addParam(newParam(attr.getAttributeName(), attr.isMandatory()));
Param.Builder param = newParam(attr.getAttributeName(), attr.isMandatory());
param.setType(attr.getTypeDesc());
param.setDefaultValue(attr.getDefaultValue());
param.setDoc(attr.getUnexpandedHtmlDocumentation());
callable.addParam(param);
}
value.setCallable(callable);
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ public String getHtmlDocumentation() throws BuildEncyclopediaDocException {
return tryExpand(htmlDocumentation);
}

/**
* Returns the unexpanded html documentation of the rule attribute.
*/
public String getUnexpandedHtmlDocumentation() {
return htmlDocumentation;
}

public String tryExpand(String html) throws BuildEncyclopediaDocException {
if (linkExpander == null) {
return html;
Expand Down Expand Up @@ -321,6 +328,24 @@ public String getSynopsis() throws BuildEncyclopediaDocException {
return sb.toString();
}

/**
* Returns a string description for this attribute's type.
*/
public String getTypeDesc() throws BuildEncyclopediaDocException {
if (type == null) {
return "";
}
String rawType = TYPE_DESC.get(type);
return rawType == null ? "" : tryExpand(rawType);
}

/**
* Returns the default value of this attribute as a Starlark snippet.
*/
public String getDefaultValue() throws BuildEncyclopediaDocException {
return defaultValue == null ? "" : defaultValue;
}

/**
* Returns true if the attribute doc is of a common attribute type.
*/
Expand Down