-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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: support for embedding code snippets #22226
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for docsdocker ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -42,6 +42,8 @@ Testcontainers provide support for the most popular languages, and Docker sponso | |||
|
|||
The rest are community-driven and maintained by independent contributors. | |||
|
|||
{{< embedded language="go" source="/git-src/testcontainers-go/modules/redis/examples_test.go" id="runRedisContainer" >}} |
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.
Before merging this PR, this line is just an example on how to use it, so it should be removed from here.
# git-src clones the OSS projects in order to include | ||
# code snippets into the docs. | ||
FROM base AS git-src-oss | ||
WORKDIR /git-src | ||
RUN git clone https://github.com/testcontainers/testcontainers-go.git |
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 should use vendoring through go mod convention of hugo if we need to use external resources like we do for cli reference docs:
Also git clone without pinning to commit sha is not reproducible and can lead to regressions with unrelated changes.
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.
Indeed, this is a PoC, and during the initial discussion with the Docs team we considered having the code snippets living in the docs repo, so the upstream repo (i.e. tc-go) would have to send a PR to the docs syncing the code snippets. As a result, no git clone would be needed, and the embedded short-code would just read from a local path, ideally next to the docs page using the code.
Description
This pull request includes changes to the Dockerfile, documentation, and template files to support embedding code snippets from the
testcontainers-go
repository into the documentation. The most important changes include adding a new build stage to clone thetestcontainers-go
repository, updating the documentation to include an embedded code snippet, and modifying the shortcode template to handle these embedded snippets.Dockerfile changes:
git-src-oss
to clone thetestcontainers-go
repository and copy it to the project directory ([DockerfileR36-R45](https://github.com/docker/docs/pull/22226/files#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557R36-R45)
).Documentation changes:
content/manuals/testcontainers.md
to include an embedded Go code snippet from thetestcontainers-go
repository ([content/manuals/testcontainers.mdR45-R46](https://github.com/docker/docs/pull/22226/files#diff-7905b168f0bee5db6711b541f42c48f5d0901c8cdc17f323e3c1725a5445a3dcR45-R46)
).IMPORTANT: this change is a demonstration on how to use the embedding shortcode.
Template changes:
layouts/shortcodes/embedded.html
to handle embedded code snippets, including logic to identify and extract specific code sections based on custom tags ([layouts/shortcodes/embedded.htmlR1-R65](https://github.com/docker/docs/pull/22226/files#diff-dc256c151d3b9c325236dc0c38d0ef5155ce617bb93d44b669b7641a00fbe42aR1-R65)
).The tag is using the following format:
// START $id
// END $id
Exception: for testcontainers-go, where this mechanism already exists, we are using different start/end tags:
// $id {
// }
Reviews