Skip to content

Commit

Permalink
Writer fixes (#1469)
Browse files Browse the repository at this point in the history
* Fixes for RustWriter bugs #1465 & #1459

* Fix behavior causing extra newlines in docs
  • Loading branch information
rcoh authored Jun 15, 2022
1 parent b45c1f0 commit 898dc70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,16 @@ fun RustWriter.containerDocs(text: String, vararg args: Any): RustWriter {
* - Empty newlines are removed
*/
fun <T : AbstractCodeWriter<T>> T.docs(text: String, vararg args: Any, newlinePrefix: String = "/// "): T {
// Because writing docs relies on the newline prefix, ensure that there was a new line written
// before we write the docs
this.ensureNewline()
pushState()
setNewlinePrefix(newlinePrefix)
val cleaned = text.lines()
.joinToString("\n") {
// Rustdoc warns on tabs in documentation
it.trimStart().replace("\t", " ")
}
// Because writing docs relies on the newline prefix, ensure that there was a new line written
// before we write the docs
this.ensureNewline()
write(cleaned, *args)
popState()
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class FluentClientGenerator(
Fluent builders are created through the [`Client`](crate::client::Client) by calling
one if its operation methods. After parameters are set using the builder methods,
the `send` method can be called to initiate the request.
""",
""".trim(),
newlinePrefix = "//! "
)
operations.forEach { operation ->
Expand Down

0 comments on commit 898dc70

Please sign in to comment.