sdocs 0.0.54 → 0.0.56

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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.0.56] - 2026-07-05
11
+
12
+ ### Added
13
+
14
+ - **`configSchema` in `sdocs/language`** — a structured description of the
15
+ `sdocs.config.*` shape (keys, documentation, and value enums) mirroring
16
+ `SdocsConfig`. Editor tooling reads it to complete the config file in
17
+ projects that don't install `sdocs`, so config completion can't drift from
18
+ the config type.
19
+
20
+ ## [0.0.55] - 2026-07-05
21
+
22
+ ### Changed
23
+
24
+ - **Renamed the stage alignment attributes** `align`/`alignY` (added in
25
+ 0.0.54) to **`contentX`**/**`contentY`** — for horizontal/vertical content
26
+ alignment on `[preview]`/`[example]` and their `content.docs` and `[DOCS]`
27
+ defaults. Values and direction-aware behavior are unchanged.
28
+
10
29
  ## [0.0.54] - 2026-07-05
11
30
 
12
31
  ### Added
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A structured description of the `sdocs.config.*` shape, mirroring the
3
+ * `SdocsConfig` type. Editor tooling consumes this to offer key and value
4
+ * completions in projects that don't install `sdocs` (where the TypeScript
5
+ * type isn't resolvable). Keep it in step with `SdocsConfig` in `types.ts`.
6
+ */
7
+ /** One config key: how to present, insert, and (for enums) value-complete it. */
8
+ export interface ConfigFieldSchema {
9
+ /** Short type hint shown as the completion detail, e.g. `'string | string[]'`. */
10
+ detail: string;
11
+ /** Markdown documentation for the key. */
12
+ doc: string;
13
+ /** Snippet inserted after the key name — includes the `:` and a tabstop. */
14
+ insert: string;
15
+ /** Allowed values, for value-position completion. */
16
+ values?: string[];
17
+ /** Whether `values` are strings (quoted on insert) or literals (inserted bare). */
18
+ quoted?: boolean;
19
+ /** Nested object schema, when this key holds an object. */
20
+ object?: ConfigSchema;
21
+ }
22
+ /** A config object shape: its keys mapped to their field descriptions. */
23
+ export type ConfigSchema = Record<string, ConfigFieldSchema>;
24
+ /** The `sdocs.config.*` schema, rooted at the exported config object. */
25
+ export declare const configSchema: ConfigSchema;
@@ -0,0 +1,131 @@
1
+ /**
2
+ * A structured description of the `sdocs.config.*` shape, mirroring the
3
+ * `SdocsConfig` type. Editor tooling consumes this to offer key and value
4
+ * completions in projects that don't install `sdocs` (where the TypeScript
5
+ * type isn't resolvable). Keep it in step with `SdocsConfig` in `types.ts`.
6
+ */
7
+ // Sizing knobs shared by the page/docs/layout content objects.
8
+ const maxWidth = {
9
+ detail: 'string',
10
+ doc: 'Content column max width — any CSS length (`1200px`, `80ch`, `100%`).',
11
+ insert: ": '$0'",
12
+ };
13
+ const padding = {
14
+ detail: 'string',
15
+ doc: 'Space around the content — any CSS padding shorthand (`16px`, `1rem 2rem`).',
16
+ insert: ": '$0'",
17
+ };
18
+ // Stage-layout knobs shared by the docs preview/example stages.
19
+ const direction = {
20
+ detail: "'row' | 'column'",
21
+ doc: 'Preview/example stage `flex-direction`. Default: `row`.',
22
+ insert: ": '${0:row}'",
23
+ values: ['row', 'column', 'row-reverse', 'column-reverse'],
24
+ quoted: true,
25
+ };
26
+ const gap = {
27
+ detail: 'string',
28
+ doc: 'Gap between stage items — any CSS length. Default: `16px`.',
29
+ insert: ": '$0'",
30
+ };
31
+ const contentX = {
32
+ detail: "'left' | 'center' | 'right' | 'justify'",
33
+ doc: 'Horizontal alignment of stage contents. Default: `left`.',
34
+ insert: ": '${0:left}'",
35
+ values: ['left', 'center', 'right', 'justify'],
36
+ quoted: true,
37
+ };
38
+ const contentY = {
39
+ detail: "'top' | 'middle' | 'bottom' | 'justify'",
40
+ doc: 'Vertical alignment of stage contents. Default: `top`.',
41
+ insert: ": '${0:top}'",
42
+ values: ['top', 'middle', 'bottom', 'justify'],
43
+ quoted: true,
44
+ };
45
+ /** The `sdocs.config.*` schema, rooted at the exported config object. */
46
+ export const configSchema = {
47
+ include: {
48
+ detail: 'string | string[]',
49
+ doc: 'Glob pattern(s) locating your `.sdoc` files. Default: `./src/**/*.sdoc`.',
50
+ insert: ": ['$0']",
51
+ },
52
+ port: {
53
+ detail: 'number',
54
+ doc: 'Dev server port. Default: `3000`.',
55
+ insert: ': ${0:3000}',
56
+ },
57
+ open: {
58
+ detail: 'boolean',
59
+ doc: 'Open the browser when the dev server starts. Default: `false`.',
60
+ insert: ': ${0:false}',
61
+ values: ['true', 'false'],
62
+ },
63
+ css: {
64
+ detail: 'string | Record<string, string>',
65
+ doc: 'CSS loaded inside preview iframes — a single stylesheet path, or a map of named stylesheets to switch between.',
66
+ insert: ": '$0'",
67
+ },
68
+ logo: {
69
+ detail: 'string',
70
+ doc: 'Sidebar logo text. Default: `sdocs`.',
71
+ insert: ": '${0:sdocs}'",
72
+ },
73
+ icon: {
74
+ detail: 'string | false',
75
+ doc: "Sidebar logo icon: `'sdocs'` for the built-in mascot, an image URL, or `false` to hide it. Default: `'sdocs'`.",
76
+ insert: ": '${0:sdocs}'",
77
+ values: ['sdocs'],
78
+ quoted: true,
79
+ },
80
+ sidebar: {
81
+ detail: 'object',
82
+ doc: 'Sidebar ordering and default-expanded folders.',
83
+ insert: ': {\n\t$0\n}',
84
+ object: {
85
+ order: {
86
+ detail: 'Record<string, string[]>',
87
+ doc: "Per-folder sort overrides. Keys are folder paths (`'root'` for the top level); `'*'` stands for unlisted items.",
88
+ insert: ': {\n\t$0\n}',
89
+ },
90
+ open: {
91
+ detail: 'string[]',
92
+ doc: 'Folders expanded by default on load.',
93
+ insert: ': [$0]',
94
+ },
95
+ },
96
+ },
97
+ content: {
98
+ detail: 'object',
99
+ doc: 'Content presentation per entity kind. Entity and block attributes override these.',
100
+ insert: ': {\n\t$0\n}',
101
+ object: {
102
+ page: {
103
+ detail: 'object',
104
+ doc: '`[PAGE]` content. Defaults: `maxWidth` `1200px`, `padding` `32px`, `toc` `true`.',
105
+ insert: ': {\n\t$0\n}',
106
+ object: {
107
+ maxWidth,
108
+ padding,
109
+ toc: {
110
+ detail: 'boolean',
111
+ doc: 'Show the page table of contents. Default: `true`.',
112
+ insert: ': ${0:true}',
113
+ values: ['true', 'false'],
114
+ },
115
+ },
116
+ },
117
+ docs: {
118
+ detail: 'object',
119
+ doc: '`[DOCS]` pages. `maxWidth` is the content column; `padding`/`direction`/`gap`/`contentX`/`contentY` are the default preview & example stage layout.',
120
+ insert: ': {\n\t$0\n}',
121
+ object: { maxWidth, padding, direction, gap, contentX, contentY },
122
+ },
123
+ layout: {
124
+ detail: 'object',
125
+ doc: '`[LAYOUT]` stages. Defaults: `maxWidth` `100%`, `padding` `0px`.',
126
+ insert: ': {\n\t$0\n}',
127
+ object: { maxWidth, padding },
128
+ },
129
+ },
130
+ },
131
+ };
@@ -1,4 +1,5 @@
1
1
  export { scanSdoc, offsetToPosition, ENTITY_KINDS, SUB_BLOCK_KINDS, type Span, type EntityKind, type SubBlockKind, type AttrValue, type Attrs, type SubBlock, type Entity, type TagBlock, type ScanError, type SdocFile, } from './scanner.js';
2
2
  export { projectSdoc, type SdocProjection, type ProjectedLineKind, } from './projection.js';
3
3
  export { segmentPageBody, type PageSegment, } from './page-islands.js';
4
+ export { configSchema, type ConfigSchema, type ConfigFieldSchema, } from './config-schema.js';
4
5
  export { parseSdoc, parseArgsLiteral, slugifyTitle, normalizeBody, attributeRules, type AttrRule, type ArgValue, type Sizing, type PreviewBlock, type ExampleBlock, type DocsEntity, type PageEntity, type LayoutEntity, type SdocEntity, type SdocDocument, } from './parser.js';
@@ -1,4 +1,5 @@
1
1
  export { scanSdoc, offsetToPosition, ENTITY_KINDS, SUB_BLOCK_KINDS, } from './scanner.js';
2
2
  export { projectSdoc, } from './projection.js';
3
3
  export { segmentPageBody, } from './page-islands.js';
4
+ export { configSchema, } from './config-schema.js';
4
5
  export { parseSdoc, parseArgsLiteral, slugifyTitle, normalizeBody, attributeRules, } from './parser.js';
@@ -14,9 +14,9 @@ export interface Sizing {
14
14
  /** gap of preview/example stages */
15
15
  gap: string | null;
16
16
  /** horizontal alignment of preview/example stage contents */
17
- align: string | null;
17
+ contentX: string | null;
18
18
  /** vertical alignment of preview/example stage contents */
19
- alignY: string | null;
19
+ contentY: string | null;
20
20
  /** table-of-contents visibility (PAGE) */
21
21
  toc: boolean | null;
22
22
  }
@@ -50,8 +50,8 @@ const SIZING_ATTR_RULES = {
50
50
  const STAGE_LAYOUT_ATTR_RULES = {
51
51
  direction: { required: false, kind: 'string', hint: 'direction="column"' },
52
52
  gap: { required: false, kind: 'string', hint: 'gap="16px"' },
53
- align: { required: false, kind: 'string', hint: 'align="center"' },
54
- alignY: { required: false, kind: 'string', hint: 'alignY="middle"' },
53
+ contentX: { required: false, kind: 'string', hint: 'contentX="center"' },
54
+ contentY: { required: false, kind: 'string', hint: 'contentY="middle"' },
55
55
  };
56
56
  function sizingOf(attrs) {
57
57
  const toc = stringAttr(attrs, 'toc');
@@ -60,8 +60,8 @@ function sizingOf(attrs) {
60
60
  padding: stringAttr(attrs, 'padding'),
61
61
  direction: stringAttr(attrs, 'direction'),
62
62
  gap: stringAttr(attrs, 'gap'),
63
- align: stringAttr(attrs, 'align'),
64
- alignY: stringAttr(attrs, 'alignY'),
63
+ contentX: stringAttr(attrs, 'contentX'),
64
+ contentY: stringAttr(attrs, 'contentY'),
65
65
  toc: toc === null ? null : toc === 'true',
66
66
  };
67
67
  }
@@ -20,8 +20,8 @@ const DEFAULTS = {
20
20
  padding: '16px',
21
21
  direction: 'row',
22
22
  gap: '16px',
23
- align: 'left',
24
- alignY: 'top',
23
+ contentX: 'left',
24
+ contentY: 'top',
25
25
  },
26
26
  layout: { maxWidth: '100%', padding: '0px' },
27
27
  },
@@ -28,8 +28,8 @@ export declare function generateIframeComponent(scriptPrelude: string, snippetBo
28
28
  padding: string;
29
29
  direction?: string;
30
30
  gap?: string;
31
- align?: string;
32
- alignY?: string;
31
+ contentX?: string;
32
+ contentY?: string;
33
33
  }): string;
34
34
  /** The JS that boots a preview page: mount the wrapper + parent-frame messaging. */
35
35
  export declare function generateMountScript(iframeComponentId: string): string;
