From 5ede15c6e1ed9480f578b8e541d92a3ce95bc53e Mon Sep 17 00:00:00 2001 From: Googler Date: Mon, 26 Jun 2023 09:19:45 -0700 Subject: [PATCH] starlark_doc_extract: match legacy Stardoc behavior for private aspect attrs and attr.license() For private aspect propagation attrs, legacy Stardoc does not emit documentation. For the deprecated attr.license() attributes, legacy Stardoc pretends the attribute is a string list, so we do the same. (Note that we have to finally fix License.repr() to return something sensible that can be parsed by BuildType.LICENSE.convert() - i.e. by License.parseLicense() - because starlark_doc_extract, unlike legacy Stardoc, correctly processes attribute default values.) PiperOrigin-RevId: 543457875 Change-Id: I5d01312e30ccdc8b1d71322f496ec8a237fa993d --- .../devtools/build/lib/packages/License.java | 28 +++++++++-- .../ModuleInfoExtractor.java | 12 ++++- .../build/lib/packages/LicenseTest.java | 46 +++++++++++++++++++ .../ModuleInfoExtractorTest.java | 19 +++++++- .../lib/starlark/StarlarkIntegrationTest.java | 2 +- 5 files changed, 98 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/packages/License.java b/src/main/java/com/google/devtools/build/lib/packages/License.java index 0f3c3bf06efdcd..4fe246a4224c8c 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/License.java +++ b/src/main/java/com/google/devtools/build/lib/packages/License.java @@ -14,6 +14,9 @@ package com.google.devtools.build.lib.packages; +import static com.google.common.collect.ImmutableList.toImmutableList; + +import com.google.common.base.Ascii; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.devtools.build.lib.cmdline.Label; @@ -27,6 +30,7 @@ import java.util.List; import java.util.Locale; import java.util.Set; +import java.util.stream.Stream; import net.starlark.java.eval.Printer; /** Support for license and distribution checking. */ @@ -35,6 +39,7 @@ public final class License implements LicenseApi { private final ImmutableSet licenseTypes; private final ImmutableSet