Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space inserted after link in KDoc, even when not indended. #190

Closed
bethcutler opened this issue Mar 11, 2021 · 4 comments
Closed

Space inserted after link in KDoc, even when not indended. #190

bethcutler opened this issue Mar 11, 2021 · 4 comments

Comments

@bethcutler
Copy link
Contributor

In KDoc, if you want to refer to the plural of an object that has a singular name, you might write:

/** There are many [FooObject]s. */

ktfmt inserts a space after the link, which is unexpected:

/** There are many [FooObject] s. */
@bethcutler
Copy link
Contributor Author

Related, and more problematic issue:
If there is a parenthetical comment immediately following an inline object link, the space between them will be removed, unintentionally turning the link and parenthetical into a non-functional Markdown link.

/** BEFORE Please see [onNext] (which has more details) */

/** AFTER Please see [onNext](which has more details) */

@cgrushko
Copy link
Contributor

We didn't realize these are all valid KDocs.
In the meantime, a workaround for the second example is to use a letter or digit after the [link]. I know, not really a solution :)

I'll try to tackle this tomorrow. The hard part is to decide what behavior we should have. I'm leaning towards collapsing multiple spaces into a single space and not add any spaces anywhere.

@cgrushko
Copy link
Contributor

Looks like the issue is that the kdoc lexer we use (bundled with the compiler) is lacking and would report confusing data to ktfmt.

I want to look into using Dokka instead.

@SanjayVas
Copy link

Here's another example that breaks the KDoc.

/** The final produced value may have [size][ByteString.size] < [bufferSize]. **/

becomes

/** The final produced value may have [size] [ByteString.size]< [bufferSize]. **/

This not only breaks the KDoc reference, but also incorrect removes the space after it.

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

No branches or pull requests

3 participants