mirror of https://github.com/smithy-lang/smithy-rs
fix docgen link (#3815)
_By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
This commit is contained in:
parent
ed7f7e69bb
commit
4d889f7f1d
|
@ -73,7 +73,7 @@ object AwsDocs {
|
||||||
|
|
||||||
Occasionally, SDKs may have additional service-specific values that can be set on the [`Config`] that
|
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.
|
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:
|
done as follows:
|
||||||
|
|
||||||
```rust,no_run
|
```rust,no_run
|
||||||
|
|
|
@ -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.conditionalBlockTemplate
|
||||||
import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape
|
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.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.documentShape
|
||||||
import software.amazon.smithy.rust.codegen.core.rustlang.map
|
import software.amazon.smithy.rust.codegen.core.rustlang.map
|
||||||
import software.amazon.smithy.rust.codegen.core.rustlang.render
|
import software.amazon.smithy.rust.codegen.core.rustlang.render
|
||||||
|
@ -91,7 +92,7 @@ fun MemberShape.enforceRequired(
|
||||||
}
|
}
|
||||||
val shape = this
|
val shape = this
|
||||||
val isOptional = codegenContext.symbolProvider.toSymbol(shape).isOptional()
|
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 =
|
val error =
|
||||||
OperationBuildError(codegenContext.runtimeConfig).missingField(
|
OperationBuildError(codegenContext.runtimeConfig).missingField(
|
||||||
codegenContext.symbolProvider.toMemberName(shape), "A required field was not set",
|
codegenContext.symbolProvider.toMemberName(shape), "A required field was not set",
|
||||||
|
@ -100,10 +101,7 @@ fun MemberShape.enforceRequired(
|
||||||
when (codegenContext.model.expectShape(this.target)) {
|
when (codegenContext.model.expectShape(this.target)) {
|
||||||
is StringShape ->
|
is StringShape ->
|
||||||
writable {
|
writable {
|
||||||
rustTemplate(
|
rust("#T.filter(|f|!AsRef::<str>::as_ref(f).trim().is_empty())", field)
|
||||||
"#{field}.filter(|f|!AsRef::<str>::as_ref(f).trim().is_empty())",
|
|
||||||
"field" to field,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> field
|
else -> field
|
||||||
|
@ -221,7 +219,11 @@ class BuilderGenerator(
|
||||||
implBlockWriter.docs("This method will fail if any of the following fields are not set:")
|
implBlockWriter.docs("This method will fail if any of the following fields are not set:")
|
||||||
trulyRequiredMembers.forEach {
|
trulyRequiredMembers.forEach {
|
||||||
val memberName = symbolProvider.toMemberName(it)
|
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) {
|
implBlockWriter.rustBlockTemplate("pub fn build(self) -> $returnType", *preludeScope) {
|
||||||
|
|
Loading…
Reference in New Issue