-
Notifications
You must be signed in to change notification settings - Fork 50
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
feat: link api ref docs to examples #1550
base: main
Are you sure you want to change the base?
Conversation
A new generated diff is ready to view. |
This comment has been minimized.
This comment has been minimized.
|
A new generated diff is ready to view. |
Affected ArtifactsNo artifacts changed size |
import software.amazon.smithy.model.traits.TitleTrait | ||
|
||
/** | ||
* Maps a services SKD ID to its code examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit/grammar: service's
typo: SDK
) | ||
|
||
/** | ||
* Maps a services SKD ID to its handwritten module documentation file in the `resources` dir. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"service's SDK"
} | ||
|
||
private fun generateBoilerPlate(ctx: CodegenContext) = buildString { | ||
// Title must me "Module" followed by the exact module name or dokka won't render it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "me" -> "be"
|
||
private fun generateCodeExamplesDocs(sdkId: String) = buildString { | ||
appendLine("## Code Examples") | ||
appendLine("To see full code examples, see the $sdkId examples in the AWS Code Library. See ${codeExamples[sdkId]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"AWS Code Library" -> "AWS code example library"
https://docs.aws.amazon.com/code-library/latest/ug/what-is-code-library.html
private fun generateHandWrittenDocs(sdkId: String): String = object {} | ||
.javaClass | ||
.classLoader | ||
.getResourceAsStream("aws/sdk/kotlin/codegen/moduledocumentation/${handWritten[sdkId]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think we'd need to make a new directory for this, can't we keep the handwritten service docs in /services/
?
.getResourceAsStream("aws/sdk/kotlin/codegen/moduledocumentation/${handWritten[sdkId]}") | ||
?.bufferedReader() | ||
?.readText() | ||
?: throw Exception("Unable to read from file ${handWritten[sdkId]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throw a more specific exception here
/** | ||
* Maps a services SKD ID to its code examples | ||
*/ | ||
private val currentCodeExamplesServices = mapOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming: top-level values should be in SCREAMING_SNAKE_CASE. Also "current" is implied.
Something like CODE_EXAMPLES_SERVICES_MAP
* Maps a services SKD ID to its handwritten module documentation file in the `resources` dir. | ||
* The module documentation files MUST be markdown files. | ||
*/ | ||
private val currentHandWrittenServices = mapOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here. "current" is implied. HAND_WRITTEN_SERVICES_MAP
if (handWritten.keys.contains(sdkId)) { | ||
append( | ||
generateHandWrittenDocs(sdkId), | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want our hand-written content to appear above links to the code examples.
|
||
private fun generateCodeExamplesDocs(sdkId: String) = buildString { | ||
appendLine("## Code Examples") | ||
appendLine("To see full code examples, see the $sdkId examples in the AWS Code Library. See ${codeExamples[sdkId]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"see the $sdkId examples"
I think we should be using the value from the TitleTrait
rather than the sdkId
TitleTrait: Provides a human-readable proper noun title to services and resources.
Issue #
N/A
Description of changes
Module documentation is now handled by an integration. It handles links to code examples and hand written documentation
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.