writing-docs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWriting Remotion Documentation
Remotion 文档编写指南
Documentation lives in as files.
packages/docs/docs.mdx文档以 文件形式存储在 目录下。
.mdxpackages/docs/docsAdding a new page
添加新页面
- Create a new file in
.mdxpackages/docs/docs - Add the document to
packages/docs/sidebars.ts - Write the content following guidelines below
- Run in
bun render-cards.tsto generate social preview cardspackages/docs
Breadcrumb (): If a documentation page belongs to a package, add to the frontmatter. This displays the package name as a breadcrumb above the title.
crumbcrumb: '@remotion/package-name'md
---
image: /generated/articles-docs-my-package-my-api.png
title: '<MyComponent>'
crumb: '@remotion/my-package'
---One API per page: Each function or API should have its own dedicated documentation page. Do not combine multiple APIs (e.g., and ) on a single page.
getEncodableVideoCodecs()getEncodableAudioCodecs()Public API only: Documentation is for public APIs only. Do not mention, reference, or compare against internal/private APIs or implementation details.
Use headings for all fields: When documenting API options or return values, each property should be its own heading. Use for top-level properties and for nested properties within an options object. Do not use bullet points for individual fields.
#######- 在 目录下创建新的
packages/docs/docs文件.mdx - 将文档添加到 中
packages/docs/sidebars.ts - 按照下方指南撰写内容
- 在 目录下运行
packages/docs生成社交预览卡片bun render-cards.ts
面包屑():如果文档页面属于某个包,请在前置元数据中添加 。这会在标题上方显示包名作为面包屑。
crumbcrumb: '@remotion/package-name'md
---
image: /generated/articles-docs-my-package-my-api.png
title: '<MyComponent>'
crumb: '@remotion/my-package'
---一个API对应一个页面:每个函数或API都应有独立的文档页面。不要将多个API(例如 和 )放在同一个页面中。
getEncodableVideoCodecs()getEncodableAudioCodecs()仅公开API:文档仅针对公开API。请勿提及、引用或对比内部/私有API或实现细节。
所有字段使用标题:在记录API选项或返回值时,每个属性都应作为独立标题。顶层属性使用 ,选项对象中的嵌套属性使用 。请勿对单个字段使用项目符号。
#######Language guidelines
语言规范
- Keep it brief: Developers don't like to read. Extra words cause information loss.
- Link to terminology: Use terminology page for Remotion-specific terms.
- Avoid emotions: Remove filler like "Great! Let's move on..." - it adds no information.
- Separate into paragraphs: Break up long sections.
- Address as "you": Not "we".
- Don't blame the user: Say "The input is invalid" not "You provided wrong input".
- Don't assume it's easy: Avoid "simply" and "just" - beginners may struggle.
- 保持简洁:开发者不喜欢冗长的内容。多余的文字会导致信息丢失。
- 术语链接:Remotion特定术语请链接到术语表页面。
- 避免情绪化表达:删除诸如“太棒了!让我们继续...”之类的填充内容——它们没有任何信息价值。
- 分段展示:拆分长段落。
- 以“你”称呼读者:不要用“我们”。
- 不要指责用户:要说“输入无效”而非“你提供了错误的输入”。
- 不要假设内容简单:避免使用“只需”“简单地”等词汇——初学者可能会觉得困难。
Code snippets
代码片段
Basic syntax highlighting:
md
```ts
const x = 1;
```基础语法高亮:
md
```ts
const x = 1;
```Type-safe snippets (preferred)
类型安全片段(推荐)
Use to check snippets against TypeScript:
twoslashmd
```ts twoslash
import {useCurrentFrame} from 'remotion';
const frame = useCurrentFrame();
```使用 检查片段是否符合TypeScript规范:
twoslashmd
```ts twoslash
import {useCurrentFrame} from 'remotion';
const frame = useCurrentFrame();
```Hiding imports
隐藏导入代码
Use to hide setup code - only content below is displayed:
// ---cut---md
```ts twoslash
import {useCurrentFrame} from 'remotion';
// ---cut---
const frame = useCurrentFrame();
```使用 隐藏设置代码——仅显示下方内容:
// ---cut---md
```ts twoslash
import {useCurrentFrame} from 'remotion';
// ---cut---
const frame = useCurrentFrame();
```Adding titles
添加标题
Always add a to code fences that show example usage:
titlemd
```ts twoslash title="MyComponent.tsx"
console.log('Hello');
```对于展示示例用法的代码块,务必添加 :
titlemd
```ts twoslash title="MyComponent.tsx"
console.log('Hello');
```Special components
特殊组件
Steps
步骤组件
md
- <Step>1</Step> First step
- <Step>2</Step> Second stepmd
- <Step>1</Step> 第一步
- <Step>2</Step> 第二步Experimental badge
实验特性徽章
md
<ExperimentalBadge>
<p>This feature is experimental.</p>
</ExperimentalBadge>md
<ExperimentalBadge>
<p>此特性为实验性。</p>
</ExperimentalBadge>Interactive demos
交互式演示
md
<Demo type="rect"/>Demos must be implemented in . See the skill for details on adding new demos.
packages/docs/components/demos/index.tsxdocs-demomd
<Demo type="rect"/>演示必须在 中实现。有关添加新演示的详情,请查看 技能文档。
packages/docs/components/demos/index.tsxdocs-demoAvailableFrom
AvailableFrom组件
Use to indicate when a feature or parameter was added. No import needed - it's globally available.
For page-level version indicators, use an heading with inline so it appears next to the title (not below it). Use and to escape angle brackets in component names:
# h1<AvailableFrom><>md
undefined用于标识特性或参数的添加版本。无需导入——它是全局可用的。
页面级版本标识:在 标题中内联使用 ,使其显示在标题旁(而非下方)。使用 和 转义组件名称中的尖括号:
# h1<AvailableFrom><>md
undefined<MyComponent><AvailableFrom v="4.0.123" />
<MyComponent><AvailableFrom v="4.0.123" />
```md
```md@remotion/my-package<AvailableFrom v="4.0.123" />
@remotion/my-package<AvailableFrom v="4.0.123" />
For section headings:
```md
对于章节标题:
```mdSaving to another cloud<AvailableFrom v="3.2.23" />
保存到其他云平台<AvailableFrom v="3.2.23" />
undefinedundefinedCompatibilityTable
CompatibilityTable组件
Use to indicate which runtimes and environments a component or API supports. No import needed. Place it in a section before .
## Compatibility## See alsoAvailable boolean props: , , , , , , . Set to (supported) or (not supported).
chromefirefoxsafariplayerstudioclientSideRenderingserverSideRenderingtrue{false}Set to empty string for not applicable if this is a frontend API: , , .
Use to hide the Node.js/Bun/serverless row if this is a frontend API.
""nodejs=""bun=""serverlessFunctions=""hideServersmd
undefined用于标识组件或API支持的运行时和环境。无需导入。请将其放在 章节中,位于 之前。
## 兼容性## 另请参阅可用布尔属性:、、、、、、。设置为 (支持)或 (不支持)。
chromefirefoxsafariplayerstudioclientSideRenderingserverSideRenderingtrue{false}如果是前端API,将不适用的属性设为空字符串 :、、。
如果是前端API,使用 隐藏Node.js/Bun/无服务器行。
""nodejs=""bun=""serverlessFunctions=""hideServersmd
undefinedCompatibility
兼容性
<CompatibilityTable chrome firefox safari nodejs="" bun="" serverlessFunctions="" clientSideRendering={false} serverSideRendering player studio hideServers />
```
<CompatibilityTable chrome firefox safari nodejs="" bun="" serverlessFunctions="" clientSideRendering={false} serverSideRendering player studio hideServers />
```
Optional parameters
可选参数
For optional parameters in API documentation:
- Add to the heading - this indicates the parameter is optional --> Don't do it if it is a CLI flag (beginning with
?) - CLI flags are always optional-- - Do NOT add text - the
_optional_suffix is sufficient? - Include default value in description - mention it naturally in the text
md
undefined对于API文档中的可选参数:
- 在标题中添加 ——这表示该参数是可选的 --> 如果是CLI标志(以
?开头)则无需添加——CLI标志始终是可选的-- - 不要添加 文本——
_optional_后缀已足够说明? - 在描述中包含默认值——在文本中自然提及
md
undefinedonError?
onError?
Called when an error occurs. Default: errors are thrown.
**Do NOT do this:**
```md发生错误时触发。默认值:抛出错误。
**请勿这样做:**
```mdonError?
onError?
optional
Called when an error occurs.
undefinedoptional
发生错误时触发。
undefinedCombining optional and AvailableFrom
结合可选参数与AvailableFrom
When a parameter is both optional and was added in a specific version:
md
undefined当参数既是可选的又是在特定版本中添加时:
md
undefinedonError?<AvailableFrom v="4.0.50" />
onError?<AvailableFrom v="4.0.50" />
Called when an error occurs.
undefined发生错误时触发。
undefined"Optional since" pattern
“自某版本起可选”模式
If a parameter became optional in a specific version (was previously required):
md
undefined如果参数在特定版本后变为可选(之前是必填的):
md
undefinedcodec?
codec?
Optional since <AvailableFrom v="5.0.0" inline />. Previously required.
undefined自 <AvailableFrom v="5.0.0" inline /> 起变为可选。此前为必填。
undefinedGenerating preview cards
生成预览卡片
After adding or editing a page, generate social media preview cards:
bash
cd packages/docs && bun render-cards.ts添加或编辑页面后,生成社交媒体预览卡片:
bash
cd packages/docs && bun render-cards.tsVerifying docs compile
验证文档编译
To check that documentation builds without errors:
bash
undefined要检查文档是否能无错误构建:
bash
undefinedfrom the monorepo root
从单仓库根目录执行
bun run build-docs
This validates MDX syntax, twoslash snippets, and broken links.bun run build-docs
这会验证MDX语法、twoslash片段和失效链接。