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

feat: link api ref docs to examples #1550

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

0marperez
Copy link
Contributor

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.

@0marperez 0marperez added the no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. label Mar 12, 2025
Copy link

A new generated diff is ready to view.

This comment has been minimized.

Copy link

Copy link

A new generated diff is ready to view.

Copy link

Affected Artifacts

No artifacts changed size

@0marperez 0marperez marked this pull request as ready for review March 12, 2025 21:27
@0marperez 0marperez requested a review from a team as a code owner March 12, 2025 21:27
import software.amazon.smithy.model.traits.TitleTrait

/**
* Maps a services SKD ID to its code examples
Copy link
Member

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.
Copy link
Member

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
Copy link
Member

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]}")
Copy link
Member

@lauzadis lauzadis Mar 12, 2025

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]}")
Copy link
Member

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]}")
Copy link
Member

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(
Copy link
Member

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(
Copy link
Member

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

Comment on lines +86 to +90
if (handWritten.keys.contains(sdkId)) {
append(
generateHandWrittenDocs(sdkId),
)
}
Copy link
Member

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]}")
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants