Skip to content

Commit

Permalink
fix docgen link (#3815)
Browse files Browse the repository at this point in the history
_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
Velfi authored Sep 5, 2024
1 parent ed7f7e6 commit 4d889f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ object AwsDocs {
Occasionally, SDKs may have additional service-specific values that can be set on the [`Config`] that
is absent from [`SdkConfig`], or slightly different settings for a specific client may be desired.
The [`Builder`] struct implements `From<&SdkConfig>`, so setting these specific settings can be
The [`Builder`](crate::config::Builder) struct implements `From<&SdkConfig>`, so setting these specific settings can be
done as follows:
```rust,no_run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.asOptional
import software.amazon.smithy.rust.codegen.core.rustlang.conditionalBlockTemplate
import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape
import software.amazon.smithy.rust.codegen.core.rustlang.docs
import software.amazon.smithy.rust.codegen.core.rustlang.docsTemplate
import software.amazon.smithy.rust.codegen.core.rustlang.documentShape
import software.amazon.smithy.rust.codegen.core.rustlang.map
import software.amazon.smithy.rust.codegen.core.rustlang.render
Expand Down Expand Up @@ -91,7 +92,7 @@ fun MemberShape.enforceRequired(
}
val shape = this
val isOptional = codegenContext.symbolProvider.toSymbol(shape).isOptional()
val field = field.letIf(!isOptional) { field.map { rust("Some(#T)", it) } }
val field = field.letIf(!isOptional) { it.map { t -> rust("Some(#T)", t) } }
val error =
OperationBuildError(codegenContext.runtimeConfig).missingField(
codegenContext.symbolProvider.toMemberName(shape), "A required field was not set",
Expand All @@ -100,10 +101,7 @@ fun MemberShape.enforceRequired(
when (codegenContext.model.expectShape(this.target)) {
is StringShape ->
writable {
rustTemplate(
"#{field}.filter(|f|!AsRef::<str>::as_ref(f).trim().is_empty())",
"field" to field,
)
rust("#T.filter(|f|!AsRef::<str>::as_ref(f).trim().is_empty())", field)
}

else -> field
Expand Down Expand Up @@ -221,7 +219,11 @@ class BuilderGenerator(
implBlockWriter.docs("This method will fail if any of the following fields are not set:")
trulyRequiredMembers.forEach {
val memberName = symbolProvider.toMemberName(it)
implBlockWriter.docs("- [`$memberName`](#T::$memberName)", symbolProvider.symbolForBuilder(shape))
implBlockWriter.docsTemplate(
// We have to remove the `r##` prefix in the path b/c Rustdoc doesn't support it.
"- [`$memberName`](#{struct}::${memberName.removePrefix("r##")})",
"struct" to symbolProvider.symbolForBuilder(shape),
)
}
}
implBlockWriter.rustBlockTemplate("pub fn build(self) -> $returnType", *preludeScope) {
Expand Down

0 comments on commit 4d889f7

Please sign in to comment.