kopium
kopium copied to clipboard
split doc comments by sentence
The current output from --docs is one giant line and this could be better. We should split it onto several lines such that:
/// First sentence for main doc line
///
/// second sentence preceded by a blank line as is convention
/// every other sentence on its own line at this point on
struct x {}
Unfortunately, the description properties come from golang and are not necessary broken by anything (no periods to separate sentences, just a regular whitespace).
So to actually split by sentence, we would need something like https://bminixhofer.github.io/nnsplit/ to detect sentence borders. The english model they have seem quite good from the github pages link, and it's only 4MB (it could possibly be embedded).
A PR that explores this would be very much appreciated (and very likely merged if it's working well).
This proposed change would only touch main.rs, but see #19 for the initial implementation of doc comment extraction.
some splitting now happens by default in https://github.com/kube-rs/kopium/commit/c74379de0b9763599fe276484f23d263b3301bb7 if newline characters are included. They often are not though.
we get . now at the end of sentences 🙌
Yeah, the newline split is probably sufficient here. Going to close this. It's not really a problem to use the generated docs as it stands even though it will create large docstrings. People can whitelist the generated file from certain formatting / clippy checks if needed, and it's better to actually mimic the source than to try to permute it and potentially being wrong.
People can whitelist the generated file from certain formatting / clippy checks if needed, and it's better to actually mimic the source than to try to permute it and potentially being wrong.
Maybe Kopium should just emit them, it's an auto generated file anyways.