Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove doc hidden from struct fields #2854

Merged
merged 4 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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)]")
}
}

Expand Down