Skip to content

Documentation for dev and copilot #4384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 64 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
9db5e8b
feat(doc): add basic copilot-instructions.md and llms.txt
michaelmkraus Jun 12, 2025
ea41c1f
chore(): add typedoc to project
michaelmkraus Jun 16, 2025
fdfb88e
chore(): add basic adr for copilot documentation
michaelmkraus Jun 16, 2025
006ca98
docs(): add some documentation for component to test generation with …
michaelmkraus Jun 16, 2025
5b34e33
feat(): add postinstall script to copy copilot instruction to corresp…
michaelmkraus Jun 16, 2025
93076c2
docs: document automated postinstall propagation of copilot-instructi…
michaelmkraus Jun 18, 2025
314cd06
feat: add generate-copilot-instructions script with PascalCase folder…
michaelmkraus Jun 18, 2025
730e839
docs: document automated generation of copilot-instructions.md by inc…
michaelmkraus Jun 18, 2025
c528673
docs: adapt jsdoc for button and its models
michaelmkraus Jun 23, 2025
6133886
chore: add plugin to merge typedoc files
michaelmkraus Jun 23, 2025
c11b057
feat: append component doc to existing instructions instead of overwr…
michaelmkraus Jun 24, 2025
f2ad116
chore: add typedoc for doc generation
michaelmkraus Jun 25, 2025
793a26f
chore: remove comment
michaelmkraus Jun 25, 2025
1efbd0e
feat: merge component documentations into [MyComponent].md files and …
michaelmkraus Jun 26, 2025
1bc0087
feat: restructure script and add comments
michaelmkraus Jun 26, 2025
a88ae59
chore: delete existing md files within button docs folder
michaelmkraus Jun 30, 2025
e3d2125
feat: add script to generate framework-specific code snippets
michaelmkraus Jun 30, 2025
63d7dbd
feat: use mitosis plugin instead of script to generate examples
michaelmkraus Jul 1, 2025
fcea6f6
feat: append example snippets for react, angular and vue to [componen…
michaelmkraus Jul 3, 2025
12367ed
feat: introduce sassdoc to generate md documentation for SCSS and int…
michaelmkraus Jul 4, 2025
2c4f59b
feat: add script to extract sassdoc and save in md
michaelmkraus Jul 10, 2025
1ccc328
chore: move scripts to documentation subfolder
michaelmkraus Jul 14, 2025
14b7a17
chore: add readme describing how to generate copilot-instructions.md
michaelmkraus Jul 15, 2025
25c54e7
chore: adapt readme describing how to generate copilot-instructions.md
michaelmkraus Jul 15, 2025
8d1be02
feat: fix typos in readme
michaelmkraus Jul 16, 2025
cd80ca1
chore: adapt skript calls and readme
michaelmkraus Jul 16, 2025
e08e252
chore: moved script calls to scripts/package.json and adapt README
michaelmkraus Jul 16, 2025
ce1769d
chore: moved typedoc.json to scripts folder
michaelmkraus Jul 16, 2025
c83d172
feat: add sassdoc comments to variables for drawer
michaelmkraus Jul 17, 2025
7444bb4
docs: add examples for SassDoc and JSDoc
michaelmkraus Jul 17, 2025
c0095d9
feat: only handle defined components and skip others
michaelmkraus Jul 17, 2025
65e099a
docs: added open points to readme
michaelmkraus Jul 17, 2025
5f254da
feat: also copy all component-md files to docs/copilot folder
michaelmkraus Jul 18, 2025
b4902f4
chore: add new cli tool to copy docs to project
nmerget Jul 22, 2025
c3a9402
Merge remote-tracking branch 'origin/main' into docs-copilot-document…
nmerget Jul 22, 2025
ef9f32b
fix: issues with bad docs folder
nmerget Jul 22, 2025
ea4977c
fix: linting issue
nmerget Jul 22, 2025
9d3670a
fix: issues with extract-css-vars.ts
nmerget Jul 22, 2025
9ff0ceb
chore: update button.docs.lite.tsx
nmerget Jul 24, 2025
ac63cfd
Merge remote-tracking branch 'origin/main' into docs-copilot-document…
nmerget Jul 24, 2025
50e172a
feat: improve copilot
nmerget Jul 24, 2025
c2f622b
fix: issues with agent directories
nmerget Jul 24, 2025
5d6e5d9
chore: add remaining component examples
nmerget Jul 24, 2025
49d6300
Merge branch 'main' into docs-copilot-documentation
nmerget Jul 24, 2025
f88c409
chore: add agent-cli to build outputs
nmerget Jul 25, 2025
c692649
Merge remote-tracking branch 'origin/docs-copilot-documentation' into…
nmerget Jul 25, 2025
66b0168
chore: add agent-cli to build outputs
nmerget Jul 25, 2025
6170dde
fix: issue with agent-cli bin
nmerget Jul 25, 2025
e7bf98b
chore: improve some ai related stuff
nmerget Jul 25, 2025
7cebac1
Merge branch 'main' into docs-copilot-documentation
mfranzke Jul 25, 2025
79e02c1
Update README.md
mfranzke Jul 30, 2025
9344550
Update packages/foundations/agent/_instructions.md
nmerget Jul 30, 2025
f58c777
Update packages/foundations/agent/_instructions.md
nmerget Jul 30, 2025
fcd1ba8
Update scripts/documentation/merge-component-docs.ts
nmerget Jul 30, 2025
ae8c6a4
Update packages/foundations/agent/_instructions.md
nmerget Jul 30, 2025
cb4f476
Update packages/agent-cli/package.json
nmerget Jul 30, 2025
c206bd5
Update packages/agent-cli/package.json
nmerget Jul 30, 2025
952dba8
Update packages/agent-cli/README.md
mfranzke Jul 30, 2025
9ba3aa7
Merge branch 'main' into docs-copilot-documentation
mfranzke Jul 30, 2025
1616965
refactor: regenerated package lock file
mfranzke Jul 30, 2025
b0bc425
docs: copilot documentation documentation (#4651)
mfranzke Jul 30, 2025
6025a84
docs: provide further information
mfranzke Jul 31, 2025
262ae9f
docs: added sample prompt
mfranzke Jul 31, 2025
7aee163
Merge branch 'main' into docs-copilot-documentation
mfranzke Jul 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .config/.jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"**/.next/**",
"**/.nuxt/**",
"**/.output/**",
"**/agent/**",
"**/.vscode/**",
"**/*-example/index.html",
"**/*-showcase/index.html",
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/01-build-outputs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ jobs:
name: db-ux-stylelint-build
path: packages/stylelint/build

- name: ⏬ Download agent-cli build
uses: actions/download-artifact@v4
with:
name: db-ux-agent-cli-build
path: packages/agent-cli/build

- name: ⏬ Download output
uses: actions/download-artifact@v4
with:
Expand All @@ -51,7 +57,9 @@ jobs:
install-command: npm i

- name: 🔨 Build outputs
run: npm run build-outputs
run: |
npm run generate:agent
npm run build-outputs

- name: ⏫ Upload outputs
uses: actions/upload-artifact@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/01-build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ jobs:
name: db-ux-stylelint-build
path: packages/stylelint/build

- name: ⏫ Upload agent-cli build
uses: actions/upload-artifact@v4
with:
name: db-ux-agent-cli-build
path: packages/agent-cli/build

- name: 💀 Killing me softly
uses: ./.github/actions/cancel-workflow
if: failure()
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
node_modules
!packages/agent-cli/test/**/node_modules
npm-debug.log
.history
.idea
Expand Down Expand Up @@ -66,3 +67,6 @@ showcases/patternhub/public/iframe-resizer/*
/scripts/public/
/scripts/gh-pages.tar.gz
!/scripts/tests/fixtures/out
/output/**/docs/
/output/**/agent/
/packages/agent-cli/test/.github/copilot-instructions.md
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build-outputs/**
build-showcases/**
showcases/**/public/**
CODE-OF-CONDUCT.md
**/agent/**
77 changes: 77 additions & 0 deletions docs/adr/adr-05-copilot-developer-doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# ADR 2025-06-10: Documentation strategy for GitHub Copilot and developer docs

## Context

We need a consistent, maintainable documentation approach that serves both developers and AI-assisted coding
tools (GitHub Copilot) without duplicating effort. The documentation must cover component usage, variants, props,
examples, and allow Copilot to answer questions like "What variants does the Button support?" without manually
opening multiple files.

Key requirements:

- Single source of truth for component documentation.
- Automatic inclusion of context in Copilot Chat for both IDEs, VS Code and IntelliJ.
- Developer-friendly Markdown for manual reading and static site generation.
- Compatibility with LLM context conventions (llms.txt) and Copilot Custom Instructions (copilot-instructions.md).

## Decision

1. Documentation Format & Location

- Use Markdown files per component, stored in packages/components/docs/ or packages/components/src/components/docs/.
- Central table of contents in docs/llms.txt listing all component docs with relative paths.

2. Copilot Custom Instructions

- Place copilot-instructions.md in the project root (under .github/) to provide global guidance.
- Instruct Copilot Chat to load this file automatically; it will include links to llms.txt and recommended file paths.

3. Automatic Context Loading

- In VS Code and IntelliJ, Copilot Chat will automatically read .github/copilot-instructions.md on new chats.
- To surface specific details, embed documentation (e.g., Button.md) directly in copilot-instructions.md.

4. Interactive Context Attachment

- For deeper or ad-hoc queries, use the "Attach Context" feature in Copilot Chat to load component Markdown files during the session.

5. Static Site & Developer Docs

- Integrate component docs via Astro as a package in the monorepo, referencing Markdown sources in packages/components/... .
- Render pages dynamically under /components/[slug] and /api/[slug] for manual browsing.

6. Automated Propagation of Copilot Instructions

We add a `postinstall` hook to our component package that:

- copies or appends the package-specific file `.github/copilot-instructions.md` to the target project,
- uses unique markers to automatically replace outdated blocks during future installations,
- handles missing or already existing files as well as idempotent updates cleanly, ensuring that every installation immediately provides the latest Copilot context for our package.

7. Automate generation and propagation of Copilot instructions on package build.

- Define `generate:copilot-instructions` in `package.json` and hook into `prepare`.
- Only include `*.md` files whose filename matches the parent directory converted to PascalCase (e.g. `custom-select` → `CustomSelect.md`), ensuring no unrelated MDs are merged.

## Alternatives Considered

- Rely solely on Code Search: Let Copilot use workspace search to locate docs dynamically. Rejected due to inconsistency and limited to agent mode.
- TypeDoc-only approach: Generate API docs from TypeScript. Provides type detail but lacks usage narratives and cross-framework examples.
- Mitosis Metadata Model: Embed JSON metadata via useMetadata and generate docs. Promising, but requires custom plugins and not widely adopted yet.

## Consequences

- Pros:

- Clear separation: manual design guidance (Markdown) vs. AI context (Instructions + llms.txt snippets).
- Maintains single source (docs in packages/components/docs).
- Enables Copilot to provide accurate, component-specific suggestions without manual file opening.
- Developer site generation remains straightforward via Astro.
- Consumers always receive the latest Copilot context without manual steps.
- Guarantees that only the intended component documentation is merged into Copilot instructions.

- Cons:
- Requires maintaining excerpts in copilot-instructions.md when docs change.
- Copilot cannot truly auto-load all linked docs; manual attachment or excerpt embedding needed for deep context.
- Postinstall hooks may be disabled for security reasons, making it impossible to automate the copying of the copilot instructions.
- Relies on strict naming conventions; any divergence between folder and file names will cause a component’s docs to be skipped.
11 changes: 11 additions & 0 deletions output/angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ There are 3 ways to use Events in Angular:
></db-input>
```

## Documentation for AI Agents

We provide a documentation for every component in the DB UX Design System via `docs` folder.
To consume those documentation for AI Agents the best way is to copy the `docs` folder into your project.

We provide a CLI tool to do this automatically, which you can run with:

```shell
npx @db-ux/agent-cli
```

## Deutsche Bahn brand

As we'd like to perfectly support our users and customers on their digital journey, the usage of Deutsche Bahn brand and trademarks are bound of clear guidelines and restrictions even if being used with the code that we're providing with this product; Deutsche Bahn fully reserves all rights regarding the Deutsche Bahn brand, even though that we're providing the code of DB UX Design System products free to use and release it under the Apache 2.0 license.
Expand Down
Empty file added output/angular/agent/.gitkeep
Empty file.
6 changes: 6 additions & 0 deletions output/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
"main": "dist/fesm5.js",
"module": "dist/fesm5.js",
"types": "dist/core.d.ts",
"files": [
"dist/",
"agent"
],
"scripts": {
"build": "ng build",
"mv:agent": "cpr agent ../../build-outputs/angular/agent -o",
"ng": "ng",
"postbuild": "npm-run-all -p mv:*",
"start": "ng serve"
},
"devDependencies": {
Expand Down
11 changes: 11 additions & 0 deletions output/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ import { DBButton } from '@db-ux/react-core-components';
...
```

## Documentation for AI Agents

We provide a documentation for every component in the DB UX Design System via `docs` folder.
To consume those documentation for AI Agents the best way is to copy the `docs` folder into your project.

We provide a CLI tool to do this automatically, which you can run with:

```shell
npx @db-ux/agent-cli
```

## Deutsche Bahn brand

As we'd like to perfectly support our users and customers on their digital journey, the usage of Deutsche Bahn brand and trademarks are bound of clear guidelines and restrictions even if being used with the code that we're providing with this product; Deutsche Bahn fully reserves all rights regarding the Deutsche Bahn brand, even though that we're providing the code of DB UX Design System products free to use and release it under the Apache 2.0 license.
Expand Down
Empty file added output/react/agent/.gitkeep
Empty file.
4 changes: 3 additions & 1 deletion output/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/"
"dist/",
"agent"
],
"scripts": {
"build": "npm-run-all tsc",
"mv:dist": "cpr dist ../../build-outputs/react/dist --overwrite",
"mv:agent": "cpr agent ../../build-outputs/react/agent -o",
"mv:package.json": "cpr package.json ../../build-outputs/react/package.json --overwrite",
"mv:readme": "cpr README.md ../../build-outputs/react/README.md --overwrite",
"open:report": "npx playwright show-report",
Expand Down
10 changes: 10 additions & 0 deletions output/stencil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ If you don't have it already, add a VS Code settings folder and file at the root
}
```

## Documentation for AI Agents

We provide a documentation for every component in the DB UX Design System via `docs` folder.
To consume those documentation for AI Agents the best way is to copy the `docs` folder into your project.

We provide a CLI tool to do this automatically, which you can run with:

```shell
npx @db-ux/agent-cli
```

## Deutsche Bahn brand

Expand Down
Empty file added output/stencil/agent/.gitkeep
Empty file.
4 changes: 3 additions & 1 deletion output/stencil/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
}
},
"files": [
"dist/"
"dist/",
"agent"
],
"scripts": {
"build": "stencil build",
"build:cem": "cem analyze",
"mv:dist": "cpr dist ../../build-outputs/wc-core-components/dist -o",
"mv:agent": "cpr agent ../../build-outputs/wc-core-components/agent -o",
"mv:package.json": "cpr package.json ../../build-outputs/wc-core-components/package.json -o",
"mv:readme": "cpr README.md ../../build-outputs/wc-core-components/README.md -o",
"postbuild": "npm-run-all --parallel build:* --parallel mv:*",
Expand Down
8 changes: 4 additions & 4 deletions output/stencil/scripts/packageLinkPhase.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const resolveAllUnions = (resolvedData, resolvedProps, resolvedUnions) => {
};

const resolveManifestTypes = (resolvedUnions, manifestValues) =>
manifestValues.map((manifestValue) => {
manifestValues?.map((manifestValue) => {
if (!manifestValue.type) {
// those are methods
return manifestValue;
Expand Down Expand Up @@ -219,12 +219,12 @@ export const packageLinkPhase = (
resolveAllUnions(resolvedData, resolvedProps, resolvedUnions);

customElementsManifest.modules = customElementsManifest.modules
.filter(
?.filter(
// We just need the .tsx files for elements
(module) => module.path.endsWith('.tsx')
)
.map((module) => {
const declarations = module.declarations.map((declaration) => {
const declarations = module.declarations?.map((declaration) => {
const members = resolveManifestTypes(
resolvedUnions,
declaration.members
Expand All @@ -234,7 +234,7 @@ export const packageLinkPhase = (
declaration.attributes
);

const slots = declaration.slots.map((slot) => ({
const slots = declaration.slots?.map((slot) => ({
name: slot.name,
description:
resolvedUnions[
Expand Down
11 changes: 11 additions & 0 deletions output/vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ Both Inputs in this example do the same:
</template>
```

## Documentation for AI Agents

We provide a documentation for every component in the DB UX Design System via `docs` folder.
To consume those documentation for AI Agents the best way is to copy the `docs` folder into your project.

We provide a CLI tool to do this automatically, which you can run with:

```shell
npx @db-ux/agent-cli
```

## Deutsche Bahn brand

As we'd like to perfectly support our users and customers on their digital journey, the usage of Deutsche Bahn brand and trademarks are bound of clear guidelines and restrictions even if being used with the code that we're providing with this product; Deutsche Bahn fully reserves all rights regarding the Deutsche Bahn brand, even though that we're providing the code of DB UX Design System products free to use and release it under the Apache 2.0 license.
Expand Down
Empty file added output/vue/agent/.gitkeep
Empty file.
4 changes: 3 additions & 1 deletion output/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
}
},
"files": [
"dist/"
"dist/",
"agent"
],
"scripts": {
"build": "npm-run-all build:*",
"build:01_vite": "vite build",
"build:02_types": "vue-tsc --declaration --emitDeclarationOnly",
"mv:dist": "cpr dist ../../build-outputs/vue/dist --overwrite",
"mv:agent": "cpr agent ../../build-outputs/vue/agent -o",
"mv:package.json": "cpr package.json ../../build-outputs/vue/package.json --overwrite",
"mv:readme": "cpr README.md ../../build-outputs/vue/README.md --overwrite",
"postbuild": "npm-run-all --parallel mv:*",
Expand Down
Loading
Loading