From 1056e9451282a5f709d10ce473c817998874af56 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 8 Aug 2018 01:49:27 -0700 Subject: [PATCH] Fixed the builtins exporter to include all top level Starlark symbols. RELNOTES: None PiperOrigin-RevId: 207850273 --- .../google/devtools/build/docgen/ApiExporter.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/google/devtools/build/docgen/ApiExporter.java b/src/main/java/com/google/devtools/build/docgen/ApiExporter.java index b65f11b77176bc..a0124d251dfe57 100644 --- a/src/main/java/com/google/devtools/build/docgen/ApiExporter.java +++ b/src/main/java/com/google/devtools/build/docgen/ApiExporter.java @@ -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; @@ -36,6 +35,13 @@ private static void appendBuiltins(String builtinsFile) { Builtins.Builder builtins = Builtins.newBuilder(); Map 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 modEntry : allTypes.entrySet()) { SkylarkModuleDoc mod = modEntry.getValue(); @@ -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 methEntry : - mod.getBuiltinMethods().entrySet()) { - SkylarkBuiltinMethodDoc meth = methEntry.getValue(); - builtins.addGlobal(collectFieldInfo(meth)); - } } Builtins build = builtins.build(); build.writeTo(out);