write-component-docs
Skill255 starsChanged 43 days agoMITView on GitHub
Write bilingual (zh + en) documentation for any Vue component in the pixelium-design monorepo, following the project's VitePress doc template system. Use when asked to write or update docs for a component (e.g. "为 xxx 写文档", "write docs for xxx", "参照其他组件写文档"), or to add an example preview / API block / sidebar entry for a component.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- digital-go-jp/design-system-example-components-reacttheir own version, first seen Oct 9, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- digital-go-jp/design-system-example-components-react★ 685same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 4 are distinctive, and 15 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
15
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Read <component>/type.ts — the exported type names are what matter:
- Very specific: line 23
Read every prop/event/slot's JSDoc to write accurate descriptions.
- Very specific: line 24
Read <component>/index.vue to understand behavior and caveats (e.g.
- Very specific: line 25
Check sibling sub-components (e.g.
- Very specific: line 60
Place one preview after each usage section.
- Very specific: line 64
Add ## API (NOT wrapped in language blocks) then:
- Very specific: line 97
Every .md file in packages/document/slice/ is a reusable fragment (currently: percent, rest-attrs, emit-event, option, option-list, …
- Distinctive: line 117
EVERY type that shows up in the rendered tables must be presented in full on the same page - a name alone is not enough.
- Very specific: line 125
Use the canonical Chinese component name from share.ts additionMapZh (e.g.
- Distinctive: line 129
Use accurate component terminology for the concept (e.g.
- Very specific: line 130
When describing component-exposed methods/props in prose, simply say the component "暴露 X 方法 / exposes X methods" — do NOT mention ref (e.g.
- Very specific: line 134
Create one *.vue per usage section, referenced by <preview path="./xxx.vue"></preview>.
- Distinctive: line 140
Icons: import from the icon package, do NOT hand-write glyphs:
- Very specific: line 148
Fixed colors: use fixed hex colors, not CSS variables like var(--px-color-warning) (those don't exist).
- Very specific: line 152
When possible reuse sibling layouts — px-space wraps multiple items.
- Very specific: line 158
Add the component's kebab name to newItems to show the NEW!
- Very specific: line 159
Add <component>: '<中文名>' to additionMapZh (e.g.
- Very specific: line 166
Run npm run build inside packages/document/ (runs gen-doc.mts) to regenerate zh//en/ and confirm the md/API/slice blocks resolve without …
- Distinctive: line 167
If the user previously declined a build, don't rerun it — just report that the generated folders hold stale content until a build runs.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Write Pixelium Component Docs
This skill explains how to write documentation for any Vue component in the pixelium-design monorepo. It is distilled from the completed timeline doc work plus the patterns found across all existing component docs (button, tab, input, table, card, menu, dialog, drawer, etc.). Follow it to avoid the corrections the user repeatedly made during review.
1. System architecture (understand before editing)
- Component source:
packages/web-vue/lib/<component>/— each component folder hastype.ts(JSDoc-annotated prop/event/slot types),index.vue,index.less, andtest/. - Doc template source (EDIT THESE):
packages/document/template/—*.mdfiles plus example*.vuepreview files, grouped in category folders:common/,data-input/,data-display/,layout/,navigation/,feedback/,base/,config/,fabulous-idea/,guide/. - Reusable doc fragments:
packages/document/slice/— every.mdfile in this folder is a reusable fragment referenced by[[[slice ...]]]blocks (e.g.percent.md,rest-attrs.md,emit-event.md,option.md,date-format.md,value-with-device-width.md). - Generated output (DO NOT hand-edit):
packages/document/zh/andpackages/document/en/— regenerated by the build script. - Build script:
packages/document/script/gen-doc.mts; API resolver:packages/document/script/resolve-api.mts. - Sidebar: auto-generated at runtime by
packages/document/.vitepress/dfs-4-md.ts. To register a NEW! badge or Chinese/English nav titles, editpackages/document/.vitepress/share.ts. Do NOT hand-edit sidebar files.
2. Step 1 — Read the component source
- Read
<component>/type.ts— the exported type names are what matter:${CompName}Props,${CompName}Events,${CompName}Slotsare auto-grouped by the resolver into 属性/类型/可选/默认值/描述/版本, 事件/参数/描述/版本, and 插槽/参数/描述/版本 tables.- Read every prop/event/slot's JSDoc to write accurate descriptions.
- Read
<component>/index.vueto understand behavior and caveats (e.g. fortimeline, the last item renders no connector line — never demonstrateline-varianton the last item). - Check sibling sub-components (e.g.
timeline-item,tab-panel,collapse-item,grid-item) — each needs its own[[[api <name> ...]]]block. - Determine the category folder by comparing with existing components (button→
common, tab→navigation, timeline→data-display, input→data-input, dialog→feedback, ...). - Confirm the registered component names from the lib entry (
px-kebab-case in templates, e.g.px-timeline,px-timeline-item; PascalCaseTimelinein prose).
3. Step 2 — Write the .md file
Create packages/document/template/<category>/<component>.md.
Language blocks
Wrap every prose section in language blocks:
[[[zh
## 标题
中文说明
]]]
[[[en
## English Heading
English explanation
]]]The doc starts with an H1 in each language block (# Timeline), then a one-line description.
Preview blocks
<preview path="./xxx.vue"></preview>Place one preview after each usage section. The referenced .vue file lives in the same template folder.
API blocks
Add ## API (NOT wrapped in language blocks) then:
## API
[[[api zh
propName: Description.
events.eventName: Description.
slots.slotName: Description.
exposeName.method: Description.]]]
[[[api en
propName: Description.
events.eventName: Description.
slots.slotName: Description.
exposeName.method: Description.]]][[[api <lang>]]with no component name resolves from the file basename (kebab-case) to../web-vue/lib/<basename>/type.ts.[[[api <sub-component> <lang>]](e.g.[[[api timeline-item zh]]) resolves../web-vue/lib/timeline-item/type.ts. The sub-component name is kebab-case.- Description keys (how the resolver matches them to table rows):
- Props: the plain prop name (
direction), or optionallyCompName.prop. Unmatched props render with an empty description cell. - Events:
events.<event>(e.g.events.update:modelValue). - Slots:
slots.<slot>(e.g.slots.default,slots.icon). - Expose methods: plain key like
inputExpose.focus(noevents./slots.prefix).
- Props: the plain prop name (
- List events/slots on their own lines; blank lines inside a block are fine (they're skipped).
- The build merges these descriptions with the JSDoc types/defaults from
type.tsinto the final tables. You do NOT write types/defaults yourself.
Slice blocks
[[[slice <name>]]]Every .md file in packages/document/slice/ is a reusable fragment (currently: percent, rest-attrs, emit-event, option, option-list, group-option, date-format, quick-access-option, value-with-device-width). The script reads ./slice/<name>.md. Prefer these over rewriting common explanations; if a shared concept is missing, add a new .md file there instead of inlining it.
Prose rules (user-mandated)
- Describe the COMPONENT only. Do NOT describe the examples themselves - no commentary about the sample data or how a demo is built (e.g. "the files below carry an
urlonly, without afile"). The code panel already shows it, and it does not change how the component is used. - Example
.vuefiles carry no explanatory text either: no hint / caption / status paragraphs, and no scoped styles that exist only to style them. The prose block above the<preview>is the place for explanation.
API description rules (user-mandated)
- Descriptions describe ONLY the meaning of the property/event/slot — NO types, NO default values, NO code-related details.
- Refer to the component with its own PascalCase name (
Timeline,TimelineItem) when the word means the component — never lowercase, never the Chinese name — in BOTH zh and en blocks. - zh example:
direction: Timeline 的排列方向。 - en example:
direction: The arrangement direction of Timeline. - Slot wording example:
slots.icon: TimelineItem 节点处的图标。/slots.icon: The icon at the node of TimelineItem. - Optional parameters that change the scope of a call MUST be spelled out: when omitting a parameter makes the call act on every matching item (e.g.
submit(fileId?),retry(fileId?),abort(id?), and the same methods in thefile-listslot scope), the description must say so - e.g. "handling every pending file when none is given". The signature alone does not explain what the call acts on. - The same applies to optional parameters of events, props and slot scope methods.
Type definition rules (user-mandated)
- EVERY type that shows up in the rendered tables must be presented in full on the same page - a name alone is not enough.
- Shared types that already have a slice: include the slice (
[[[slice emit-event]]]forEmitEvent,[[[slice rest-attrs]]]forRestAttrs). When a shared type appears and no slice exists, add one underpackages/document/slice/. - Types owned by the component (e.g.
UploadData,UploadHeaders,UploadPatch,UploadCustomRequestOptions,CustomRequest,CustomDownload,CreateThumbnailUrl,FileInfo): add a### <TypeName>section holding atsblock copied verbatim from<component>/type.ts, ordered as the types are first referenced. - A type owned by ANOTHER component (e.g.
ButtonProps,ButtonEvents) is only referenced - its definition belongs to that component's page. - Inline function/object shapes that a table already spells out need no extra section.
Terminology rules (user-mandated)
- Use the canonical Chinese component name from
share.tsadditionMapZh(e.g. "时间线", NOT "时间轴"). Verify, don't assume. - In Chinese prose, refer to components by PascalCase component names (
Timeline,TimelineItem), not Chinese translations like 时间线/时间线项. - In English prose, also use PascalCase (
Timeline,TimelineItem) where the word refers to the component. - Prop names in prose: backticked camelCase (
theme,lineVariant,contentPlacement); in Vue templates use kebab-case (line-variant,content-placement,default-active). - Use accurate component terminology for the concept (e.g. "自定义节点" not "自定义圆点").
- When describing component-exposed methods/props in prose, simply say the component "暴露 X 方法 / exposes X methods" — do NOT mention
ref(e.g. do NOT write "通过 ref 暴露", "exposes ... via ref"). The docs describe the component's API, not how it is accessed in a template.
4. Step 3 — Write example preview .vue files
Create one *.vue per usage section, referenced by <preview path="./xxx.vue"></preview>.
Required conventions (each is a user-mandated fix)
- No Chinese in code — all strings, comments, and values in
.vuefiles must be English. - Use
px-prefix and kebab-case props in templates:<px-button>,<px-tab :default-active="'1'">,<px-timeline-item line-variant="dashed">. - Icons: import from the icon package, do NOT hand-write glyphs:
(See<script setup lang="ts"> import { IconHome, IconCog, IconEnvelope } from '@pixelium/web-vue/icon-hn/es' </script> <!-- <IconHome></IconHome> inside the relevant #icon slot -->tab-icon.vuefor the reference pattern.) - Fixed colors: use fixed hex colors, not CSS variables like
var(--px-color-warning)(those don't exist). Examples seen in the codebase:#409EFF,#FAE13C,#E956AE,#909399,#0960bd,#00b42a,#d97706,#ff7875,#86909c. - Vary
themeacross items when the component has athemeprop — don't leave everything default (primary,success,warning,info,danger,notice,sakura). - Visual-caveat props (like
line-varianton a last item that renders no line): never put them on the last item; demonstrate on a middle item followed by a solid one. - Make the section's feature obvious (e.g.
#iconslot shows<IconX>;#markslot shows styled content). - When possible reuse sibling layouts —
px-spacewraps multiple items; for grouped sections keep consistent visual density.
5. Step 4 — Register in share.ts
In packages/document/.vitepress/share.ts:
- Add the component's kebab name to
newItemsto show the NEW! badge (same format as existing entries, e.g.'timeline'). Every newly added component MUST be put in thenewItemslist — this is a required step, not optional. - Add
<component>: '<中文名>'toadditionMapZh(e.g.timeline: '时间线'). Add an English title toadditionMapEn/titleMapEnonly if the auto-derived title is wrong. ordercontrols the display order of top-level categories (folder names, e.g.common,data-input,data-display, ...) andguideOrdercontrols the order of the guide sub-pages — only touch them when adding a brand-new category/guide page. Adding a component does NOT require editing them: within a category, component pages are simply ordered by the filesystem listing (alphabetical).
The sidebar itself is auto-generated — do NOT hand-edit it.
6. Step 5 — Verify the build
- Run
npm run buildinsidepackages/document/(runsgen-doc.mts) to regeneratezh//en/and confirm the md/API/slice blocks resolve without errors. - If the user previously declined a build, don't rerun it — just report that the generated folders hold stale content until a build runs.
- Note: the full VitePress build may fail on a PRE-EXISTING unrelated dependency issue (
parsnip-kitmissingwaitexport). Don't chase it; it's not caused by doc edits.
7. Final self-check before presenting
- File is in the correct category folder under
template/. - Prose wrapped in
[[[zh ...]]]/[[[en ...]]];## APIis NOT wrapped. - Every component reference is PascalCase in BOTH zh and en prose and API descriptions.
- API descriptions contain no types/defaults/code.
- Prose describes the component only; no commentary about an example's own data or implementation, and no hint/caption text inside the example
.vuefiles. - All props/events/slots from
type.tshave matching descriptions; sub-components each have their own[[[api ...]]]block. - Shared concepts use
[[[slice ...]]]where applicable. - Every type name that appears in the tables is presented in full - a slice or a
### <TypeName>section with the verbatimtsdefinition; no bare type name is left undefined. - Optional parameters that change the scope of a call (e.g. "handling every pending file when none is given") are explained in the descriptions.
- Example .vue files: English only,
px-prefix, kebab-case props, Icon imports, fixed hex colors, varied themes, mark + footer present, no last-item line-variant. - share.ts updated (badge + zh title); canonical Chinese name used (e.g. 时间线).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

