docs-util: add support for workflows in markdown theme (#8485)

* add template for workflows

* initial changes

* added support for parallel steps

* added support for when

* added merge options

* fix merge options

* fix to tooltip

* clean up

* remove redirects

* fixes

* theme fixes + added merge options

* generate hook examples + fixes

* changed namespaces

* add custom autogenerator

* change type of additional data
This commit is contained in:
Shahed Nasser
2024-08-09 16:35:52 +03:00
committed by GitHub
parent 79b49c1288
commit a19c562bec
58 changed files with 2098 additions and 328 deletions
+1
View File
@@ -15,3 +15,4 @@ export * from "./learning-paths"
export * from "./set-obj-value"
export * from "./sidebar-attach-href-common-options"
export * from "./swr-fetcher"
export * from "./workflow-diagram-utils"
@@ -0,0 +1,32 @@
import { WorkflowSteps, WorkflowStepUi } from "types"
export const createNodeClusters = (steps: WorkflowSteps) => {
const clusters: Record<number, WorkflowStepUi[]> = {}
steps.forEach((step) => {
if (!clusters[step.depth]) {
clusters[step.depth] = []
}
if (step.type === "when") {
const whenSteps = step.steps.map((whenStep) => ({
...whenStep,
depth: step.depth,
when: step,
}))
clusters[step.depth].push(...whenSteps)
} else {
clusters[step.depth].push(step)
}
})
return clusters
}
export const getNextCluster = (
clusters: Record<number, WorkflowStepUi[]>,
depth: number
) => {
const nextDepth = depth + 1
return clusters[nextDepth]
}