Skip to content

FunSpec (Builder): Add throwsKDoc #1934

Open
@hfhbd

Description

@hfhbd

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions