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

modulegen: generate md file inside internal/mkdocs #1543

Merged
merged 1 commit into from
Aug 29, 2023
Merged

modulegen: generate md file inside internal/mkdocs #1543

merged 1 commit into from
Aug 29, 2023

Conversation

mmorel-35
Copy link
Contributor

@mmorel-35 mmorel-35 commented Aug 28, 2023

What does this PR do?

This removes codeinclude function and use text/template instead of html/template.

It also moves the logic of markdown example file creation to the internal/mkdocs package.

Why is it important?

This is separating code in there domain to improve the readability and maintanability.

Related issues

Follow-ups

Remove Example functions and replace them with fields so they are calculated once.

@netlify
Copy link

netlify bot commented Aug 28, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit bec4e87
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/64eddb0ff2bdb100085ebf50
😎 Deploy Preview https://deploy-preview-1543--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mdelapenya
Copy link
Member

Mmm it's interesting but I think we broke the generator for examples:

go run . --name questdb --image "questdb/questdb:latest" --title QuestDB

It wasn't in this PR but I'm currently bisecting where the example generator was broken.

@mdelapenya
Copy link
Member

Bisecting: 0 revisions left to test after this (roughly 0 steps)
[56b41d1c4649896a352791c402f839b27f8e3af0] fix: generated code must compile (#1059)

So it seems I broke it back in April, in #1059. Will debug it and send a fix

@mmorel-35
Copy link
Contributor Author

mmorel-35 commented Aug 28, 2023

I get it ! The {{ $entrypoint }} is not used in the example_test.go.tmpl ;)

@mdelapenya
Copy link
Member

mdelapenya commented Aug 28, 2023

Could you do a local verification, and generate an example or a module, and from the root for, run mkdocs serve to verify the docs site for the new module renders properly?

@mmorel-35
Copy link
Contributor Author

Hi @mdelapenya ,
It seems to be working on this
https://deploy-preview-1543--testcontainers-go.netlify.app/examples/questdb/

I'll revert the last commit once you saw it ;)

Comment on lines 27 to 33
## Module reference

The QuestDB module exposes one entrypoint function to create the QuestDB container, and this function receives two parameters:

```golang
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*QuestDBContainer, error)
```
Copy link
Contributor Author

@mmorel-35 mmorel-35 Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdelapenya ,
This part of documentation seems to be erronous. Shall modules and example both have an entrypoint with RunContainer then ?

In that case it would be possible produce example_test.go with example_test package instead of example package.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a plan to generate an example_test.go file in every module, in which we only add Go examples code, which will be rendered in the markdown files (please see the Artemis module). An example module will not have real API, only examples.

Since we are not there yet, the example must have a private function. We could even make it simpler and name that function runContainer so we just have to lowercase the initial upper char.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see !

@mmorel-35
Copy link
Contributor Author

If the test is compliant for you I'll keep the test/template instead of the html/template.
Once the internal/module and internal/modfile are on the main branch I'll clean up this one.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mmorel-35 mmorel-35 marked this pull request as ready for review August 29, 2023 11:51
@mmorel-35 mmorel-35 requested a review from a team as a code owner August 29, 2023 11:51
Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mdelapenya mdelapenya merged commit 84962a2 into testcontainers:main Aug 29, 2023
@mdelapenya mdelapenya self-assigned this Aug 29, 2023
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Aug 29, 2023
@mmorel-35 mmorel-35 deleted the modulegen/mkdocs/template branch August 29, 2023 15:43
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Aug 29, 2023
* main:
  modulegen: generate md file inside internal/mkdocs (testcontainers#1543)
  modulegen: create internal/module and internal/modfile (testcontainers#1539)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Aug 29, 2023
* main:
  modulegen: generate md file inside internal/mkdocs (testcontainers#1543)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Aug 30, 2023
* main: (32 commits)
  fix: remove wrong example from workspace (testcontainers#1556)
  chore(deps): bump the all group in /modules/localstack with 1 update (testcontainers#1552)
  modulegen: generate code-workspace with json marshal (testcontainers#1551)
  chore(deps): bump the all group in /modules/compose with 2 updates (testcontainers#1553)
  feat: add mariadb module (testcontainers#1548)
  feat(modulegen): print out VSCode workspace file if needed (testcontainers#1549)
  modulegen: generate md file inside internal/mkdocs (testcontainers#1543)
  modulegen: create internal/module and internal/modfile (testcontainers#1539)
  [Enhancement]: add ability to set repo:tag for ContainerRequest FromDockerfile (testcontainers#1508)
  Fix module generator for examples (testcontainers#1545)
  Update pulsar.md (testcontainers#1542)
  modulegen: create internal/make (testcontainers#1537)
  chore: fix workflow (testcontainers#1538)
  chore(deps): bump the all group in /examples/cockroachdb with 1 update (testcontainers#1522)
  chore(deps): bump the all group in /examples/bigtable with 1 update (testcontainers#1534)
  chore(deps): bump the all group in /modules/localstack with 4 updates (testcontainers#1535)
  chore(deps): bump the all group in /modules/k3s with 2 updates (testcontainers#1526)
  chore(deps): bump the all group in /examples/spanner with 2 updates (testcontainers#1532)
  chore(deps): bump the all group in /examples/firestore with 1 update (testcontainers#1523)
  chore(deps): bump the all group in /modules/redis with 1 update (testcontainers#1524)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Changes that do not impact the existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants