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

Documentation generator truncates some configuration descriptions #691

Closed
rock3r opened this issue Jan 14, 2018 · 4 comments · Fixed by #692
Closed

Documentation generator truncates some configuration descriptions #691

rock3r opened this issue Jan 14, 2018 · 4 comments · Fixed by #692

Comments

@rock3r
Copy link
Contributor

rock3r commented Jan 14, 2018

If the configuration description contains a - character, the description will be truncated in the generated documentation markdown. For example, ClassNaming:

/**
 * @configuration classPattern - naming pattern (default: '[A-Z$][a-zA-Z0-9$]*')
 * @active since v1.0.0
 * @author Marvin Ramin
 */

Results in this documentation being generated:

image

I suppose this is due to how the description is identified based on the - using an hardcoded splitting index in RuleVisitor:

https://github.com/arturbosch/detekt/blob/1a22cb5bf5e4f9cce7e70f1858d4b070d6bffa75/detekt-generator/src/main/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleVisitor.kt#L95-L100

@rock3r
Copy link
Contributor Author

rock3r commented Jan 14, 2018

I suppose the configuration name is a single word so we could instead tweak it like this:

val configurationOption = it.trim()
val name = configurationOption.substringBefore(' ').trimEnd()
val defaultValue = configurationDefaultValueRegex.find(configurationOption)
		?.groupValues?.get(1)?.trim() ?: ""
val description = configurationOption.substringAfter("-")
		.replace(configurationDefaultValueRegex, "")
		.trim()
Configuration(name, description, defaultValue) 

Which seems to fix the issue and is a bit more robust:

image

Unfortunately I don't have time to do a proper PR today :( But this needs to be properly tested too.

@rock3r
Copy link
Contributor Author

rock3r commented Jan 14, 2018

CC @arturbosch @Mauin

@schalkms
Copy link
Member

Thanks. I have also updated the corresponding test case.

@lock
Copy link

lock bot commented Jun 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants