Skip to content
New issue

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

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

Already on GitHub? # to your account

Imports only used in docs #46

Closed
gabrielittner opened this issue May 29, 2017 · 7 comments
Closed

Imports only used in docs #46

gabrielittner opened this issue May 29, 2017 · 7 comments

Comments

@gabrielittner
Copy link
Contributor

When an import is only used in square brackets in the docs it will get removed by ktlint. For example:

package com.example

import android.provider.CalendarContract.Colors

/**
 * [Colors]
 */
class Foo

will become:

package com.example

/**
 * [Colors]
 */
class Foo

IntelliJ itself shows the import as used (or not as unused).

@shyiko
Copy link
Collaborator

shyiko commented May 29, 2017

@gabrielittner Thank you for the ticket! I'll take care of it.

@shyiko
Copy link
Collaborator

shyiko commented May 29, 2017

On a second thought, it might be what we want. The thing is Foo class is not technically using Colors. It does reference it the docs but that doesn't mean that Foo has hard (compile) dependency on Colors. Kotlin supports alternatives that don't require imports:

[Colors](android.provider.CalendarContract.Colors)

[android.provider.CalendarContract.Colors]

What do think?

@gabrielittner
Copy link
Contributor Author

gabrielittner commented May 29, 2017

I'm not sure what's the best solution here. In the case where I've run across it, the imported class is used a ton in the docs and using it without import adds a lot of noise.
If you decide to keep removing the import it would be nice to at least get a warning or something, because without the import all the links will be broken.

@vRallev
Copy link

vRallev commented May 29, 2017

I'm running into the same issue and I'd prefer if the import would be allowed in this case for the same reason. It would add a lot of noise to reference the full path everywhere.

@shyiko
Copy link
Collaborator

shyiko commented May 29, 2017

@gabrielittner @vRallev fair enough. Fixed in 0.7.1 (Maven Central sync might take up to ~25 minutes). 🎉

@shyiko shyiko closed this as completed May 29, 2017
@vRallev
Copy link

vRallev commented May 29, 2017

The new version works nicely. Thanks!

@gabrielittner
Copy link
Contributor Author

Also working here. Thank you

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants