sdocs 0.0.47 → 0.0.49

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,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.0.49] - 2026-07-05
11
+
12
+ ### Fixed
13
+
14
+ - **The `:` group marker no longer leaks into page headings.** A title like
15
+ `:Group / Name` groups an entry in the sidebar, but the leading colon was
16
+ rendered verbatim in the component/page `<h1>`. Headings now strip it, so the
17
+ title reads `Group / Name`.
18
+
19
+ ## [0.0.48] - 2026-07-05
20
+
21
+ ### Changed
22
+
23
+ - **Empty API sections are hidden on component pages.** Props, CSS Props,
24
+ Events, Snippets, Methods, and States sections now render only when the
25
+ component actually has entries for them, instead of every section always
26
+ showing with a "None" placeholder.
27
+
10
28
  ## [0.0.47] - 2026-07-05
11
29
 
12
30
  ### Fixed
@@ -20,6 +20,12 @@ interface SidebarConfig {
20
20
  }
21
21
  /** Build a tree from flat doc entries */
22
22
  export declare function buildTree(docs: DocEntry[], sidebar?: SidebarConfig): TreeNode[];
23
+ /**
24
+ * The title shown to users. A leading ':' on the first segment is a sidebar
25
+ * grouping directive (see buildTree), not part of the displayed title, so it
26
+ * is stripped for headings.
27
+ */
28
+ export declare function displayTitle(title: string | null | undefined): string;
23
29
  /** Check if a path matches a tree node (for active state) */
24
30
  export declare function pathMatchesNode(currentPath: string[], node: TreeNode): boolean;
25
31
  /** Find the doc entry for a given path */
@@ -172,6 +172,14 @@ function sortByOrder(nodes, order) {
172
172
  nodes.push(node);
173
173
  }
174
174
  }
175
+ /**
176
+ * The title shown to users. A leading ':' on the first segment is a sidebar
177
+ * grouping directive (see buildTree), not part of the displayed title, so it
178
+ * is stripped for headings.
179
+ */
180
+ export function displayTitle(title) {
181
+ return (title ?? '').replace(/^:\s*/, '');
182
+ }
175
183
  /** Check if a path matches a tree node (for active state) */
176
184
  export function pathMatchesNode(currentPath, node) {
177
185
  if (node.path.length !== currentPath.length)
@@ -7,6 +7,7 @@
7
7
  import ApiTable from './ApiTable.svelte';
8
8
  import PropControl from './PropControl.svelte';
9
9
  import CssPropControl from './CssPropControl.svelte';
10
+ import { displayTitle } from '../tree-builder.js';
10
11
 
11
12
  interface Props {
12
13
  doc: DocEntry;
@@ -278,13 +279,20 @@
278
279
  description: s.description,
279
280
  })),
280
281
  );
282
+
283
+ // The Reset button normally sits in the Props header; when a component has
284
+ // editable CSS vars but no regular props, that section is hidden, so show
285
+ // Reset in the CSS Props header instead.
286
+ const showResetInCss = $derived(
287
+ hasEditableControls && propsRows.length === 0 && cssPropsRows.length > 0,
288
+ );
281
289
  </script>
282
290
 
283
291
  <div class="sdocs-component-view">