@@ -88,8 +88,8 @@ export function generateIframeComponent(scriptPrelude, snippetBody, stateNames =
88
88
  // layout stages are flow-root blocks. Both contain child margins, so the
89
89
  // height reported for iframe auto-sizing is exact.
90
90
  //
91
- // align/alignY are *physical* (horizontal/vertical); which flex property
92
- // each drives depends on direction. The flow axis (main) takes
91
+ // contentX/contentY are *physical* (horizontal/vertical); which flex
92
+ // property each drives depends on direction. The flow axis (main) takes
93
93
  // justify-content, the other (cross) takes align-items — and align-items
94
94
  // has no distribution value, so a 'justify' that lands on the cross axis
95
95
  // falls back to stretch.
@@ -106,8 +106,8 @@ export function generateIframeComponent(scriptPrelude, snippetBody, stateNames =
106
106
  justify: 'space-between',
107
107
  };
108
108
  const flexStage = () => {
109
- const h = H[stage.align ?? 'left'] ?? 'flex-start';
110
- const v = V[stage.alignY ?? 'top'] ?? 'flex-start';
109
+ const h = H[stage.contentX ?? 'left'] ?? 'flex-start';
110
+ const v = V[stage.contentY ?? 'top'] ?? 'flex-start';
111
111
  const isColumn = String(stage.direction).startsWith('column');
112
112
  const justify = isColumn ? v : h;
113
113
  let alignItems = isColumn ? h : v;
package/dist/types.d.ts CHANGED
@@ -35,9 +35,9 @@ export interface SdocsConfig {
35
35
  /** Stage gap. Default: '16px' */
36
36
  gap?: string;
37
37
  /** Horizontal alignment of stage contents: 'left'|'center'|'right'|'justify'. Default: 'left' */
38
- align?: string;
38
+ contentX?: string;
39
39
  /** Vertical alignment of stage contents: 'top'|'middle'|'bottom'. Default: 'top' */
40
- alignY?: string;
40
+ contentY?: string;
41
41
  };
42
42
  /** [LAYOUT] stages. Defaults: maxWidth '100%', padding '0px'. */
43
43
  layout?: ContentSizing;
@@ -52,13 +52,13 @@ export interface ContentSizing {
52
52
  export interface StageLayout {
53
53
  maxWidth: string;
54
54
  padding: string;
55
- /** flex-direction + gap + align; set for preview/example stages only */
55
+ /** flex-direction + gap + contentX; set for preview/example stages only */
56
56
  direction?: string;
57
57
  gap?: string;
58
58
  /** horizontal ('left'|'center'|'right'|'justify') — mapped by direction */
59
- align?: string;
59
+ contentX?: string;
60
60
  /** vertical ('top'|'middle'|'bottom') — mapped by direction */
61
- alignY?: string;
61
+ contentY?: string;
62
62
  }
63
63
  /** Resolved config with all defaults applied */
64
64
  export interface ResolvedSdocsConfig {
@@ -79,8 +79,8 @@ export interface ResolvedSdocsConfig {
79
79
  docs: Required<ContentSizing> & {
80
80
  direction: string;
81
81
  gap: string;
82
- align: string;
83
- alignY: string;
82
+ contentX: string;
83
+ contentY: string;
84
84
  };
85
85
  layout: Required<ContentSizing>;
86
86
  };
package/dist/vite.js CHANGED
@@ -308,13 +308,13 @@ export function sdocsPlugin(userConfig) {
308
308
  maxWidth: block?.maxWidth ??
309
309
  (entity.kind === 'LAYOUT' ? (entity.sizing.maxWidth ?? kindDefaults.maxWidth) : '100%'),
310
310
  padding: block?.padding ?? entity.sizing.padding ?? kindDefaults.padding,
311
- // direction/gap/align flex the preview/example stages only
311
+ // direction/gap/contentX flex the preview/example stages only
312
312
  ...(entity.kind === 'DOCS' && block
313
313
  ? {
314
314
  direction: block.direction ?? entity.sizing.direction ?? config.content.docs.direction,
315
315
  gap: block.gap ?? entity.sizing.gap ?? config.content.docs.gap,
316
- align: block.align ?? entity.sizing.align ?? config.content.docs.align,
317
- alignY: block.alignY ?? entity.sizing.alignY ?? config.content.docs.alignY,
316
+ contentX: block.contentX ?? entity.sizing.contentX ?? config.content.docs.contentX,
317
+ contentY: block.contentY ?? entity.sizing.contentY ?? config.content.docs.contentY,
318
318
  }
319
319
  : {}),
320
320
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdocs",
3
- "version": "0.0.54",
3
+ "version": "0.0.56",
4
4
  "description": "A lightweight documentation tool for Svelte 5 components",
5
5
  "type": "module",
6
6
  "license": "MIT",