Skip to content

feat: support multiline doc strings#19

Merged
Brendan Le Glaunec (Ullaakut) merged 4 commits intomainfrom
17-fix-doc-line-breaks
May 5, 2025
Merged

feat: support multiline doc strings#19
Brendan Le Glaunec (Ullaakut) merged 4 commits intomainfrom
17-fix-doc-line-breaks

Conversation

@Ullaakut
Copy link
Copy Markdown
Member

Goal of this PR

This PR attempts to add multi line doc strings support without breaking other things, but I don't like the solution I found. I'm hoping there is a better one that does not involve calling html.EspaceString ourselves and replacing the html/template with a text/template 😄

Basically here the issue I faced, and I don't quite understand why it happens, is that when using the html/template and not escaping the return of docToString, I got an error that said unknown escape sequence. When using both htlm.EscapeString and the html/template, it ends up escaping twice of course.

So Nicholas Wiersma (@nrwiersma) I hope you have an idea for a cleaner solution 😁

Another issue is that multiline-support (especially allowing empty lines to denote paragraphs) is kind of incompatible with not including the empty newlines before directives, which we obviously don't want to include. So here I specifically discard the empty newlines to avoid that issue, but it prevents doing one of the things that Carl Kittelberger (@icedream) suggested in his ticket.

Fixes #17

How did I test it?

Unit tests

This comment was marked as outdated.

Comment thread cmd/oapi-gen/gen.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, I would add an example in an actual spec test to see what it will do.

@Ullaakut Brendan Le Glaunec (Ullaakut) merged commit 8220c73 into main May 5, 2025
14 checks passed
@Ullaakut Brendan Le Glaunec (Ullaakut) deleted the 17-fix-doc-line-breaks branch May 5, 2025 09:38
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.

Line breaks in documentation removed entirely

3 participants