实现一个新选项
为一个功能添加新选项是为 Remotion 做出贡献并启用更多使用场景的好方法。
🌐 Adding a new option to a feature is a great way to contribute to Remotion and enable more use cases.
指定选项的方法
🌐 Ways of specifying an option
有多种方法可以指定一个选项:
🌐 There are multiple ways to specify an option:
- 可以通过 Node.JS 调用的 API 可以直接接受一个参数。
- 可以在 Remotion Studio 的渲染对话框中添加影响渲染的选项。
- 如果该操作可以作为 CLI 命令使用,则该选项也应作为 CLI 标志添加。
- config 文件也可以用于指定多个选项。
:::注意 执行 CLI 命令时不应读取配置文件,否则其值应被忽略。:::
选项解析
🌐 Option Resolution
该选项应按以下顺序解决:
🌐 The option should be resolved in the following order:
直接传递给 Node.JS API通过 Remotion Studio 渲染界面指定
通过 配置文件指定
回退到默认值
命名
🌐 Naming
在 Node.JS 中,该选项应在 camelCase 中命名,而在 CLI 接受的选项中应在 hyphen-case 中命名。
🌐 The option should be named in camelCase for options in Node.JS and in hyphen-case for options accepted by the CLI.
接受数值的选项名称中应包含单位。例如使用 durationInFrames 而不是 duration,或使用 timeoutInMilliseconds 而不是 timeout。
🌐 Options accepting numerical values should include the unit in the name. For example durationInFrames instead of duration or timeoutInMilliseconds instead of timeout.
文档
🌐 Documentation
🌐 The option should be documented in the API reference and the CLI reference.
请注意该选项从哪个版本开始可用。
🌐 Note from which version the option is available.
测试对命令行接口的更改
🌐 Testing changes to the CLI
查看贡献文档中的 运行 CLI 部分。
🌐 Check out the Running the CLI section in the contributing docs.
另请参阅
🌐 See also