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

[gen-readme] Allow custom templates #1794

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

mikeland73
Copy link
Contributor

Summary

This adds:

Flag that saves default template

devbox generate readme [path] --save-template

Flag that uses custom template

devbox generate readme [path] --template <custom-template>

It also:

  • defaults readme [path] to README.md
  • defaults template [path] to readme.tmpl
  • If there is readme.tmpl in root, then devbox generate readme will use it automatically.
  • Fixed missing env vars from default template

How was it tested?

devbox generate readme --save-template # generate template
vi readme.tmpl # modified template
devbox generate readme devbox.md # tested creating new readme

@mikeland73
Copy link
Contributor Author

@savil gentle ping

@savil
Copy link
Collaborator

savil commented Feb 9, 2024

@mikeland73 sorry for the delay in reviewing this. I'm a little hesitant with this design. I don't love having golang templates be the expected UX for our users.

I'm curious if there's a markdown template where one can more natively separate the auto-generated parts from the user-written parts of the markdown file...

@mikeland73
Copy link
Contributor Author

@savil we already use golang templates for plugins, and generally go applications expose go templating (e.g. Helm being a fairly prominent example) so I don't think it's unexpected or bad UX.

I think if we try to use markdown for this we will end up inventing our own templating. I would much rather re-use golang templates.

I also considered allowing injecting the readme into a specific portion of a manually created file, but that is very limiting (so limiting, that we would probably not use it ourselves). But as built, this would be useful for us right away in Axiom.

Copy link
Collaborator

@savil savil left a comment

Choose a reason for hiding this comment

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

Nice!

Also discusssed offline that we may want a follow up PR that can preserve the README content outside the gen-readme comments:

<!-- gen-readme start - generated by https://github.com/jetpack-io/devbox/ -->
...
<!-- gen-readme end -->

So, it may be nice to move those comments outside the template and into the file-content we always generate.

This would enable users to also custom-modify the README's markdown directly, without needing to deal with the golang template.

@mikeland73 mikeland73 merged commit 8cf1821 into main Feb 13, 2024
24 checks passed
@mikeland73 mikeland73 deleted the landau/gen-readme-custom-template branch February 13, 2024 01:38
Copy link

sentry-io bot commented Feb 13, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ **Generic Error: <redacted *errors.withStack>: <redacted errors.withStack>: <redacted usererr.combined> go.jetpack.io/devbox/internal/boxcli/usererr in... View Issue
  • ‼️ **Generic Error: <redacted *errors.withStack>: <redacted errors.withStack>: <redacted usererr.combined> go.jetpack.io/devbox/internal/boxcli/usererr in... View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants