Skip to content

Generate CLI reference #3083

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

Merged
merged 2 commits into from
Apr 2, 2025
Merged

Conversation

itowlson
Copy link
Collaborator

@itowlson itowlson commented Apr 1, 2025

An experiment in support of spinframework/spin-docs#72

cc @kate-goldenring

e.g. spin maintenance generate-reference -o REFME.md

Copy link
Contributor

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this @itowlson. Can you also commit the initial CLI.md?

Cargo.toml Outdated
@@ -19,6 +19,7 @@ anyhow = { workspace = true }
async-trait = { workspace = true }
bytes = { workspace = true }
clap = { version = "3.2.24", features = ["derive", "env"] }
clap-markdown = { git = "https://github.com/itowlson/clap-markdown", branch = "clap-v3-compat" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move the fork to spinframework's repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure what to do with the fork. It can't live in my personal account I agree. But it feels awkward to have something so disconnected from Spin and so specifically about Clap in spinframework. Maybe that's just me. We could make it a crate in the Spin project, but then we would lose traceability to the original repo and author, which feels rude.

Anyway I'm happy to follow whatever you and other folks more steeped on open-source etiquette advise!

Copy link
Contributor

Choose a reason for hiding this comment

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

That is a good point. I think we can leave it as a fork on your account but can you add a comment as to why we have a fork and the condition of leaving the fork, which seems to be if/when we move to clap 3?

@itowlson itowlson force-pushed the generate-cli-reference branch 4 times, most recently from 1beb547 to 2029539 Compare April 1, 2025 23:14
@itowlson
Copy link
Collaborator Author

itowlson commented Apr 1, 2025

@kate-goldenring I wasn't planning to commit the generated Markdown. I thought that was going to go to the docs site? I don't want to get into a position where anyone working on the CLI has to remember to regenerate the Markdown and commit the changes - I was more imagining this command running in CI as part of a release (and hopefully PRing to the docs repo so that all we need to do is mash the approve and merge button).

Signed-off-by: itowlson <[email protected]>
@itowlson itowlson force-pushed the generate-cli-reference branch from 2029539 to 4dfec70 Compare April 2, 2025 01:25
@itowlson
Copy link
Collaborator Author

itowlson commented Apr 2, 2025

I tweaked this so it defaults to writing to stdout. My thought is that we can have a GH workflow (or step in the release workflow) that does something like:

  • cat the Bartholomew frontmatter of the CLI reference page to a file e.g. cli-reference.md
  • spin maintenance generate-reference >>cli-reference.md
  • PR cli-reference.md to the appropriate place in spin-docs

(We can't use MarkdownOptions::title() to set the front matter as it always prepends a # heading marker. Although I suppose I could change that too. Why not go wild.)

I think we've done something like the PR thing before, but I'm a bit lost on the details, sorry. (ETA: Rajat's plugin PR creator uses a Spin app in the cloud to create the PR.)

I did it manually locally and the results look okay, a bit doubled up on the top heading, and the code block on the subheads isn't lovely, but perfectly acceptable for compliance purposes I think.

image

image

And in dark mode:

image

@kate-goldenring
Copy link
Contributor

@itowlson this all looks great. IMO, i think we can move this to ready for review and then integrate it with the docs CI as you mention

@itowlson itowlson marked this pull request as ready for review April 2, 2025 21:04
@itowlson
Copy link
Collaborator Author

itowlson commented Apr 2, 2025

After discussion with @kate-goldenring I've moved the forked third-party code into the project (rather than having a separate repo unrelated to the Spin project). I've tried to provide appropriate attribution and credit, and have reproduced the licences and copyright statements. I've done this as a separate commit so we can easily unpick the change if I've done it wrong or I was wrong to do it! Thoughts welcome.

@itowlson itowlson force-pushed the generate-cli-reference branch from bc18647 to 58de6cc Compare April 2, 2025 21:39
@itowlson itowlson requested a review from kate-goldenring April 2, 2025 21:40
@itowlson itowlson enabled auto-merge April 2, 2025 21:44
@itowlson itowlson merged commit 792e78a into spinframework:main Apr 2, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants