@uniweb/build 0.1.22 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/docs.js +44 -56
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/build",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "Build tooling for the Uniweb Component Web Platform",
5
5
  "type": "module",
6
6
  "exports": {
package/src/docs.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { readFile, writeFile } from 'node:fs/promises'
9
9
  import { existsSync } from 'node:fs'
10
- import { join } from 'node:path'
10
+ import { join, isAbsolute } from 'node:path'
11
11
  import { buildSchema } from './schema.js'
12
12
 
13
13
  /**
@@ -30,51 +30,39 @@ function generateComponentDocs(name, meta) {
30
30
  lines.push('')
31
31
  }
32
32
 
33
- // Category badge
34
- if (meta.category) {
35
- lines.push(`**Category:** ${meta.category}`)
36
- lines.push('')
37
- }
38
-
39
- // Content Elements
40
- if (meta.elements && Object.keys(meta.elements).length > 0) {
41
- lines.push('### Content Elements')
42
- lines.push('')
43
- lines.push('| Element | Label | Required | Description |')
44
- lines.push('|---------|-------|----------|-------------|')
45
-
46
- for (const [key, element] of Object.entries(meta.elements)) {
47
- const label = element.label || key
48
- const required = element.required ? 'Yes' : ''
49
- const description = element.description || ''
50
- lines.push(`| \`${key}\` | ${label} | ${required} | ${description} |`)
51
- }
52
- lines.push('')
53
- }
54
-
55
- // Parameters/Properties
33
+ // Parameters/Properties (shown first - most important for content authors)
56
34
  if (meta.properties && Object.keys(meta.properties).length > 0) {
57
35
  lines.push('### Parameters')
58
36
  lines.push('')
59
- lines.push('| Parameter | Type | Default | Description |')
60
- lines.push('|-----------|------|---------|-------------|')
61
37
 
62
38
  for (const [key, prop] of Object.entries(meta.properties)) {
63
- const type = prop.type || 'string'
64
- const defaultVal = prop.default !== undefined ? `\`${prop.default}\`` : ''
65
- let description = prop.label || ''
39
+ const defaultVal = prop.default !== undefined ? prop.default : ''
40
+
41
+ // Parameter name with default
42
+ if (defaultVal !== '') {
43
+ lines.push(`**${key}** = \`${defaultVal}\``)
44
+ } else {
45
+ lines.push(`**${key}**`)
46
+ }
66
47
 
67
- // Add options for select type
48
+ // For select type, show options on next line
68
49
  if (prop.type === 'select' && prop.options) {
69
50
  const optionValues = prop.options.map(o =>
70
51
  typeof o === 'object' ? o.value : o
71
- ).join(', ')
72
- description += description ? ` (${optionValues})` : optionValues
52
+ ).join(' | ')
53
+ lines.push(` ${optionValues}`)
54
+ } else if (prop.type === 'boolean') {
55
+ // For boolean, show the label as description
56
+ if (prop.label) {
57
+ lines.push(` ${prop.label}`)
58
+ }
59
+ } else if (prop.label) {
60
+ // For other types, show label
61
+ lines.push(` ${prop.label}`)
73
62
  }
74
63
 
75
- lines.push(`| \`${key}\` | ${type} | ${defaultVal} | ${description} |`)
64
+ lines.push('')
76
65
  }
77
- lines.push('')
78
66
  }
79
67
 
80
68
  // Presets
@@ -88,11 +76,24 @@ function generateComponentDocs(name, meta) {
88
76
  .map(([k, v]) => `${k}: ${v}`)
89
77
  .join(', ')
90
78
  : ''
91
- lines.push(`- **${preset.name}** - ${preset.label || ''} ${settings ? `(${settings})` : ''}`)
79
+ lines.push(`- **${preset.name}**${settings ? `${settings}` : ''}`)
92
80
  }
93
81
  lines.push('')
94
82
  }
95
83
 
84
+ // Content Elements (condensed - less important)
85
+ if (meta.elements && Object.keys(meta.elements).length > 0) {
86
+ const elements = Object.entries(meta.elements)
87
+ const elementList = elements.map(([key, el]) => {
88
+ return el.required ? `${key} (required)` : key
89
+ }).join(', ')
90
+
91
+ lines.push('### Content')
92
+ lines.push('')
93
+ lines.push(elementList)
94
+ lines.push('')
95
+ }
96
+
96
97
  return lines.join('\n')
97
98
  }
98
99
 
@@ -112,17 +113,11 @@ export function generateDocsFromSchema(schema, options = {}) {
112
113
  lines.push(`# ${title}`)
113
114
  lines.push('')
114
115
 
115
- // Foundation info
116
+ // Foundation description
116
117
  const foundationMeta = schema._self
117
- if (foundationMeta) {
118
- if (foundationMeta.name) {
119
- lines.push(`**${foundationMeta.name}**`)
120
- lines.push('')
121
- }
122
- if (foundationMeta.description) {
123
- lines.push(foundationMeta.description)
124
- lines.push('')
125
- }
118
+ if (foundationMeta?.description) {
119
+ lines.push(foundationMeta.description)
120
+ lines.push('')
126
121
  }
127
122
 
128
123
  lines.push('---')
@@ -134,11 +129,7 @@ export function generateDocsFromSchema(schema, options = {}) {
134
129
  if (componentNames.length > 0) {
135
130
  lines.push('## Components')
136
131
  lines.push('')
137
- for (const name of componentNames) {
138
- const meta = schema[name]
139
- const title = meta.title || name
140
- lines.push(`- [${title}](#${name.toLowerCase()}) - ${meta.description || ''}`)
141
- }
132
+ lines.push(componentNames.map(name => `[${name}](#${name.toLowerCase()})`).join(' · '))
142
133
  lines.push('')
143
134
  lines.push('---')
144
135
  lines.push('')
@@ -152,10 +143,7 @@ export function generateDocsFromSchema(schema, options = {}) {
152
143
  lines.push('')
153
144
  }
154
145
 
155
- // Footer
156
- lines.push('*Generated from foundation schema*')
157
-
158
- return lines.join('\n')
146
+ return lines.join('\n').trim() + '\n'
159
147
  }
160
148
 
161
149
  /**
@@ -206,8 +194,8 @@ export async function generateDocs(foundationDir, options = {}) {
206
194
  // Generate markdown
207
195
  const markdown = generateDocsFromSchema(schema, { title })
208
196
 
209
- // Write output
210
- const outputPath = join(foundationDir, output)
197
+ // Write output (support absolute paths for site-based generation)
198
+ const outputPath = isAbsolute(output) ? output : join(foundationDir, output)
211
199
  await writeFile(outputPath, markdown)
212
200
 
213
201
  // Count components