rough in lots of block data
This commit is contained in:
parent
4c9bd6bd3e
commit
5cb2fd9010
1 changed files with 45 additions and 4 deletions
|
|
@ -21,7 +21,7 @@ const withCleanDir = async (dirName, writeFunction) => {
|
||||||
|
|
||||||
// ensure dir is present before writing
|
// ensure dir is present before writing
|
||||||
if(!fs.existsSync(exportDirname)) {
|
if(!fs.existsSync(exportDirname)) {
|
||||||
fs.mkdirSync(exportDirname, { recursive: true })
|
fs.mkdirSync(exportDirname, { recursive: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the file
|
// write the file
|
||||||
|
|
@ -43,7 +43,7 @@ import { importBlockJson, importBlockDefinitions, allBlockDefinitionsAndPaths }
|
||||||
import importToolboxJson from './src/importer/toolbox_importer.js'
|
import importToolboxJson from './src/importer/toolbox_importer.js'
|
||||||
import importWorkspaceJson from './src/importer/workspace_importer.js'
|
import importWorkspaceJson from './src/importer/workspace_importer.js'
|
||||||
import importBlocklyJs from './src/importer/blockly_importer.js'
|
import importBlocklyJs from './src/importer/blockly_importer.js'
|
||||||
import { capitalize, filter, find, forEach, get, keyBy, map, mapValues, sortBy } from 'lodash-es'
|
import { capitalize, filter, find, forEach, get, isArray, isObject, keyBy, map, mapValues, sortBy } from 'lodash-es'
|
||||||
|
|
||||||
const
|
const
|
||||||
toolbox = await importToolboxJson(),
|
toolbox = await importToolboxJson(),
|
||||||
|
|
@ -53,14 +53,56 @@ const
|
||||||
const pretty = jsObject => JSON.stringify(jsObject, null, 2) + "\n"
|
const pretty = jsObject => JSON.stringify(jsObject, null, 2) + "\n"
|
||||||
|
|
||||||
const toBlockMarkdown = definition => {
|
const toBlockMarkdown = definition => {
|
||||||
|
const
|
||||||
|
lineObjects = filter(map(filter(definition.lines, isArray), "[1]"), isObject),
|
||||||
|
fields = filter(lineObjects, "field"),
|
||||||
|
inputValues = filter(lineObjects, "inputValue"),
|
||||||
|
inputStatements = filter(lineObjects, "inputStatement")
|
||||||
|
|
||||||
return `---
|
return `---
|
||||||
title: "Block: ${definition.name}"
|
title: "Block: ${definition.name}"
|
||||||
editLink: true
|
editLink: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Block: ${definition.name}
|
# Block ${definition.name}
|
||||||
|
|
||||||
|
## Categories 🔜
|
||||||
|
|
||||||
|
## Description
|
||||||
${ definition.visualization?.tooltip?.replaceAll("\n", "\n ") || "No docs for this block, yet." }
|
${ definition.visualization?.tooltip?.replaceAll("\n", "\n ") || "No docs for this block, yet." }
|
||||||
|
|
||||||
|
## Workspace 🔜
|
||||||
|
|
||||||
|
## Fields
|
||||||
|
|
||||||
|
${ fields.map(field =>
|
||||||
|
`### \`${ capitalize(field.field) }\`
|
||||||
|
|
||||||
|
- Text: ${ field.text || 'None' }
|
||||||
|
- Select:
|
||||||
|
- ${ map(field.options||[], 0).join("\n - ") }`
|
||||||
|
).join("\n\n") }
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
${ inputValues.map(inputValue =>
|
||||||
|
`### \`${ capitalize(inputValue.inputValue) }\`
|
||||||
|
|
||||||
|
- Check: ${inputValue.check || 'None' }
|
||||||
|
- Shadow: ${inputValue.shadow?.type || inputValue.shadow}`
|
||||||
|
).join("\n\n") }
|
||||||
|
|
||||||
|
${ inputStatements.map(inputStatement =>
|
||||||
|
`### \`${ capitalize(inputStatement.inputStatement) }\`
|
||||||
|
|
||||||
|
- Check: ${inputStatement.check || 'None' }`
|
||||||
|
).join("\n\n") }
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
${ capitalize(definition.connections?.output || "Unspecified") }
|
||||||
|
|
||||||
|
## Examples 🔜
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +142,6 @@ withCleanDir("docs/blocks", async write => {
|
||||||
forEach(categoryBlocksMap, (categoryBlocks, categoryName) => {
|
forEach(categoryBlocksMap, (categoryBlocks, categoryName) => {
|
||||||
// if category contains this block, add to its sidebar
|
// if category contains this block, add to its sidebar
|
||||||
if(categoryBlocks.includes(definition.type)) {
|
if(categoryBlocks.includes(definition.type)) {
|
||||||
console.log('found:', definition.type, 'in', categoryName)
|
|
||||||
find(blockSidebar.items, { text: categoryName }).items.push(sidebarEntry)
|
find(blockSidebar.items, { text: categoryName }).items.push(sidebarEntry)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue