cobra
cobra copied to clipboard
Move newline to inside the DisableAutoGenTag block
Fixes https://github.com/spf13/cobra/issues/2029
There are tools that care about whitespace regardless of the file type, as stated in the original issue pre-commit has a end-of-file-fixer
which looks for things like double returns. https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#end-of-file-fixer
The fix ensures the generated files only have a single return at the end of the file, it does not remove all of them.
If this is deemed not needed feel free to close it or let me know and I can.
It would be nice to add a little test to keep the output correct after this change.
Added a new assertion to the tests Test fails before the change with:
go test github.com/spf13/cobra/doc
--- FAIL: TestGenMdNoTag (0.00s)
cmd_test.go:110: Expected to not have suffix:
"\n\n"
Got: "## root\n\nRoot short description\n\n### Synopsis\n\nRoot long description\n\n```\nroot [flags]\n```\n\n### Options\n\n```\n -h, --help help for root\n -r, --rootflag string (default \"two\")\n -t, --strtwo string help message for parent flag strtwo (default \"two\")\n```\n\n### SEE ALSO\n\n* [root echo](root_echo.md)\t - Echo anything to the screen\n\n"
After fix the test passes. All other tests already pass as they don't have the double line break.