Skip to content

support extracting nu code snippets into standalone .nu files for better downstream trackability#2162

Merged
hustcer merged 1 commit into
nushell:mainfrom
orthonormalremy:cookbook-direnv-split
May 21, 2026
Merged

support extracting nu code snippets into standalone .nu files for better downstream trackability#2162
hustcer merged 1 commit into
nushell:mainfrom
orthonormalremy:cookbook-direnv-split

Conversation

@orthonormalremy
Copy link
Copy Markdown
Contributor

@orthonormalremy orthonormalremy commented May 12, 2026

There are many useful recipes that exist in the cookbook and there is no way to track them directly in a script-friendly way (markdown file parsing is not ideal obviously).

This PR adds support for useful standalone code snippets (e.g. snippets that someone might want to put in their autoload/ dir) to be extracted out into their own .nu files so it can remain the source of truth for the cookbook while also being programmatically fetch-able.

Note: this PR uses the lightweight @vuepress/plugin-markdown-include plugin which is an official VuePress plugin from the same @vuepress/* family already used in this repo

@orthonormalremy
Copy link
Copy Markdown
Contributor Author

orthonormalremy commented May 18, 2026

the people yearn for programmatically trackable cookbook recipes

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 18, 2026

what people?

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 18, 2026

i'm ok with this, although there are more scripts than the few you have in this pr probably. @hustcer usually makes most decisions on this repo so i'll leave it up to him.

@orthonormalremy
Copy link
Copy Markdown
Contributor Author

what people?

just a meme format lol (see: "my people yearn for freedom")

@hustcer
Copy link
Copy Markdown
Contributor

hustcer commented May 21, 2026

Thanks, I’m fine with this change.

@hustcer hustcer merged commit d283b10 into nushell:main May 21, 2026
2 checks passed
@NotTheDr01ds
Copy link
Copy Markdown
Contributor

NotTheDr01ds commented May 22, 2026

Apologies for missing this, but ... We used to do this, and we decided to remove snippets. It was a lot of work to remove them across all of the files and translations, and I really don't want to re-introduce this "feature."

Translations being one of the bigger issues. I know that this is limited to the Cookbook at the moment, and I don't think we have any Cookbook translations.

It's probably my fault for never finishing up #1487 and adding this guidance to Contributing.md ;-)

Also note that the support is already there (see 61adb5c), so no need to add a new plugin for it, I don't think?

But regardless, I'd like to consider moving these back to being embedded in the md files themselves. It's far easier on maintainers to edit all in one doc. The disadvantages of this change, IMHO, far outweigh any advantages. The "Copy" button on each code block is what most users will use to make use of the snippet anyway.

Do we really foresee people cloning the entire doc repository just to be able to copy over a few files? I seriously doubt it.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 22, 2026

ya, i forgot that i agreed with @NotTheDr01ds. handling those extra files is a pain. here's the revert #2171

@orthonormalremy
Copy link
Copy Markdown
Contributor Author

Ah sorry I tired to find some prior art around this but I should've looked harder, no worries!

@NotTheDr01ds
Copy link
Copy Markdown
Contributor

NotTheDr01ds commented May 22, 2026

@orthonormalremy Not a problem at all!

Again, I consider this my fault for not catching your PR earlier (as well as for not updating the Contribution Guide as I had promised). I really do appreciate your attempt at improving Nushell here! Looking forward to future suggestions!

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.

4 participants