284
292
  {#if focusedSnippet}
285
293
  <!-- Example full-page view -->
286
294
  <div class="sdocs-view-header">
287
- <h1 class="sdocs-view-title">{meta.title} / {snippetName}</h1>
295
+ <h1 class="sdocs-view-title">{displayTitle(meta.title)} / {snippetName}</h1>
288
296
  </div>
289
297
  <div class="sdocs-panels">
290
298
  <CollapsiblePanel title="Preview">
@@ -297,7 +305,7 @@
297
305
  {:else}
298
306
  <!-- Full component view -->
299
307
  <div class="sdocs-view-header">
300
- <h1 class="sdocs-view-title">{meta.title}</h1>
308
+ <h1 class="sdocs-view-title">{displayTitle(meta.title)}</h1>
301
309
  {#if meta.description}
302
310
  <p class="sdocs-view-description">{meta.description}</p>
303
311
  {/if}
@@ -373,56 +381,71 @@
373
381
  {/if}
374
382
  {/snippet}
375
383
 
376
- <section class="sdocs-doc-section">
377
- <h2 class="sdocs-doc-section-title">
378
- <Icon name="sliders-horizontal" --w="15px" --h="15px" --fill="var(--color-base-500)" />
379
- Props
380
- {#if hasEditableControls}
381
- <button class="sdocs-reset-btn" onclick={handleReset}>Reset</button>
382
- {/if}
383
- </h2>
384
- <ApiTable rows={propsRows} control={propControl} />
385
- </section>
386
-
387
- <section class="sdocs-doc-section">
388
- <h2 class="sdocs-doc-section-title">
389
- <Icon name="palette" --w="15px" --h="15px" --fill="var(--color-base-500)" />
390
- CSS Props
391
- </h2>
392
- <ApiTable rows={cssPropsRows} control={cssPropControl} />
393
- </section>
394
-
395
- <section class="sdocs-doc-section">
396
- <h2 class="sdocs-doc-section-title">
397
- <Icon name="zap" --w="15px" --h="15px" --fill="var(--color-base-500)" />
398
- Events
399
- </h2>
400
- <ApiTable rows={eventsRows} showDefault={false} />
401
- </section>
402
-
403
- <section class="sdocs-doc-section">
404
- <h2 class="sdocs-doc-section-title">
405
- <Icon name="code" --w="15px" --h="15px" --fill="var(--color-base-500)" />
406
- Snippets
407
- </h2>
408
- <ApiTable rows={snippetsRows} showDefault={false} />
409
- </section>
410
-
411
- <section class="sdocs-doc-section">
412
- <h2 class="sdocs-doc-section-title">
413
- <Icon name="square-function" --w="15px" --h="15px" --fill="var(--color-base-500)" />
414
- Methods
415
- </h2>
416
- <ApiTable rows={methodsRows} showDefault={false} control={methodControl} />
417
- </section>
418
-
419
- <section class="sdocs-doc-section">
420
- <h2 class="sdocs-doc-section-title">
421
- <Icon name="database" --w="15px" --h="15px" --fill="var(--color-base-500)" />
422
- States
423
- </h2>
424
- <ApiTable rows={stateRows} defaultLabel="Current value" />
425
- </section>
384
+ {#if propsRows.length > 0}
385
+ <section class="sdocs-doc-section">
386
+ <h2 class="sdocs-doc-section-title">
387
+ <Icon name="sliders-horizontal" --w="15px" --h="15px" --fill="var(--color-base-500)" />
388
+ Props
389
+ {#if hasEditableControls}
390
+ <button class="sdocs-reset-btn" onclick={handleReset}>Reset</button>
391
+ {/if}
392
+ </h2>
393
+ <ApiTable rows={propsRows} control={propControl} />
394
+ </section>
395
+ {/if}
396
+
397
+ {#if cssPropsRows.length > 0}
398
+ <section class="sdocs-doc-section">
399
+ <h2 class="sdocs-doc-section-title">
400
+ <Icon name="palette" --w="15px" --h="15px" --fill="var(--color-base-500)" />
401
+ CSS Props
402
+ {#if showResetInCss}
403
+ <button class="sdocs-reset-btn" onclick={handleReset}>Reset</button>
404
+ {/if}
405
+ </h2>
406
+ <ApiTable rows={cssPropsRows} control={cssPropControl} />
407
+ </section>
408
+ {/if}
409
+
410
+ {#if eventsRows.length > 0}
411
+ <section class="sdocs-doc-section">
412
+ <h2 class="sdocs-doc-section-title">
413
+ <Icon name="zap" --w="15px" --h="15px" --fill="var(--color-base-500)" />
414
+ Events
415
+ </h2>
416
+ <ApiTable rows={eventsRows} showDefault={false} />
417
+ </section>
418
+ {/if}
419
+
420
+ {#if snippetsRows.length > 0}
421
+ <section class="sdocs-doc-section">
422
+ <h2 class="sdocs-doc-section-title">
423
+ <Icon name="code" --w="15px" --h="15px" --fill="var(--color-base-500)" />
424
+ Snippets
425
+ </h2>
426
+ <ApiTable rows={snippetsRows} showDefault={false} />
427
+ </section>
428
+ {/if}
429
+
430
+ {#if methodsRows.length > 0}
431
+ <section class="sdocs-doc-section">
432
+ <h2 class="sdocs-doc-section-title">
433
+ <Icon name="square-function" --w="15px" --h="15px" --fill="var(--color-base-500)" />
434
+ Methods
435
+ </h2>
436
+ <ApiTable rows={methodsRows} showDefault={false} control={methodControl} />
437
+ </section>
438
+ {/if}
439
+
440
+ {#if stateRows.length > 0}
441
+ <section class="sdocs-doc-section">
442
+ <h2 class="sdocs-doc-section-title">
443
+ <Icon name="database" --w="15px" --h="15px" --fill="var(--color-base-500)" />
444
+ States
445
+ </h2>
446
+ <ApiTable rows={stateRows} defaultLabel="Current value" />
447
+ </section>
448
+ {/if}
426
449
 
427
450
  {#if exampleSnippets.length > 0}
428
451
  <hr class="sdocs-divider" />
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { DocEntry } from '../../types.js';
3
3
  import PreviewFrame from './PreviewFrame.svelte';
4
+ import { displayTitle } from '../tree-builder.js';
4
5
 
5
6
  interface Props {
6
7
  doc: DocEntry;
@@ -25,7 +26,7 @@
25
26
  <div class="sdocs-page-main">
26
27
  <!-- Header -->
27
28
  <div class="sdocs-view-header">
28
- <h1 class="sdocs-view-title">{meta.title}</h1>
29
+ <h1 class="sdocs-view-title">{displayTitle(meta.title)}</h1>
29
30
  {#if meta.description}
30
31
  <p class="sdocs-view-description">{meta.description}</p>
31
32
  {/if}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdocs",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
4
4
  "description": "A lightweight documentation tool for Svelte 5 components",
5
5
  "type": "module",
6
6
  "license": "MIT",