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

FunSpec (Builder): Add throwsKDoc #1934

Open
hfhbd opened this issue Jun 24, 2024 · 1 comment
Open

FunSpec (Builder): Add throwsKDoc #1934

hfhbd opened this issue Jun 24, 2024 · 1 comment

Comments

@hfhbd
Copy link
Contributor

hfhbd commented Jun 24, 2024

Is your feature request related to a problem? Please describe.
There is no nice option to add Kdoc for @throws, with automatic tag sorting and new lines handling.

Describe the solution you'd like

with(funSpecBuilder) {
  returns(BOOLEAN, "true")
  throws(ClassName("", "FooException"), "if fails")
}

Describe alternatives you've considered
You can always add the tag to the general kDoc CodeBlock, but you need to add the new lines. Also, the order feels wrong:

with(funSpecBuilder) {
  returns(BOOLEAN, "true")
  addAnnotation(AnnotationSpec.builder(ClassName("", "FooException").build())
  addKdoc("Foo summary" + "\n" + "if fails")
}
/**
 * Foo summary
 * 
 * @throws FooException if fails
 * @parameter bar the content
 * @returns true
 */
@kotlin.Throws(FooException::class)
fun foo(bar: kotlin.String): kotlin.Boolean {
}

Additional context
What about other tags, like @see, @sample etc.? Do you want to have an CodeBlock for each of them? And what about the TypeSpec.Builder?

Or should this issue just focus on FunSpec and @throws?

@Egorand
Copy link
Collaborator

Egorand commented Jun 25, 2024

Nice, I like the proposed API. Would you like to send us a PR?

I'd limit this to just @throws for now. Tags like @see and @sample should probably be added to Documentable since they apply to any Kotlin construct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants