Skip to content

Commit

Permalink
Fixed the builtins exporter to include all top level Starlark symbols.
Browse files Browse the repository at this point in the history
RELNOTES: None
PiperOrigin-RevId: 207850273
  • Loading branch information
Googler authored and Copybara-Service committed Aug 8, 2018
1 parent 5106813 commit 1056e94
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/main/java/com/google/devtools/build/docgen/ApiExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.google.devtools.build.docgen.builtin.BuiltinProtos.Param;
import com.google.devtools.build.docgen.builtin.BuiltinProtos.Type;
import com.google.devtools.build.docgen.builtin.BuiltinProtos.Value;
import com.google.devtools.build.docgen.skylark.SkylarkBuiltinMethodDoc;
import com.google.devtools.build.docgen.skylark.SkylarkMethodDoc;
import com.google.devtools.build.docgen.skylark.SkylarkModuleDoc;
import com.google.devtools.build.docgen.skylark.SkylarkParamDoc;
Expand All @@ -36,6 +35,13 @@ private static void appendBuiltins(String builtinsFile) {
Builtins.Builder builtins = Builtins.newBuilder();

Map<String, SkylarkModuleDoc> allTypes = SkylarkDocumentationCollector.collectModules();

// Add all global variables and functions in Builtins as Values.
SkylarkModuleDoc topLevelModule =
allTypes.remove(SkylarkDocumentationCollector.getTopLevelModule().name());
for (SkylarkMethodDoc meth : topLevelModule.getMethods()) {
builtins.addGlobal(collectFieldInfo(meth));
}
for (Map.Entry<String, SkylarkModuleDoc> modEntry : allTypes.entrySet()) {
SkylarkModuleDoc mod = modEntry.getValue();

Expand All @@ -54,13 +60,6 @@ private static void appendBuiltins(String builtinsFile) {
value.setType(mod.getName());
value.setDoc(mod.getDocumentation());
builtins.addGlobal(value);

// Add all global variables and functions in Builtins as Values.
for (Map.Entry<String, SkylarkBuiltinMethodDoc> methEntry :
mod.getBuiltinMethods().entrySet()) {
SkylarkBuiltinMethodDoc meth = methEntry.getValue();
builtins.addGlobal(collectFieldInfo(meth));
}
}
Builtins build = builtins.build();
build.writeTo(out);
Expand Down

0 comments on commit 1056e94

Please sign in to comment.