wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
import fs from 'fs'
|
|
|
|
import { mkdir } from 'node:fs/promises'
|
|
|
|
import path from 'path'
|
2025-04-01 16:15:20 +02:00
|
|
|
import { designs, about, i18n } from '@freesewing/collection'
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
import {
|
|
|
|
designs as designTranslations,
|
|
|
|
optiongroups as optiongroupTranslations,
|
|
|
|
} from '../src/lib/i18n.mjs'
|
2025-04-01 16:15:20 +02:00
|
|
|
import {
|
|
|
|
capitalize,
|
|
|
|
optionsMenuStructure,
|
|
|
|
optionType,
|
|
|
|
orderBy,
|
|
|
|
} from '../../../packages/utils/src/index.mjs'
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If you are looking to port a design, remove it from the list below
|
|
|
|
* and the options umbrella page will be auto-generated
|
|
|
|
*
|
|
|
|
* Run 'npm run prestart' to force it, or it will happen automatically
|
|
|
|
* when you run `npm run start`
|
|
|
|
*/
|
2024-11-02 13:06:51 +01:00
|
|
|
const skip = []
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* mkdir helper
|
|
|
|
*/
|
|
|
|
async function ensuredir(dir) {
|
|
|
|
try {
|
|
|
|
await mkdir(path.resolve(dir), { recursive: true })
|
|
|
|
} catch (err) {
|
|
|
|
// Swallor error of folder exists
|
|
|
|
if (!err.toString().includes('already exists')) {
|
|
|
|
console.log(err)
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generate option table
|
|
|
|
*/
|
|
|
|
function optionInfo(option) {
|
|
|
|
const type = optionType(option)
|
|
|
|
if (type === 'pct') return pctOption(option)
|
|
|
|
if (type === 'count') return countOption(option)
|
|
|
|
if (type === 'deg') return degOption(option)
|
|
|
|
if (type === 'bool') return boolOption(option)
|
|
|
|
if (type === 'list') return listOption(option)
|
|
|
|
if (type === 'mm') return mmOption(option)
|
|
|
|
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
|
|
|
function pctOption(option) {
|
|
|
|
return [
|
|
|
|
`- Type: **Percentage**`,
|
|
|
|
`- Default: **${option.pct}%**`,
|
|
|
|
`- Minimum: **${option.min}%**`,
|
|
|
|
`- Maximum: **${option.max}%**`,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
function degOption(option) {
|
|
|
|
return [
|
|
|
|
`- Type: **Degrees**`,
|
|
|
|
`- Default: **${option.deg}°**`,
|
|
|
|
`- Minimum: **${option.min}°**`,
|
|
|
|
`- Maximum: **${option.max}°**`,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
function countOption(option) {
|
|
|
|
return [
|
|
|
|
`- Type: **Percentage**`,
|
|
|
|
`- Default: **${option.pct}**`,
|
|
|
|
`- Minimum: **${option.min}**`,
|
|
|
|
`- Maximum: **${option.max}**`,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
function listOption(option) {
|
|
|
|
return [
|
|
|
|
`- Type: **List**`,
|
|
|
|
`- Default: **${option.dflt}**`,
|
|
|
|
`- options:`,
|
|
|
|
...option.list.map((o) => ` - ${o}`),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
function boolOption(option) {
|
|
|
|
return [`- Type: **Boolean**`, `- Default: **${option.bool}**`]
|
|
|
|
}
|
|
|
|
function mmOption(option) {
|
|
|
|
return [
|
|
|
|
`- Type: **Millimeter**`,
|
|
|
|
`- Default: **${option.mm}mm**`,
|
|
|
|
`- Minimum: **${option.min}mm**`,
|
|
|
|
`- Maximum: **${option.max}mm**`,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2025-04-01 16:15:20 +02:00
|
|
|
const designPageTemplate = (design) => `---
|
|
|
|
title: ${i18n[design].en.t}
|
|
|
|
---
|
|
|
|
|
|
|
|
{/* This page is auto-generated. Manual changes will be lost. */}
|
|
|
|
|
|
|
|
import { DocusaurusDoc } from '@freesewing/react/components/Docusaurus'
|
|
|
|
import { DesignInfo } from '@freesewing/react/components/Collection'
|
|
|
|
import Link from '@docusaurus/Link'
|
|
|
|
import Notes from '@site/docs/docs/designs/${design}/_notes.mdx'
|
|
|
|
import DesignExamples from '@site/src/components/DesignExamples.mjs'
|
|
|
|
|
|
|
|
<DocusaurusDoc>
|
|
|
|
|
|
|
|
<DesignInfo design="${design}" Link={Link} />
|
|
|
|
|
|
|
|
## Designer notes {#notes}
|
|
|
|
|
|
|
|
<Notes />
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
<DesignExamples design="${design}" Link={Link} />
|
|
|
|
|
|
|
|
</DocusaurusDoc>
|
|
|
|
|
|
|
|
`
|
|
|
|
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
/*
|
|
|
|
* Generate options page for each design
|
2025-04-01 16:15:20 +02:00
|
|
|
* Also create the /designs/NAME page
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
*/
|
|
|
|
async function generateDesignsDocs() {
|
|
|
|
// Iterate over designs
|
2025-04-01 16:15:20 +02:00
|
|
|
for (const [name, design] of Object.entries(designs)) {
|
|
|
|
if (!skip.includes(name)) {
|
|
|
|
const imports = Object.keys(designs[name].patternConfig.options)
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
.filter(
|
2025-04-01 16:15:20 +02:00
|
|
|
(optName) => optionType(designs[name].patternConfig.options[optName]) !== 'constant'
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
)
|
|
|
|
.sort()
|
|
|
|
.map(
|
|
|
|
(opt) =>
|
2025-04-01 16:15:20 +02:00
|
|
|
`import ${capitalize(opt.toLowerCase())} from '@site/docs/docs/designs/${name}/options/${opt.toLowerCase()}/readme.mdx'`
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
)
|
|
|
|
const content = [
|
|
|
|
`---`,
|
|
|
|
`title: "${designTranslations[name].t}: Design Options"`,
|
|
|
|
`sidebar_label: Design Options`,
|
|
|
|
`sidebar_position: 10`,
|
|
|
|
`toc_max_heading_level: 5`,
|
|
|
|
`---`,
|
|
|
|
'',
|
|
|
|
...imports,
|
|
|
|
'',
|
|
|
|
]
|
2025-04-01 16:15:20 +02:00
|
|
|
const structure = optionsMenuStructure(designs[name].patternConfig.options, {}, true)
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
for (const [key, val] of Object.entries(structure)) {
|
|
|
|
content.push(`## ${optiongroupTranslations[key] || key} {#${key}}`)
|
|
|
|
if (val.isGroup) {
|
|
|
|
for (const [skey, sval] of Object.entries(val)) {
|
|
|
|
if (!sval.isGroup && optionType(sval) !== 'constant') {
|
|
|
|
content.push(
|
2025-04-01 16:15:20 +02:00
|
|
|
`### ${i18n[name].en.o[skey]?.t} {#${skey.toLowerCase()}}`,
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
'',
|
2025-04-01 16:15:20 +02:00
|
|
|
`**${i18n[name].en.o[skey]?.d}**`,
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
...optionInfo(sval),
|
|
|
|
'',
|
|
|
|
`<${capitalize(skey.toLowerCase())} />`,
|
|
|
|
''
|
|
|
|
)
|
|
|
|
} else if (sval.isGroup) {
|
2025-04-01 16:15:20 +02:00
|
|
|
content.push(
|
|
|
|
`### ${i18n[name].en.o[skey]?.t || capitalize(skey)} {#${skey.toLowerCase()}}`
|
|
|
|
)
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
for (const [sskey, ssval] of Object.entries(sval)) {
|
|
|
|
if (!ssval.isGroup && optionType(ssval) !== 'constant') {
|
|
|
|
content.push(
|
2025-04-01 16:15:20 +02:00
|
|
|
`#### ${i18n[name].en.o[sskey]?.t || sskey} {#${sskey.toLowerCase()}}`,
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
'',
|
2025-04-01 16:15:20 +02:00
|
|
|
`**${i18n[name].en.o[sskey]?.d}**`,
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
...optionInfo(ssval),
|
|
|
|
'',
|
|
|
|
`<${capitalize(sskey.toLowerCase())} />`,
|
|
|
|
''
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2025-04-01 16:15:20 +02:00
|
|
|
const dir = `./docs/docs/designs/${name}/options`
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
await ensuredir(dir)
|
|
|
|
fs.writeFileSync(`${dir}/readme.mdx`, content.join('\n'))
|
|
|
|
}
|
2025-04-01 16:15:20 +02:00
|
|
|
fs.writeFileSync(`./docs/designs/${name}.mdx`, designPageTemplate(name))
|
wip: Porting of docs to docusaurus (#7208)
This ports the docs for the following designs: breanna, bruce, cathrin, florence, florent , hugo, lily, lunetius, onyx, opal, paco, sandy, shelly, shin, sven, tamiko, teagan, iberius, trayvon, wahid, walburga, and yuri.
Also adds a prebuild step to build the options umbrella pages. and includes some CSS tweaks.
2024-11-02 10:12:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function prebuild() {
|
|
|
|
generateDesignsDocs()
|
|
|
|
}
|
|
|
|
|
|
|
|
prebuild()
|