@contractspec/example.in-app-docs 1.1.0

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.
@@ -0,0 +1,28 @@
1
+ $ tsdown
2
+ ℹ tsdown v0.19.0 powered by rolldown v1.0.0-beta.59
3
+ ℹ config file: /home/runner/work/contractspec/contractspec/packages/examples/in-app-docs/tsdown.config.js
4
+ ℹ entry: src/example.ts, src/index.ts, src/docs/in-app-docs.docblock.ts, src/docs/index.ts, src/ui/InAppDocsViewer.tsx, src/ui/index.ts
5
+ ℹ target: esnext
6
+ ℹ tsconfig: tsconfig.json
7
+ ℹ Build start
8
+ ℹ Cleaning 20 files
9
+ ℹ dist/docs/in-app-docs.docblock.js 3.01 kB │ gzip: 1.44 kB
10
+ ℹ dist/ui/InAppDocsViewer.js 1.93 kB │ gzip: 0.87 kB
11
+ ℹ dist/example.js 1.33 kB │ gzip: 0.67 kB
12
+ ℹ dist/index.js 0.24 kB │ gzip: 0.12 kB
13
+ ℹ dist/ui/index.js 0.12 kB │ gzip: 0.08 kB
14
+ ℹ dist/docs/index.js 0.04 kB │ gzip: 0.06 kB
15
+ ℹ dist/docs/in-app-docs.docblock.js.map 3.60 kB │ gzip: 1.66 kB
16
+ ℹ dist/ui/InAppDocsViewer.js.map 2.59 kB │ gzip: 1.20 kB
17
+ ℹ dist/example.js.map 2.52 kB │ gzip: 1.16 kB
18
+ ℹ dist/docs/in-app-docs.docblock.d.ts.map 0.17 kB │ gzip: 0.14 kB
19
+ ℹ dist/ui/InAppDocsViewer.d.ts.map 0.17 kB │ gzip: 0.15 kB
20
+ ℹ dist/example.d.ts.map 0.15 kB │ gzip: 0.14 kB
21
+ ℹ dist/docs/in-app-docs.docblock.d.ts 0.56 kB │ gzip: 0.35 kB
22
+ ℹ dist/example.d.ts 0.46 kB │ gzip: 0.28 kB
23
+ ℹ dist/ui/InAppDocsViewer.d.ts 0.38 kB │ gzip: 0.25 kB
24
+ ℹ dist/index.d.ts 0.18 kB │ gzip: 0.11 kB
25
+ ℹ dist/ui/index.d.ts 0.08 kB │ gzip: 0.07 kB
26
+ ℹ dist/docs/index.d.ts 0.04 kB │ gzip: 0.06 kB
27
+ ℹ 18 files, total: 17.56 kB
28
+ ✔ Build complete in 25485ms
@@ -0,0 +1,29 @@
1
+ $ bun build:types && bun build:bundle
2
+ $ tsc --noEmit
3
+ $ tsdown
4
+ ℹ tsdown v0.19.0 powered by rolldown v1.0.0-beta.59
5
+ ℹ config file: /home/runner/work/contractspec/contractspec/packages/examples/in-app-docs/tsdown.config.js
6
+ ℹ entry: src/example.ts, src/index.ts, src/docs/in-app-docs.docblock.ts, src/docs/index.ts, src/ui/InAppDocsViewer.tsx, src/ui/index.ts
7
+ ℹ target: esnext
8
+ ℹ tsconfig: tsconfig.json
9
+ ℹ Build start
10
+ ℹ dist/docs/in-app-docs.docblock.js 3.01 kB │ gzip: 1.44 kB
11
+ ℹ dist/ui/InAppDocsViewer.js 1.93 kB │ gzip: 0.87 kB
12
+ ℹ dist/example.js 1.33 kB │ gzip: 0.67 kB
13
+ ℹ dist/index.js 0.24 kB │ gzip: 0.12 kB
14
+ ℹ dist/ui/index.js 0.12 kB │ gzip: 0.08 kB
15
+ ℹ dist/docs/index.js 0.04 kB │ gzip: 0.06 kB
16
+ ℹ dist/docs/in-app-docs.docblock.js.map 3.60 kB │ gzip: 1.66 kB
17
+ ℹ dist/ui/InAppDocsViewer.js.map 2.59 kB │ gzip: 1.20 kB
18
+ ℹ dist/example.js.map 2.52 kB │ gzip: 1.16 kB
19
+ ℹ dist/docs/in-app-docs.docblock.d.ts.map 0.17 kB │ gzip: 0.14 kB
20
+ ℹ dist/ui/InAppDocsViewer.d.ts.map 0.17 kB │ gzip: 0.15 kB
21
+ ℹ dist/example.d.ts.map 0.15 kB │ gzip: 0.14 kB
22
+ ℹ dist/docs/in-app-docs.docblock.d.ts 0.56 kB │ gzip: 0.35 kB
23
+ ℹ dist/example.d.ts 0.46 kB │ gzip: 0.28 kB
24
+ ℹ dist/ui/InAppDocsViewer.d.ts 0.38 kB │ gzip: 0.25 kB
25
+ ℹ dist/index.d.ts 0.18 kB │ gzip: 0.11 kB
26
+ ℹ dist/ui/index.d.ts 0.08 kB │ gzip: 0.07 kB
27
+ ℹ dist/docs/index.d.ts 0.04 kB │ gzip: 0.06 kB
28
+ ℹ 18 files, total: 17.56 kB
29
+ ✔ Build complete in 27671ms
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @contractspec/example.in-app-docs
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ec5e95c: chore: upgrade dependencies
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [ec5e95c]
12
+ - @contractspec/lib.example-shared-ui@1.8.0
13
+ - @contractspec/lib.contracts@1.54.0
@@ -0,0 +1,16 @@
1
+ import { DocBlock } from "@contractspec/lib.contracts/docs";
2
+
3
+ //#region src/docs/in-app-docs.docblock.d.ts
4
+
5
+ /**
6
+ * DocBlocks for the in-app documentation example.
7
+ *
8
+ * These blocks provide publicly visible guides aimed at non‑technical users.
9
+ * Each DocBlock is associated with a route under /docs/examples/in-app-docs
10
+ * and will be rendered in the ContractSpec sandbox or within your app if you
11
+ * integrate the documentation.
12
+ */
13
+ declare const inAppDocs: DocBlock[];
14
+ //#endregion
15
+ export { inAppDocs };
16
+ //# sourceMappingURL=in-app-docs.docblock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-app-docs.docblock.d.ts","names":[],"sources":["../../src/docs/in-app-docs.docblock.ts"],"sourcesContent":[],"mappings":";;;;;;AAYA;;;;;;cAAa,WAAW"}
@@ -0,0 +1,65 @@
1
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
2
+
3
+ //#region src/docs/in-app-docs.docblock.ts
4
+ /**
5
+ * DocBlocks for the in-app documentation example.
6
+ *
7
+ * These blocks provide publicly visible guides aimed at non‑technical users.
8
+ * Each DocBlock is associated with a route under /docs/examples/in-app-docs
9
+ * and will be rendered in the ContractSpec sandbox or within your app if you
10
+ * integrate the documentation.
11
+ */
12
+ const inAppDocs = [{
13
+ id: "docs.examples.in-app-docs",
14
+ title: "In‑App Docs — Overview",
15
+ summary: "Overview of the in‑app documentation example demonstrating how DocBlock can serve end‑user guides.",
16
+ kind: "goal",
17
+ visibility: "public",
18
+ route: "/docs/examples/in-app-docs",
19
+ tags: [
20
+ "documentation",
21
+ "overview",
22
+ "guide"
23
+ ],
24
+ body: `## Purpose
25
+ The in‑app documentation example shows how you can use ContractSpec's DocBlock system to build user‑facing guides directly inside an application's UI.
26
+
27
+ Instead of relying solely on developer documentation, you can define **public** DocBlocks that describe your product's features in clear, non‑technical language. When embedded in your app, these blocks present a self‑contained help centre for users.
28
+
29
+ ## What you'll learn
30
+ * How to define DocBlock objects with public visibility and user‑friendly routes.
31
+ * How to structure an overview page for your in‑app guide using Markdown.
32
+ * How to register your DocBlocks so they show up in the sandbox and in your application.
33
+
34
+ Use this example as a template for documenting your own frontend workflows.`
35
+ }, {
36
+ id: "docs.examples.in-app-docs.usage",
37
+ title: "In‑App Docs — Using the Application",
38
+ summary: "Step‑by‑step guide for end users to navigate and use the example application.",
39
+ kind: "usage",
40
+ visibility: "public",
41
+ route: "/docs/examples/in-app-docs/usage",
42
+ tags: [
43
+ "documentation",
44
+ "usage",
45
+ "guide"
46
+ ],
47
+ body: `## Getting Started
48
+ 1. **Sign in**. Launch the app and enter your credentials. New users can click **Create Account** to register.
49
+ 2. **Explore the dashboard**. Use the sidebar or navigation bar to access sections like Dashboard, Profile, and Settings.
50
+ 3. **Add items**. On the Dashboard, click **Add Item** or a plus icon to create a new record. Fill in the form fields and press **Save**.
51
+
52
+ ## Tips
53
+ * Look for information icons (ℹ️) throughout the UI. Hover or click these icons to display contextual help powered by DocBlock.
54
+ * Use keyboard shortcuts—such as **Ctrl+S** to save or **Ctrl+K** to open the command palette—for quicker navigation.
55
+ * Need to find something quickly? Use the search bar or filters at the top of lists.
56
+
57
+ ## Next Steps
58
+ Continue exploring the different screens. Try editing or deleting items, adjusting your profile settings, or experimenting with filters.
59
+ This guide is available via the help menu inside the app, so you can reference it without leaving your workflow.`
60
+ }];
61
+ registerDocBlocks(inAppDocs);
62
+
63
+ //#endregion
64
+ export { inAppDocs };
65
+ //# sourceMappingURL=in-app-docs.docblock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-app-docs.docblock.js","names":[],"sources":["../../src/docs/in-app-docs.docblock.ts"],"sourcesContent":["import type { DocBlock } from '@contractspec/lib.contracts/docs';\nimport { registerDocBlocks } from '@contractspec/lib.contracts/docs';\n\n/**\n * DocBlocks for the in-app documentation example.\n *\n * These blocks provide publicly visible guides aimed at non‑technical users.\n * Each DocBlock is associated with a route under /docs/examples/in-app-docs\n * and will be rendered in the ContractSpec sandbox or within your app if you\n * integrate the documentation.\n */\n// Export the DocBlocks array so it can be reused by the UI layer.\nexport const inAppDocs: DocBlock[] = [\n {\n id: 'docs.examples.in-app-docs',\n title: 'In‑App Docs — Overview',\n summary:\n 'Overview of the in‑app documentation example demonstrating how DocBlock can serve end‑user guides.',\n kind: 'goal',\n visibility: 'public',\n route: '/docs/examples/in-app-docs',\n tags: ['documentation', 'overview', 'guide'],\n body: `## Purpose\nThe in‑app documentation example shows how you can use ContractSpec's DocBlock system to build user‑facing guides directly inside an application's UI.\n\nInstead of relying solely on developer documentation, you can define **public** DocBlocks that describe your product's features in clear, non‑technical language. When embedded in your app, these blocks present a self‑contained help centre for users.\n\n## What you'll learn\n* How to define DocBlock objects with public visibility and user‑friendly routes.\n* How to structure an overview page for your in‑app guide using Markdown.\n* How to register your DocBlocks so they show up in the sandbox and in your application.\n\nUse this example as a template for documenting your own frontend workflows.`,\n },\n {\n id: 'docs.examples.in-app-docs.usage',\n title: 'In‑App Docs — Using the Application',\n summary:\n 'Step‑by‑step guide for end users to navigate and use the example application.',\n kind: 'usage',\n visibility: 'public',\n route: '/docs/examples/in-app-docs/usage',\n tags: ['documentation', 'usage', 'guide'],\n body: `## Getting Started\n1. **Sign in**. Launch the app and enter your credentials. New users can click **Create Account** to register.\n2. **Explore the dashboard**. Use the sidebar or navigation bar to access sections like Dashboard, Profile, and Settings.\n3. **Add items**. On the Dashboard, click **Add Item** or a plus icon to create a new record. Fill in the form fields and press **Save**.\n\n## Tips\n* Look for information icons (ℹ️) throughout the UI. Hover or click these icons to display contextual help powered by DocBlock.\n* Use keyboard shortcuts—such as **Ctrl+S** to save or **Ctrl+K** to open the command palette—for quicker navigation.\n* Need to find something quickly? Use the search bar or filters at the top of lists.\n\n## Next Steps\nContinue exploring the different screens. Try editing or deleting items, adjusting your profile settings, or experimenting with filters.\nThis guide is available via the help menu inside the app, so you can reference it without leaving your workflow.`,\n },\n];\n\nregisterDocBlocks(inAppDocs);\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,YAAwB,CACnC;CACE,IAAI;CACJ,OAAO;CACP,SACE;CACF,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM;EAAC;EAAiB;EAAY;EAAQ;CAC5C,MAAM;;;;;;;;;;;CAWP,EACD;CACE,IAAI;CACJ,OAAO;CACP,SACE;CACF,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM;EAAC;EAAiB;EAAS;EAAQ;CACzC,MAAM;;;;;;;;;;;;;CAaP,CACF;AAED,kBAAkB,UAAU"}
@@ -0,0 +1 @@
1
+ import "./in-app-docs.docblock.js";
@@ -0,0 +1 @@
1
+ import "./in-app-docs.docblock.js";
@@ -0,0 +1,14 @@
1
+ import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
2
+
3
+ //#region src/example.d.ts
4
+
5
+ /**
6
+ * Example specification for the in-app documentation example.
7
+ *
8
+ * This example demonstrates how to use DocBlock to build public documentation
9
+ * aimed at end users directly within the application UI.
10
+ */
11
+ declare const example: _contractspec_lib_contracts0.ExampleSpec;
12
+ //#endregion
13
+ export { example as default };
14
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.d.ts","names":[],"sources":["../src/example.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQa;;;cAAP,SA0CJ,4BAAA,CA1CW"}
@@ -0,0 +1,53 @@
1
+ import { defineExample } from "@contractspec/lib.contracts";
2
+
3
+ //#region src/example.ts
4
+ /**
5
+ * Example specification for the in-app documentation example.
6
+ *
7
+ * This example demonstrates how to use DocBlock to build public documentation
8
+ * aimed at end users directly within the application UI.
9
+ */
10
+ const example = defineExample({
11
+ meta: {
12
+ key: "in-app-docs",
13
+ version: "1.0.0",
14
+ title: "In‑App Documentation Example",
15
+ description: "Demonstrates using DocBlock to create user‑facing guides that live inside your application's frontend. It shows how to structure a public, non‑technical user guide using ContractSpec.",
16
+ kind: "ui",
17
+ visibility: "public",
18
+ stability: "experimental",
19
+ owners: ["@docs-team"],
20
+ tags: [
21
+ "documentation",
22
+ "guide",
23
+ "ui"
24
+ ]
25
+ },
26
+ docs: {
27
+ rootDocId: "docs.examples.in-app-docs",
28
+ usageDocId: "docs.examples.in-app-docs.usage",
29
+ goalDocId: "docs.examples.in-app-docs"
30
+ },
31
+ entrypoints: {
32
+ packageName: "@contractspec/example.in-app-docs",
33
+ docs: "./docs",
34
+ ui: "./ui"
35
+ },
36
+ surfaces: {
37
+ templates: false,
38
+ sandbox: {
39
+ enabled: true,
40
+ modes: ["markdown"]
41
+ },
42
+ studio: {
43
+ enabled: false,
44
+ installable: false
45
+ },
46
+ mcp: { enabled: false }
47
+ }
48
+ });
49
+ var example_default = example;
50
+
51
+ //#endregion
52
+ export { example_default as default };
53
+ //# sourceMappingURL=example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.js","names":[],"sources":["../src/example.ts"],"sourcesContent":["import { defineExample } from '@contractspec/lib.contracts';\n\n/**\n * Example specification for the in-app documentation example.\n *\n * This example demonstrates how to use DocBlock to build public documentation\n * aimed at end users directly within the application UI.\n */\nconst example = defineExample({\n meta: {\n key: 'in-app-docs',\n version: '1.0.0',\n title: 'In‑App Documentation Example',\n description:\n \"Demonstrates using DocBlock to create user‑facing guides that live inside your application's frontend. It shows how to structure a public, non‑technical user guide using ContractSpec.\",\n kind: 'ui',\n visibility: 'public',\n stability: 'experimental',\n owners: ['@docs-team'],\n tags: ['documentation', 'guide', 'ui'],\n },\n docs: {\n // Root documentation page; clicking on the example in the docs navigation\n // will display this page.\n rootDocId: 'docs.examples.in-app-docs',\n // Explicitly set usage documentation id for quickstart/guide sections.\n usageDocId: 'docs.examples.in-app-docs.usage',\n // Provide a goal document describing the purpose of this example.\n goalDocId: 'docs.examples.in-app-docs',\n },\n entrypoints: {\n // Package name used for the example's compiled output.\n packageName: '@contractspec/example.in-app-docs',\n // Documentation entrypoint folder; compiled docs will be published under this path.\n docs: './docs',\n // UI entrypoint exposes the in-app documentation viewer component.\n ui: './ui',\n },\n surfaces: {\n // This example is not a template for new projects.\n templates: false,\n // Enable sandbox with only the markdown mode so users can view the docblocks.\n sandbox: {\n enabled: true,\n modes: ['markdown'],\n },\n // Studio/MCP not required for this simple documentation example.\n studio: { enabled: false, installable: false },\n mcp: { enabled: false },\n },\n});\n\nexport default example;\n"],"mappings":";;;;;;;;;AAQA,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,MAAM;EACN,YAAY;EACZ,WAAW;EACX,QAAQ,CAAC,aAAa;EACtB,MAAM;GAAC;GAAiB;GAAS;GAAK;EACvC;CACD,MAAM;EAGJ,WAAW;EAEX,YAAY;EAEZ,WAAW;EACZ;CACD,aAAa;EAEX,aAAa;EAEb,MAAM;EAEN,IAAI;EACL;CACD,UAAU;EAER,WAAW;EAEX,SAAS;GACP,SAAS;GACT,OAAO,CAAC,WAAW;GACpB;EAED,QAAQ;GAAE,SAAS;GAAO,aAAa;GAAO;EAC9C,KAAK,EAAE,SAAS,OAAO;EACxB;CACF,CAAC;AAEF,sBAAe"}
@@ -0,0 +1,5 @@
1
+ import "./docs/index.js";
2
+ import example from "./example.js";
3
+ import InAppDocsViewer from "./ui/InAppDocsViewer.js";
4
+ import "./ui/index.js";
5
+ export { InAppDocsViewer, example };
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import example_default from "./example.js";
2
+ import InAppDocsViewer_default from "./ui/InAppDocsViewer.js";
3
+ import "./ui/index.js";
4
+ import "./docs/index.js";
5
+
6
+ export { InAppDocsViewer_default as InAppDocsViewer, example_default as example };
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+
3
+ //#region src/ui/InAppDocsViewer.d.ts
4
+
5
+ /**
6
+ * InAppDocsViewer renders a simple navigation and content area for the example's DocBlocks.
7
+ * Users can click titles on the left to switch between documentation pages.
8
+ */
9
+ declare const InAppDocsViewer: React.FC;
10
+ //#endregion
11
+ export { InAppDocsViewer as default };
12
+ //# sourceMappingURL=InAppDocsViewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InAppDocsViewer.d.ts","names":[],"sources":["../../src/ui/InAppDocsViewer.tsx"],"sourcesContent":[],"mappings":";;;;;;AAEwC;;cASlC,iBAAiB,KAAA,CAAM"}
@@ -0,0 +1,67 @@
1
+ 'use client';
2
+
3
+ import { inAppDocs } from "../docs/in-app-docs.docblock.js";
4
+ import React, { useState } from "react";
5
+ import { MarkdownRenderer } from "@contractspec/lib.example-shared-ui";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+
8
+ //#region src/ui/InAppDocsViewer.tsx
9
+ /**
10
+ * InAppDocsViewer renders a simple navigation and content area for the example's DocBlocks.
11
+ * Users can click titles on the left to switch between documentation pages.
12
+ */
13
+ const InAppDocsViewer = () => {
14
+ const [activeId, setActiveId] = useState(inAppDocs[0]?.id ?? "");
15
+ const activeDoc = inAppDocs.find((doc) => doc.id === activeId);
16
+ return /* @__PURE__ */ jsxs("div", {
17
+ style: {
18
+ display: "flex",
19
+ height: "100%",
20
+ gap: "1rem"
21
+ },
22
+ children: [/* @__PURE__ */ jsx("nav", {
23
+ style: {
24
+ width: "220px",
25
+ borderRight: "1px solid #eee"
26
+ },
27
+ children: /* @__PURE__ */ jsx("ul", {
28
+ style: {
29
+ listStyle: "none",
30
+ padding: 0,
31
+ margin: 0
32
+ },
33
+ children: inAppDocs.map((doc) => /* @__PURE__ */ jsx("li", {
34
+ style: { marginBottom: "0.5rem" },
35
+ children: /* @__PURE__ */ jsx("button", {
36
+ onClick: () => setActiveId(doc.id),
37
+ style: {
38
+ background: doc.id === activeId ? "#f0f0f0" : "transparent",
39
+ border: "none",
40
+ padding: "0.5rem 0.75rem",
41
+ cursor: "pointer",
42
+ textAlign: "left",
43
+ width: "100%"
44
+ },
45
+ children: doc.title
46
+ })
47
+ }, doc.id))
48
+ })
49
+ }), /* @__PURE__ */ jsx("main", {
50
+ style: {
51
+ flexGrow: 1,
52
+ padding: "1rem",
53
+ overflowY: "auto"
54
+ },
55
+ children: activeDoc && /* @__PURE__ */ jsxs(Fragment, { children: [
56
+ /* @__PURE__ */ jsx("h1", { children: activeDoc.title }),
57
+ /* @__PURE__ */ jsx(MarkdownRenderer, { content: activeDoc.body }),
58
+ ";"
59
+ ] })
60
+ })]
61
+ });
62
+ };
63
+ var InAppDocsViewer_default = InAppDocsViewer;
64
+
65
+ //#endregion
66
+ export { InAppDocsViewer_default as default };
67
+ //# sourceMappingURL=InAppDocsViewer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InAppDocsViewer.js","names":[],"sources":["../../src/ui/InAppDocsViewer.tsx"],"sourcesContent":["'use client';\n\nimport React, { useState } from 'react';\n// import ReactMarkdown from 'react-markdown';\nimport { inAppDocs } from '../docs/in-app-docs.docblock';\nimport { MarkdownRenderer } from '@contractspec/lib.example-shared-ui';\n\n/**\n * InAppDocsViewer renders a simple navigation and content area for the example's DocBlocks.\n * Users can click titles on the left to switch between documentation pages.\n */\nconst InAppDocsViewer: React.FC = () => {\n const [activeId, setActiveId] = useState<string>(inAppDocs[0]?.id ?? '');\n\n const activeDoc = inAppDocs.find((doc) => doc.id === activeId);\n\n return (\n <div style={{ display: 'flex', height: '100%', gap: '1rem' }}>\n <nav style={{ width: '220px', borderRight: '1px solid #eee' }}>\n <ul style={{ listStyle: 'none', padding: 0, margin: 0 }}>\n {inAppDocs.map((doc) => (\n <li key={doc.id} style={{ marginBottom: '0.5rem' }}>\n <button\n onClick={() => setActiveId(doc.id)}\n style={{\n background: doc.id === activeId ? '#f0f0f0' : 'transparent',\n border: 'none',\n padding: '0.5rem 0.75rem',\n cursor: 'pointer',\n textAlign: 'left',\n width: '100%',\n }}\n >\n {doc.title}\n </button>\n </li>\n ))}\n </ul>\n </nav>\n <main style={{ flexGrow: 1, padding: '1rem', overflowY: 'auto' }}>\n {activeDoc && (\n <>\n <h1>{activeDoc.title}</h1>\n <MarkdownRenderer content={activeDoc.body} />;\n </>\n )}\n </main>\n </div>\n );\n};\n\nexport default InAppDocsViewer;\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,wBAAkC;CACtC,MAAM,CAAC,UAAU,eAAe,SAAiB,UAAU,IAAI,MAAM,GAAG;CAExE,MAAM,YAAY,UAAU,MAAM,QAAQ,IAAI,OAAO,SAAS;AAE9D,QACE,qBAAC;EAAI,OAAO;GAAE,SAAS;GAAQ,QAAQ;GAAQ,KAAK;GAAQ;aAC1D,oBAAC;GAAI,OAAO;IAAE,OAAO;IAAS,aAAa;IAAkB;aAC3D,oBAAC;IAAG,OAAO;KAAE,WAAW;KAAQ,SAAS;KAAG,QAAQ;KAAG;cACpD,UAAU,KAAK,QACd,oBAAC;KAAgB,OAAO,EAAE,cAAc,UAAU;eAChD,oBAAC;MACC,eAAe,YAAY,IAAI,GAAG;MAClC,OAAO;OACL,YAAY,IAAI,OAAO,WAAW,YAAY;OAC9C,QAAQ;OACR,SAAS;OACT,QAAQ;OACR,WAAW;OACX,OAAO;OACR;gBAEA,IAAI;OACE;OAbF,IAAI,GAcR,CACL;KACC;IACD,EACN,oBAAC;GAAK,OAAO;IAAE,UAAU;IAAG,SAAS;IAAQ,WAAW;IAAQ;aAC7D,aACC;IACE,oBAAC,kBAAI,UAAU,QAAW;IAC1B,oBAAC,oBAAiB,SAAS,UAAU,OAAQ;;OAC5C;IAEA;GACH;;AAIV,8BAAe"}
@@ -0,0 +1,2 @@
1
+ import InAppDocsViewer from "./InAppDocsViewer.js";
2
+ export { InAppDocsViewer };
@@ -0,0 +1,3 @@
1
+ import InAppDocsViewer_default from "./InAppDocsViewer.js";
2
+
3
+ export { InAppDocsViewer_default as InAppDocsViewer };
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@contractspec/example.in-app-docs",
3
+ "version": "1.1.0",
4
+ "description": "Example showing how to use DocBlock for in-app documentation for non-technical users",
5
+ "type": "module",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": "./dist/index.js",
9
+ "./docs": "./dist/docs/index.js",
10
+ "./docs/in-app-docs.docblock": "./dist/docs/in-app-docs.docblock.js",
11
+ "./example": "./dist/example.js",
12
+ "./ui": "./dist/ui/index.js",
13
+ "./ui/InAppDocsViewer": "./dist/ui/InAppDocsViewer.js",
14
+ "./*": "./*"
15
+ },
16
+ "scripts": {
17
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
18
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
19
+ "build": "bun build:types && bun build:bundle",
20
+ "build:bundle": "tsdown",
21
+ "build:types": "tsc --noEmit",
22
+ "dev": "bun build:bundle --watch",
23
+ "clean": "rimraf dist .turbo",
24
+ "lint": "bun lint:fix",
25
+ "lint:fix": "eslint src --fix",
26
+ "lint:check": "eslint src",
27
+ "test": "bun test"
28
+ },
29
+ "dependencies": {
30
+ "@contractspec/lib.contracts": "1.54.0",
31
+ "@contractspec/lib.example-shared-ui": "1.8.0",
32
+ "react": "19.2.4",
33
+ "react-dom": "19.2.4"
34
+ },
35
+ "devDependencies": {
36
+ "@contractspec/tool.tsdown": "1.54.0",
37
+ "@contractspec/tool.typescript": "1.54.0",
38
+ "tsdown": "^0.19.0",
39
+ "typescript": "^5.9.3",
40
+ "@types/react": "^19.2.8",
41
+ "@types/react-dom": "^19.2.2"
42
+ },
43
+ "publishConfig": {
44
+ "exports": {
45
+ ".": "./dist/index.js",
46
+ "./docs": "./dist/docs/index.js",
47
+ "./docs/in-app-docs.docblock": "./dist/docs/in-app-docs.docblock.js",
48
+ "./example": "./dist/example.js",
49
+ "./ui": "./dist/ui/index.js",
50
+ "./*": "./*"
51
+ },
52
+ "registry": "https://registry.npmjs.org/",
53
+ "access": "public"
54
+ },
55
+ "license": "MIT",
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "https://github.com/lssm-tech/contractspec.git",
59
+ "directory": "packages/examples/in-app-docs"
60
+ },
61
+ "homepage": "https://contractspec.io"
62
+ }
@@ -0,0 +1,60 @@
1
+ import type { DocBlock } from '@contractspec/lib.contracts/docs';
2
+ import { registerDocBlocks } from '@contractspec/lib.contracts/docs';
3
+
4
+ /**
5
+ * DocBlocks for the in-app documentation example.
6
+ *
7
+ * These blocks provide publicly visible guides aimed at non‑technical users.
8
+ * Each DocBlock is associated with a route under /docs/examples/in-app-docs
9
+ * and will be rendered in the ContractSpec sandbox or within your app if you
10
+ * integrate the documentation.
11
+ */
12
+ // Export the DocBlocks array so it can be reused by the UI layer.
13
+ export const inAppDocs: DocBlock[] = [
14
+ {
15
+ id: 'docs.examples.in-app-docs',
16
+ title: 'In‑App Docs — Overview',
17
+ summary:
18
+ 'Overview of the in‑app documentation example demonstrating how DocBlock can serve end‑user guides.',
19
+ kind: 'goal',
20
+ visibility: 'public',
21
+ route: '/docs/examples/in-app-docs',
22
+ tags: ['documentation', 'overview', 'guide'],
23
+ body: `## Purpose
24
+ The in‑app documentation example shows how you can use ContractSpec's DocBlock system to build user‑facing guides directly inside an application's UI.
25
+
26
+ Instead of relying solely on developer documentation, you can define **public** DocBlocks that describe your product's features in clear, non‑technical language. When embedded in your app, these blocks present a self‑contained help centre for users.
27
+
28
+ ## What you'll learn
29
+ * How to define DocBlock objects with public visibility and user‑friendly routes.
30
+ * How to structure an overview page for your in‑app guide using Markdown.
31
+ * How to register your DocBlocks so they show up in the sandbox and in your application.
32
+
33
+ Use this example as a template for documenting your own frontend workflows.`,
34
+ },
35
+ {
36
+ id: 'docs.examples.in-app-docs.usage',
37
+ title: 'In‑App Docs — Using the Application',
38
+ summary:
39
+ 'Step‑by‑step guide for end users to navigate and use the example application.',
40
+ kind: 'usage',
41
+ visibility: 'public',
42
+ route: '/docs/examples/in-app-docs/usage',
43
+ tags: ['documentation', 'usage', 'guide'],
44
+ body: `## Getting Started
45
+ 1. **Sign in**. Launch the app and enter your credentials. New users can click **Create Account** to register.
46
+ 2. **Explore the dashboard**. Use the sidebar or navigation bar to access sections like Dashboard, Profile, and Settings.
47
+ 3. **Add items**. On the Dashboard, click **Add Item** or a plus icon to create a new record. Fill in the form fields and press **Save**.
48
+
49
+ ## Tips
50
+ * Look for information icons (ℹ️) throughout the UI. Hover or click these icons to display contextual help powered by DocBlock.
51
+ * Use keyboard shortcuts—such as **Ctrl+S** to save or **Ctrl+K** to open the command palette—for quicker navigation.
52
+ * Need to find something quickly? Use the search bar or filters at the top of lists.
53
+
54
+ ## Next Steps
55
+ Continue exploring the different screens. Try editing or deleting items, adjusting your profile settings, or experimenting with filters.
56
+ This guide is available via the help menu inside the app, so you can reference it without leaving your workflow.`,
57
+ },
58
+ ];
59
+
60
+ registerDocBlocks(inAppDocs);
@@ -0,0 +1,2 @@
1
+ // Register all DocBlocks for the in-app documentation example.
2
+ import './in-app-docs.docblock';
package/src/example.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { defineExample } from '@contractspec/lib.contracts';
2
+
3
+ /**
4
+ * Example specification for the in-app documentation example.
5
+ *
6
+ * This example demonstrates how to use DocBlock to build public documentation
7
+ * aimed at end users directly within the application UI.
8
+ */
9
+ const example = defineExample({
10
+ meta: {
11
+ key: 'in-app-docs',
12
+ version: '1.0.0',
13
+ title: 'In‑App Documentation Example',
14
+ description:
15
+ "Demonstrates using DocBlock to create user‑facing guides that live inside your application's frontend. It shows how to structure a public, non‑technical user guide using ContractSpec.",
16
+ kind: 'ui',
17
+ visibility: 'public',
18
+ stability: 'experimental',
19
+ owners: ['@docs-team'],
20
+ tags: ['documentation', 'guide', 'ui'],
21
+ },
22
+ docs: {
23
+ // Root documentation page; clicking on the example in the docs navigation
24
+ // will display this page.
25
+ rootDocId: 'docs.examples.in-app-docs',
26
+ // Explicitly set usage documentation id for quickstart/guide sections.
27
+ usageDocId: 'docs.examples.in-app-docs.usage',
28
+ // Provide a goal document describing the purpose of this example.
29
+ goalDocId: 'docs.examples.in-app-docs',
30
+ },
31
+ entrypoints: {
32
+ // Package name used for the example's compiled output.
33
+ packageName: '@contractspec/example.in-app-docs',
34
+ // Documentation entrypoint folder; compiled docs will be published under this path.
35
+ docs: './docs',
36
+ // UI entrypoint exposes the in-app documentation viewer component.
37
+ ui: './ui',
38
+ },
39
+ surfaces: {
40
+ // This example is not a template for new projects.
41
+ templates: false,
42
+ // Enable sandbox with only the markdown mode so users can view the docblocks.
43
+ sandbox: {
44
+ enabled: true,
45
+ modes: ['markdown'],
46
+ },
47
+ // Studio/MCP not required for this simple documentation example.
48
+ studio: { enabled: false, installable: false },
49
+ mcp: { enabled: false },
50
+ },
51
+ });
52
+
53
+ export default example;
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ // In-App Documentation Example
2
+ // Exports the example metadata and registers documentation.
3
+
4
+ // Export example spec
5
+ export { default as example } from './example';
6
+
7
+ // Export UI components
8
+ export * from './ui';
9
+
10
+ // Import docs to register doc blocks on load
11
+ import './docs';
@@ -0,0 +1,52 @@
1
+ 'use client';
2
+
3
+ import React, { useState } from 'react';
4
+ // import ReactMarkdown from 'react-markdown';
5
+ import { inAppDocs } from '../docs/in-app-docs.docblock';
6
+ import { MarkdownRenderer } from '@contractspec/lib.example-shared-ui';
7
+
8
+ /**
9
+ * InAppDocsViewer renders a simple navigation and content area for the example's DocBlocks.
10
+ * Users can click titles on the left to switch between documentation pages.
11
+ */
12
+ const InAppDocsViewer: React.FC = () => {
13
+ const [activeId, setActiveId] = useState<string>(inAppDocs[0]?.id ?? '');
14
+
15
+ const activeDoc = inAppDocs.find((doc) => doc.id === activeId);
16
+
17
+ return (
18
+ <div style={{ display: 'flex', height: '100%', gap: '1rem' }}>
19
+ <nav style={{ width: '220px', borderRight: '1px solid #eee' }}>
20
+ <ul style={{ listStyle: 'none', padding: 0, margin: 0 }}>
21
+ {inAppDocs.map((doc) => (
22
+ <li key={doc.id} style={{ marginBottom: '0.5rem' }}>
23
+ <button
24
+ onClick={() => setActiveId(doc.id)}
25
+ style={{
26
+ background: doc.id === activeId ? '#f0f0f0' : 'transparent',
27
+ border: 'none',
28
+ padding: '0.5rem 0.75rem',
29
+ cursor: 'pointer',
30
+ textAlign: 'left',
31
+ width: '100%',
32
+ }}
33
+ >
34
+ {doc.title}
35
+ </button>
36
+ </li>
37
+ ))}
38
+ </ul>
39
+ </nav>
40
+ <main style={{ flexGrow: 1, padding: '1rem', overflowY: 'auto' }}>
41
+ {activeDoc && (
42
+ <>
43
+ <h1>{activeDoc.title}</h1>
44
+ <MarkdownRenderer content={activeDoc.body} />;
45
+ </>
46
+ )}
47
+ </main>
48
+ </div>
49
+ );
50
+ };
51
+
52
+ export default InAppDocsViewer;
@@ -0,0 +1,2 @@
1
+ // Export the in-app documentation viewer component
2
+ export { default as InAppDocsViewer } from './InAppDocsViewer';
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@contractspec/tool.typescript/react-library.json",
3
+ "include": ["src"],
4
+ "exclude": ["node_modules", "dist"],
5
+ "compilerOptions": {
6
+ "rootDir": "src",
7
+ "outDir": "dist"
8
+ }
9
+ }
10
+