Skip to content

Commit

Permalink
#1287 Fixing some generation
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Jun 5, 2024
1 parent da83ee3 commit bff8928
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@ import net.nemerosa.ontrack.model.events.Event
import org.springframework.stereotype.Component

@Component
@APIDescription("""
@APIDescription(
"""
Wraps a notification in a workflow node.
The output of this execution is exactly the output
of the notification channel.
""")
@DocumentationExampleCode("""
executorId: notification
data:
channel: slack
channelConfig:
channel: "#my-channel"
template: |
Message template
""")
"""
)
@DocumentationExampleCode(
"""
executorId: notification
data:
channel: slack
channelConfig:
channel: "#my-channel"
template: |
Message template
"""
)
@Documentation(WorkflowNotificationChannelNodeData::class)
class WorkflowNotificationChannelNodeExecutor(
workflowsExtensionFeature: WorkflowsExtensionFeature,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ fun getFieldsForDocumentationClass(documentationClass: KClass<*>): List<FieldDoc
return fields
}

fun getFieldsDocumentation(type: KClass<*>, section: String = ""): List<FieldDocumentation> {
fun getFieldsDocumentation(type: KClass<*>, section: String = "", required: Boolean = true): List<FieldDocumentation> {
val documentationAnnotation = type.findAnnotations<Documentation>().firstOrNull { it.section == section }
if (documentationAnnotation == null && !required) return emptyList()
val documentationClass = documentationAnnotation?.value ?: type
return getFieldsForDocumentationClass(documentationClass)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class DocumentationGenerationIT : AbstractDocumentationGenerationTestSupport() {

val fileId = getWNXFileId(wnx)

val outputFieldsDocumentation = try {
getFieldsDocumentation(wnx::class, section = "output", required = false)
} catch (any: Exception) {
fail("Failed to get output fields documentation for ${wnx::class.simpleName}", any)
}

directoryContext.writeFile(
fileId = fileId,
level = 4,
Expand All @@ -67,7 +73,7 @@ class DocumentationGenerationIT : AbstractDocumentationGenerationTestSupport() {
example = example,
links = wnx::class.findAnnotations(),
extendedConfig = { s ->
val output = getFieldsDocumentation(wnx::class, section = "output")
val output = outputFieldsDocumentation
if (output.isNotEmpty()) {
s.append("Output:\n\n")
directoryContext.writeFields(s, output)
Expand Down

0 comments on commit bff8928

Please sign in to comment.