block list: categories, links, descriptions
This commit is contained in:
parent
dd34206376
commit
31cbbfb3a4
1 changed files with 29 additions and 8 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { writeFileSync } from 'fs'
|
import { writeFileSync } from 'fs'
|
||||||
import { forEach, isString } from 'lodash-es'
|
import { forEach, isString, without } from 'lodash-es'
|
||||||
|
|
||||||
|
|
||||||
export default class BlockIndexExporter {
|
export default class BlockIndexExporter {
|
||||||
|
|
@ -19,6 +19,7 @@ export default class BlockIndexExporter {
|
||||||
...givenOptions
|
...givenOptions
|
||||||
},
|
},
|
||||||
categories = this.definitionSet.getCategories(),
|
categories = this.definitionSet.getCategories(),
|
||||||
|
categorized = [],
|
||||||
index = []
|
index = []
|
||||||
|
|
||||||
index.push(`---
|
index.push(`---
|
||||||
|
|
@ -27,7 +28,7 @@ editLink: false
|
||||||
---
|
---
|
||||||
|
|
||||||
# Block List`)
|
# Block List`)
|
||||||
// index.push(`All available blocks`)
|
index.push(`${this.definitionSet.blocks.length} blocks and counting`)
|
||||||
|
|
||||||
categories.forEach(category => {
|
categories.forEach(category => {
|
||||||
index.push(`## ${category.name}`)
|
index.push(`## ${category.name}`)
|
||||||
|
|
@ -35,12 +36,8 @@ editLink: false
|
||||||
index.push(
|
index.push(
|
||||||
this.definitionSet.blocks.reduce((acc, def) => {
|
this.definitionSet.blocks.reduce((acc, def) => {
|
||||||
if(category.contents?.includes(def) || category.usesBlocks?.includes(def.type)) {
|
if(category.contents?.includes(def) || category.usesBlocks?.includes(def.type)) {
|
||||||
// block name and link
|
acc.push(definitionToIndexLines(def))
|
||||||
acc.push(`### [${ def.name }](/${ def.documentationPath() })`)
|
categorized.push(def)
|
||||||
// block image
|
|
||||||
// acc.push(``) // TODO
|
|
||||||
// block short description
|
|
||||||
acc.push(`_${def.tooltip}_`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc
|
return acc
|
||||||
|
|
@ -48,6 +45,15 @@ editLink: false
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Special "Uncategorized" category
|
||||||
|
const uncategorized = without(this.definitionSet.blocks, ...categorized)
|
||||||
|
index.push(`## Uncategorized`)
|
||||||
|
index.push("These blocks do not appear in the toolbox directly. They may appear in gear menus, as sub-blocks, etc.")
|
||||||
|
|
||||||
|
index.push(
|
||||||
|
uncategorized.map(def => definitionToIndexLines(def)).join("\n")
|
||||||
|
)
|
||||||
|
|
||||||
const finalMarkdown = index.join("\n\n")
|
const finalMarkdown = index.join("\n\n")
|
||||||
|
|
||||||
if(!options.toFile) {
|
if(!options.toFile) {
|
||||||
|
|
@ -65,3 +71,18 @@ editLink: false
|
||||||
this.export({ toFile })
|
this.export({ toFile })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const definitionToIndexLines = def => {
|
||||||
|
const indexLines = []
|
||||||
|
|
||||||
|
// block name and link
|
||||||
|
indexLines.push(`### [${ def.name }](/${ def.documentationPath() })`)
|
||||||
|
|
||||||
|
// block image // TODO
|
||||||
|
// indexLines.push(``)
|
||||||
|
|
||||||
|
// block short description
|
||||||
|
indexLines.push(`_${def.tooltip}_`)
|
||||||
|
|
||||||
|
return indexLines.join("\n")
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue