From e7ebb7e68d35ae090d91fe6b4c92c1c831421faa Mon Sep 17 00:00:00 2001 From: laurentlb Date: Mon, 26 Nov 2018 09:59:06 -0800 Subject: [PATCH] Skydoc: do not show documentation of loaded symbols Default behavior of Bazel will change soon (--incompatible_no_transitive_loads) #5636 RELNOTES: None. PiperOrigin-RevId: 222841756 --- .../devtools/build/skydoc/SkydocMain.java | 2 +- .../devtools/build/skydoc/SkydocTest.java | 10 +-- .../devtools/build/skydoc/diff_test_runner.sh | 2 +- .../testdata/multiple_files_test/golden.txt | 73 ------------------- 4 files changed, 4 insertions(+), 83 deletions(-) diff --git a/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java b/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java index b86d1d086c5e6a..f29843015554d8 100644 --- a/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java +++ b/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java @@ -330,7 +330,7 @@ public Environment eval( ImmutableSet.Builder handledRuleDefinitions = ImmutableSet.builder(); // Sort the bindings so their ordering is deterministic. - TreeMap sortedBindings = new TreeMap<>(env.getGlobals().getBindings()); + TreeMap sortedBindings = new TreeMap<>(env.getGlobals().getExportedBindings()); for (Entry envEntry : sortedBindings.entrySet()) { if (ruleFunctions.containsKey(envEntry.getValue())) { diff --git a/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java b/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java index e89f49ac25e56c..5c518341f6269b 100644 --- a/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java +++ b/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java @@ -210,11 +210,8 @@ public void testRulesAcrossMultipleFiles() throws Exception { Map ruleInfoMap = ruleInfoMapBuilder.build(); - // dep_rule is available here, even though it was not defined in main.bzl, because it is - // imported in main.bzl. Thus, it's a top-level symbol in main.bzl. - assertThat(ruleInfoMap.keySet()).containsExactly("main_rule", "dep_rule"); + assertThat(ruleInfoMap.keySet()).containsExactly("main_rule"); assertThat(ruleInfoMap.get("main_rule").getDocString()).isEqualTo("Main rule"); - assertThat(ruleInfoMap.get("dep_rule").getDocString()).isEqualTo("Dep rule"); } @Test @@ -265,11 +262,8 @@ public void testRulesAcrossRepository() throws Exception { Map ruleInfoMap = ruleInfoMapBuilder.build(); - // dep_rule is available here, even though it was not defined in main.bzl, because it is - // imported in main.bzl. Thus, it's a top-level symbol in main.bzl. - assertThat(ruleInfoMap.keySet()).containsExactly("main_rule", "dep_rule"); + assertThat(ruleInfoMap.keySet()).containsExactly("main_rule"); assertThat(ruleInfoMap.get("main_rule").getDocString()).isEqualTo("Main rule"); - assertThat(ruleInfoMap.get("dep_rule").getDocString()).isEqualTo("Dep rule"); } @Test diff --git a/src/test/java/com/google/devtools/build/skydoc/diff_test_runner.sh b/src/test/java/com/google/devtools/build/skydoc/diff_test_runner.sh index 0f4fa478b90ed8..c7f11ad75bd936 100755 --- a/src/test/java/com/google/devtools/build/skydoc/diff_test_runner.sh +++ b/src/test/java/com/google/devtools/build/skydoc/diff_test_runner.sh @@ -25,7 +25,7 @@ shift 1 golden_file=$1 shift 1 -DIFF="$(diff ${actual_file} ${golden_file})" +DIFF="$(diff -u ${actual_file} ${golden_file})" if [ "$DIFF" != "" ] then diff --git a/src/test/java/com/google/devtools/build/skydoc/testdata/multiple_files_test/golden.txt b/src/test/java/com/google/devtools/build/skydoc/testdata/multiple_files_test/golden.txt index 0207452e71e0b7..d047f17e6f68df 100644 --- a/src/test/java/com/google/devtools/build/skydoc/testdata/multiple_files_test/golden.txt +++ b/src/test/java/com/google/devtools/build/skydoc/testdata/multiple_files_test/golden.txt @@ -124,79 +124,6 @@ This is yet another rule -## my_rule_impl - -
-my_rule_impl(ctx)
-
- - - -### Parameters - - - - - - - - name, srcs, beef) - - -A pretty cool function. You should call it. - -### Parameters - -
- - - - - - - - - - -

- Your opinion on beef. -

- - - -
srcs - optional. default is [] -

- What sources you want cool stuff to happen to. -

-
- - ## top_fun