Unverified Commit 27df48fc authored by ysaito1001's avatar ysaito1001 Committed by GitHub
Browse files

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: default avatarysaito1001 <awsaito@amazon.com>
parent fabef2bb
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -646,3 +646,9 @@ message = "The implementation `From<bytes_utils::segmented::SegmentedBuf>` 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"
+1 −14
Original line number Diff line number Diff line
@@ -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)

+4 −5
Original line number Diff line number Diff line
@@ -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<StructureShape>("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)]")
        }
    }