Skip to content

Commit

Permalink
Add placeholder for typescript versions (#2174)
Browse files Browse the repository at this point in the history
Add placeholder for typescript versions in the smithy.io documentation.
  • Loading branch information
hpmellema authored Mar 8, 2024
1 parent 1cd622e commit 48033c8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
17 changes: 16 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,29 @@ def __load_gradle_version():
smithy_gradle_plugin_version = __load_gradle_version()
smithy_gradle_version_placeholder = "__smithy_gradle_version__"

## Find the latest version of the typescript codegen plugin from maven repo
def __load_typescript_codegen_version():
return requests.get('https://search.maven.org/solrsearch/select?q=g:"software.amazon.smithy.typescript"'
+ '+AND+a:"smithy-typescript-codegen"&wt=json').json()['response']['docs'][0]['latestVersion']

# We use the __smithy_typescript_version__ placeholder in documentation to represent
# the current gradle plugin version number. This is found and replaced
# using a source-read pre-processor so that the generated documentation
# always references the latest release of the gradle plugin
smithy_typescript_codegen_version = __load_typescript_codegen_version()
smithy_typescript_version_placeholder = "__smithy_typescript_version__"

def setup(sphinx):
sphinx.add_lexer("smithy", SmithyLexer)
sphinx.connect('source-read', source_read_handler)
print("Finding and replacing '" + smithy_version_placeholder + "' with '" + smithy_version + "'")
print("Finding and replacing '" + smithy_gradle_version_placeholder + "' with '" + smithy_gradle_plugin_version + "'")
print("Finding and replacing '" + smithy_typescript_version_placeholder + "' with '" + smithy_typescript_codegen_version + "'")


# Rewrites __smithy_version__ to the version found in ../VERSION and
# rewrites __smithy_gradle_version__ to the latest version found on Github
def source_read_handler(app, docname, source):
source[0] = source[0].replace(smithy_version_placeholder, smithy_version)
source[0] = source[0].replace(smithy_gradle_version_placeholder, smithy_gradle_plugin_version)
source[0] = source[0].replace(smithy_gradle_version_placeholder, smithy_typescript_codegen_version)
source[0] = source[0].replace(smithy_typescript_version_placeholder, smithy_typescript_codegen_version)
4 changes: 2 additions & 2 deletions docs/source-2.0/guides/gradle-plugin/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ For example, to generate a Typescript client from a Smithy model, add the
// This dependency is required in order to apply the "typescript-client-codegen"
// plugin in smithy-build.json
smithyBuild("software.amazon.smithy.typescript:smithy-typescript-codegen:0.19.0")
smithyBuild("software.amazon.smithy.typescript:smithy-typescript-codegen:__smithy_typescript_version__")
}
.. tab:: Groovy
Expand All @@ -398,7 +398,7 @@ For example, to generate a Typescript client from a Smithy model, add the
// This dependency is required in order to apply the "typescript-client-codegen"
// plugin in smithy-build.json
smithyBuild 'software.amazon.smithy.typescript:smithy-typescript-codegen:0.19.0'
smithyBuild 'software.amazon.smithy.typescript:smithy-typescript-codegen:__smithy_typescript_version__'
}
The plugin can then be configured in the ``smithy-build.json`` to generate a typescript client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ named ``@weather-service/client`` with version ``0.0.1``.
"sources": ["model"],
"maven": {
"dependencies": [
"software.amazon.smithy.typescript:smithy-aws-typescript-codegen:0.12.0"
"software.amazon.smithy.typescript:smithy-aws-typescript-codegen:__smithy_typescript_version__"
]
},
"...": "..."
Expand All @@ -58,7 +58,7 @@ named ``@weather-service/client`` with version ``0.0.1``.
:caption: build.gradle.kts
dependencies {
smithyBuild("software.amazon.smithy.typescript:smithy-aws-typescript-codegen:0.12.0")
smithyBuild("software.amazon.smithy.typescript:smithy-aws-typescript-codegen:__smithy_typescript_version__")
}
.. tab:: Groovy
Expand All @@ -67,7 +67,7 @@ named ``@weather-service/client`` with version ``0.0.1``.
:caption: build.gradle
dependencies {
smithyBuild 'software.amazon.smithy.typescript:smithy-aws-typescript-codegen:0.12.0'
smithyBuild 'software.amazon.smithy.typescript:smithy-aws-typescript-codegen:__smithy_typescript_version__'
}
.. important::
Expand Down

0 comments on commit 48033c8

Please sign in to comment.