From 27df48fcc0fcf7a0c33700d9f99eff68565d9a48 Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Wed, 19 Jul 2023 10:02:49 -0500 Subject: [PATCH] Remove doc hidden from struct fields (#2854) ## Motivation and Context Removes `#[doc(hidden)]` from struct fields. ## Testing - [ ] Passed tests in CI ## Checklist - [x] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: ysaito1001 --- CHANGELOG.next.toml | 6 ++++++ .../codegen/core/smithy/SymbolMetadataProvider.kt | 15 +-------------- .../smithy/generators/StructureGeneratorTest.kt | 9 ++++----- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index eb59a24af5..7a753f4790 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -646,3 +646,9 @@ message = "The implementation `From` for ` references = ["smithy-rs#2848"] meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" } author = "ysaito1001" + +[[smithy-rs]] +message = "Public fields in structs are no longer marked as `#[doc(hidden)]`, and they are now visible." +references = ["smithy-rs#2854"] +meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" } +author = "ysaito1001" diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt index d78818601c..964f2046dd 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/SymbolMetadataProvider.kt @@ -20,7 +20,6 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.SensitiveTrait -import software.amazon.smithy.model.traits.StreamingTrait import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata import software.amazon.smithy.rust.codegen.core.rustlang.Visibility @@ -99,19 +98,7 @@ class BaseSymbolMetadataProvider( override fun memberMeta(memberShape: MemberShape): RustMetadata = when (val container = model.expectShape(memberShape.container)) { - is StructureShape -> { - // TODO(https://github.com/awslabs/smithy-rs/issues/943): Once streaming accessors are usable, - // then also make streaming members `#[doc(hidden)]` - if (memberShape.getMemberTrait(model, StreamingTrait::class.java).isPresent) { - RustMetadata(visibility = Visibility.PUBLIC) - } else { - RustMetadata( - // At some point, visibility _may_ be made `PRIVATE`, so make these `#[doc(hidden)]` for now. - visibility = Visibility.PUBLIC, - additionalAttributes = listOf(Attribute.DocHidden), - ) - } - } + is StructureShape -> RustMetadata(visibility = Visibility.PUBLIC) is UnionShape, is CollectionShape, is MapShape -> RustMetadata(visibility = Visibility.PUBLIC) diff --git a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGeneratorTest.kt b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGeneratorTest.kt index f765587300..77932ddfac 100644 --- a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGeneratorTest.kt +++ b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGeneratorTest.kt @@ -7,7 +7,6 @@ package software.amazon.smithy.rust.codegen.core.smithy.generators import io.kotest.matchers.string.shouldContainInOrder import io.kotest.matchers.string.shouldNotContain -import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.core.rustlang.Attribute @@ -401,7 +400,7 @@ class StructureGeneratorTest { } @Test - fun `non-streaming fields are doc-hidden`() { + fun `fields are NOT doc-hidden`() { val model = """ namespace com.test structure MyStruct { @@ -415,9 +414,9 @@ class StructureGeneratorTest { val struct = model.lookup("com.test#MyStruct") val provider = testSymbolProvider(model, rustReservedWordConfig = rustReservedWordConfig) - RustWriter.forModule("test").let { - StructureGenerator(model, provider, it, struct, emptyList()).render() - assertEquals(6, it.toString().split("#[doc(hidden)]").size, "there should be 5 doc-hiddens") + RustWriter.forModule("test").let { writer -> + StructureGenerator(model, provider, writer, struct, emptyList()).render() + writer.toString().shouldNotContain("#[doc(hidden)]") } }