Skip to content

Commit c865eaf

Browse files
xuyushun441-sysos-zhuangclaude
authored
docs(metadata): doc-type authoring guide + objectstack-ui skill (ADR-0046) (#1807)
* docs(metadata): doc-type authoring guide + objectstack-ui skill coverage (ADR-0046) Package docs (ADR-0046) shipped framework-side (collection + render) and a showcase example (#1793), but the developer docs site and AI skills never mentioned the `doc` metadata type. Close that gap: - New guide content/docs/guides/metadata/doc.mdx — flat src/docs/*.md authoring, namespace-prefixed naming, the platform-level /docs/<name> routing model (no per-app/per-package URL nesting), cross-references, and the MDX/image build bans. - List `doc` in the metadata index table + sidebar (meta.json). - objectstack-ui skill: new "Docs — Package Documentation" section so AI agents author src/docs/*.md correctly (flat dir, prefix, CommonMark+GFM, link-don't-embed for dynamic content), plus description/tags coverage. Docs/skill only — no package code. Frontend /docs route + nav entry remain the objectui P2 follow-up. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: empty changeset (docs/skill only, no package release) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9c6aa12 commit c865eaf

5 files changed

Lines changed: 267 additions & 4 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
---
3+
4+
docs(metadata): ADR-0046 — add the `doc`-type authoring guide
5+
(`content/docs/guides/metadata/doc.mdx` + index/sidebar) and cover package
6+
docs in the objectstack-ui skill. Documentation and AI-skill content only;
7+
no package release.
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
title: Doc Metadata
3+
description: Ship package documentation as metadata — flat src/docs/*.md files compiled into the manifest and rendered in the console
4+
---
5+
6+
# Doc Metadata
7+
8+
A **Doc** is a single page of package documentation. You write plain
9+
Markdown files in a flat `src/docs/` directory; `os build` compiles each
10+
one into a `doc` metadata item that ships inside the package artifact and
11+
renders in the console at `/docs/<name>`. Docs are also the grounding the
12+
AI assistant reads when answering questions about your package.
13+
14+
Unlike `content/docs/` (which builds a standalone website), package docs
15+
are **package source** — they travel with the package, version with it,
16+
and are addressable as metadata like any Object or View.
17+
18+
## Authoring: flat `src/docs/*.md`
19+
20+
The normal way to author a doc is to drop a Markdown file in `src/docs/`:
21+
22+
```
23+
src/docs/
24+
crm_index.md → doc name "crm_index"
25+
crm_user_guide.md → doc name "crm_user_guide"
26+
```
27+
28+
The filename stem becomes the doc `name`. There is no directory taxonomy
29+
and no ordering file — the flat layout is what keeps cross-references
30+
stable (a link resolves by basename, never by path).
31+
32+
### Frontmatter
33+
34+
A leading YAML frontmatter block is optional. Only `title` is read:
35+
36+
```md
37+
---
38+
title: User Guide
39+
---
40+
41+
# Getting started with CRM
42+
...
43+
```
44+
45+
The display title resolves in order: frontmatter `title:` → the first
46+
`#` heading → the doc `name`.
47+
48+
## Doc Properties
49+
50+
When a `*.md` file is collected, it becomes a `doc` item with this shape:
51+
52+
| Property | Type | Required | Description |
53+
| :--- | :--- | :--- | :--- |
54+
| `name` | `string` || Machine name (`snake_case`), from the filename stem. Must match `^[a-z][a-z0-9_]*$` and be **namespace-prefixed** |
55+
| `label` | `string` || Display title (from frontmatter `title`) |
56+
| `content` | `string` || The Markdown body |
57+
58+
You can also declare a doc programmatically with `DocSchema` in a stack
59+
definition's `docs` array, but the `src/docs/*.md` path is the convention
60+
— it gives you native editor and GitHub preview for free.
61+
62+
## Naming and routing
63+
64+
Doc names live in the same flat, instance-global namespace as the URL.
65+
The console route is **single-coordinate**`/docs/<name>`, with no
66+
package or app prefix — so a doc has exactly one URL no matter who links
67+
it.
68+
69+
That only works if names don't collide, so the build requires every doc
70+
name to be **namespace-prefixed**:
71+
72+
```
73+
src/docs/crm_user_guide.md ✅ package namespace is "crm"
74+
src/docs/user_guide.md ❌ bare name — collides across packages
75+
```
76+
77+
This is the same uniqueness rule the platform already applies to other
78+
named metadata (ADR-0048). Two packages that both ship `user_guide` would
79+
overwrite each other on the registry key and fail at install; the prefix
80+
makes the collision impossible.
81+
82+
> **Routing model.** The viewer is platform-level: one global
83+
> `/docs/<name>` route resolves any doc regardless of which app you came
84+
> from. Anything that wants to *link into* docs — an app's navigation, a
85+
> registry package page, an agent's answer — does so with that same URL.
86+
> Per-app or per-package URL nesting is explicitly **not** the model
87+
> (it would give one doc many URLs and break cross-references).
88+
89+
## Cross-references
90+
91+
Link to a sibling doc with a plain relative Markdown link:
92+
93+
```md
94+
See the [overview](./crm_index.md).
95+
```
96+
97+
The console rewrites `*.md` links to `/docs/<target>` (anchors are
98+
preserved); in an editor or on GitHub the same link resolves natively.
99+
**Broken same-package links fail the build**, so references can't rot
100+
silently.
101+
102+
## Markdown support
103+
104+
Docs render **CommonMark + GFM** through a sanitizing pipeline. Supported
105+
out of the box:
106+
107+
- Standard Markdown — headings, lists, tables, blockquotes, inline/fenced
108+
code, links.
109+
- **Heading anchors** — every heading gets a slug id and a hover anchor,
110+
so `#section` deep-links work.
111+
- **Syntax highlighting** — fenced code blocks are highlighted by
112+
language.
113+
- **GitHub alerts**`> [!NOTE]`, `> [!TIP]`, `> [!WARNING]`, etc.
114+
render as callouts.
115+
116+
Two things are **rejected at build time**, by design:
117+
118+
- **MDX / embedded components.** Docs are publisher-supplied content
119+
rendered inside the platform; executing authored code would cross a
120+
trust boundary. Markdown is data, not code.
121+
- **Image references.** Images need a content-addressed asset service
122+
(a later, additive concern). Until then, `![...](...)` fails the build
123+
rather than producing broken `<img>` tags in a tenant.
124+
125+
For dynamic content (a live flow diagram, a record table), don't try to
126+
embed a component — link to the metadata by URL instead. The platform
127+
renders the live view; the doc just points at it.
128+
129+
## Example
130+
131+
```md
132+
---
133+
title: CRM Overview
134+
---
135+
136+
# CRM
137+
138+
The CRM package manages accounts, contacts, and opportunities.
139+
140+
> [!TIP]
141+
> New here? Start with the [user guide](./crm_user_guide.md).
142+
143+
## Objects
144+
145+
| Object | Purpose |
146+
| :--- | :--- |
147+
| `crm_account` | Companies and organizations |
148+
| `crm_contact` | People at an account |
149+
```
150+
151+
Saved as `src/docs/crm_index.md`, this compiles to a `crm_index` doc and
152+
renders at `/docs/crm_index`.
153+
154+
## Next Steps
155+
156+
- See the in-repo authoring reference in the showcase package:
157+
`examples/app-showcase/src/docs/showcase_docs_guide.md`.
158+
- Read [ADR-0046](https://github.com/objectstack-ai/framework/blob/main/docs/adr/0046-package-docs-as-metadata.md)
159+
for the full design rationale and rollout phases.

content/docs/guides/metadata/index.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ Define access control and data visibility.
4949
| :--- | :--- | :--- |
5050
| [**Permission**](./permission) | Permission sets — object CRUD, field security, tab visibility | `*.permission.ts` / `*.permission.yml` |
5151

52+
### Documentation Layer
53+
54+
Ship package documentation that travels and versions with the package.
55+
56+
| Metadata Type | Description | File Convention |
57+
| :--- | :--- | :--- |
58+
| [**Doc**](./doc) | Package documentation pages — flat Markdown, rendered at `/docs/<name>` | `src/docs/*.md` |
59+
5260
## How Metadata Works Together
5361

5462
```

content/docs/guides/metadata/meta.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"flow",
1212
"workflow",
1313
"validation",
14-
"permission"
14+
"permission",
15+
"doc"
1516
]
1617
}

skills/objectstack-ui/SKILL.md

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
name: objectstack-ui
33
description: >
44
Author ObjectStack UI metadata — Views (list/form/kanban/calendar/gantt),
5-
Apps (navigation), Pages, Dashboards, Reports, Charts, Actions. Use when
5+
Apps (navigation), Pages, Dashboards, Reports, Charts, Actions, and
6+
package Docs (`src/docs/*.md`). Use when
67
the user is adding `*.view.ts` / `*.app.ts` / `*.dashboard.ts` /
7-
`*.action.ts` files or designing a Studio-rendered UI surface, including
8+
`*.action.ts` / `src/docs/*.md` files or designing a Studio-rendered UI
9+
surface, including
810
dataset-bound dashboard/report widgets. Do not use for: data schema (see
911
objectstack-data), interactive screen flows /
1012
wizards (those are `*.flow.ts` with `type: 'screen'` — see
@@ -18,7 +20,7 @@ metadata:
1820
author: objectstack-ai
1921
version: "1.1"
2022
domain: ui
21-
tags: view, app, page, dashboard, report, chart, action, widget
23+
tags: view, app, page, dashboard, report, chart, action, widget, doc
2224
---
2325

2426
# UI Design — ObjectStack UI Protocol
@@ -37,6 +39,8 @@ App navigation, Dashboards, Reports, and Actions.
3739
- You need a **dashboard** with widget grids.
3840
- You are adding **reports** (tabular, summary, matrix, chart).
3941
- You are configuring **actions** (buttons, URL jumps, screen flows).
42+
- You are writing **package documentation** (`src/docs/*.md`) that ships
43+
with the package and renders at `/docs/<name>`.
4044

4145
---
4246

@@ -616,6 +620,90 @@ export const LeadDetailPage: Page = {
616620
617621
---
618622

623+
## Docs — Package Documentation (ADR-0046)
624+
625+
A **Doc** is a page of package documentation shipped *as metadata*. You
626+
author plain Markdown in a flat `src/docs/` directory; `os build`
627+
compiles each `*.md` into a `doc` item that travels inside the package
628+
artifact and renders in the console at `/docs/<name>`. Docs are also the
629+
grounding the AI assistant reads about a package.
630+
631+
```
632+
src/docs/
633+
crm_index.md → doc "crm_index" → /docs/crm_index
634+
crm_user_guide.md → doc "crm_user_guide" → /docs/crm_user_guide
635+
```
636+
637+
### Authoring rules (each enforced by `os build`)
638+
639+
1. **Flat directory.** Every `.md` lives directly in `src/docs/`;
640+
subdirectories are a build error. Flatness is what keeps links stable
641+
— a reference resolves by basename, never by path.
642+
2. **Namespace-prefixed filename.** The filename stem becomes the doc
643+
`name` (`^[a-z][a-z0-9_]*$`) and must start with the package namespace
644+
(`crm_…`). Names share one flat, instance-global space with the URL, so
645+
a bare `user_guide` would collide across packages and fail at install
646+
(ADR-0048).
647+
3. **Title** resolves: frontmatter `title:` → first `#` heading → `name`.
648+
4. **Pure Markdown.** CommonMark + GFM only, plus heading anchors, fenced
649+
code highlighting, and GitHub alerts (`> [!NOTE]`, `> [!WARNING]`, …).
650+
**MDX and image references are rejected at build time** — docs are
651+
publisher content rendered inside the platform (no authored code across
652+
the trust boundary; images await a content-addressed asset service).
653+
5. **Cross-references** use plain relative links — `[overview](./crm_index.md)`.
654+
The console rewrites `*.md``/docs/<target>` (anchors preserved);
655+
broken same-package links fail the build.
656+
657+
### Routing model — platform-level viewer, opt-in entry
658+
659+
The viewer is **platform-level**: one global `/docs/<name>` route
660+
resolves any doc regardless of which app you came from. The URL is
661+
**single-coordinate** — no package or app prefix — so a doc has exactly
662+
one URL. Do **not** design per-app or per-package doc URLs; that gives one
663+
doc many addresses and breaks cross-references.
664+
665+
To surface a doc inside an app, add a navigation item that **links into**
666+
that global URL. There is no dedicated `doc` nav-item type yet, so use a
667+
`url` item pointing at `/docs/<name>`:
668+
669+
```typescript
670+
navigation: [
671+
{ id: 'nav_help', type: 'url', url: '/docs/crm_user_guide',
672+
label: 'User Guide', icon: 'book-open' },
673+
]
674+
```
675+
676+
A platform-level "Documentation" portal (browse/search all docs by
677+
package) is a later, additive concern — author-side, nothing to model now.
678+
679+
> **Dynamic content.** Don't try to embed a live component (a flow
680+
> diagram, a record table) in a doc — there is no inline SDUI. Link to the
681+
> metadata by URL; the platform renders the live view, the doc points at it.
682+
683+
### Example
684+
685+
```md
686+
---
687+
title: CRM Overview
688+
---
689+
690+
# CRM
691+
692+
Manages accounts, contacts, and opportunities.
693+
694+
> [!TIP]
695+
> New here? Start with the [user guide](./crm_user_guide.md).
696+
697+
| Object | Purpose |
698+
| :--- | :--- |
699+
| `crm_account` | Companies and organizations |
700+
| `crm_contact` | People at an account |
701+
```
702+
703+
In-repo reference: `examples/app-showcase/src/docs/showcase_docs_guide.md`.
704+
705+
---
706+
619707
## CRM UI Blueprint (Metadata-First)
620708

621709
Use this CRM-style structure as the canonical UI assembly reference:

0 commit comments

Comments
 (0)