Getting Started
TOC
Creating a ProjectCLI ToolStart the Development ServerProduction BuildLocal PreviewUse Scaffold TemplatesTranslate DocumentationExport PDFDocumentation LintingCreating a Project
First, you can create a new directory with the following command:
Run npm init -y to initialize a project. You can use npm, yarn, or pnpm to install doom:
Then create the files with the following commands:
Add the following scripts to package.json:
Then initialize a configuration file doom.config.yml:
At the same time, create a new tsconfig.json with the following content:
Finally, create a global.d.ts file with the following content:
This way, you can use the global components provided by doom in .mdx files with type safety.
CLI Tool
For more configuration, see Configuration
Start the Development Server
Run yarn dev to start the development server, and the browser will automatically open the documentation home page
Production Build
Run yarn build to build the production code. After the build is complete, static files will be generated in the dist directory.
Local Preview
Run yarn serve to preview the built static files. Note that if you built with the -b, -p parameters, you also need to use the -b, -p parameters when previewing.
Use Scaffold Templates
Run yarn new to generate a project, module, or documentation using scaffold templates.
Translate Documentation
- The
-g, --globparameter is required. You can specify the file directories or paths to translate. It supportsglobsyntax. Note that the parameter value must be enclosed in quotes, otherwise it will be parsed by the command line and may cause unexpected behavior. Examples:yarn translate -g abc xyzwill translate all documentation under the<root>/<source>/abcand<root>/<source>/xyzdirectories to<root>/<target>/abcand<root>/<target>/xyzyarn translate -g '*'will translate all documentation files under<root>/<source>
- The
-C, --copyparameter is optional. It controls whether local asset files are copied to the target directory when the target file does not exist. The default isfalse, which means the reference path of the asset file is changed to point to the source path. Examples:- When this parameter is enabled:
- Translating
/<source>/abc.jpgwill copy<root>/public/<source>/abc.jpgto<root>/public/<target>/abc.jpg, and update the reference path in the document to/<target>/abc.jpg - Translating
./assets/xyz.jpgin<root>/<source>/abc.mdxwill copy<root>/<source>/assets/xyz.jpgto<root>/<target>/assets/xyz.jpg, and the image reference path remains unchanged - Translating
./assets/<source>/xyz.jpgin<root>/<source>/abc.mdxwill copy<root>/<source>/assets/<source>/xyz.jpgto<root>/<target>/assets/<target>/xyz.jpg, and update the reference path in the document to./assets/<target>/xyz.jpg
- Translating
- When this parameter is not enabled:
- When translating
/<source>/abc.jpg, if<root>/public/<target>/abc.jpgalready exists, the reference path in the document will be changed to/<target>/abc.jpg; otherwise, the image reference path remains unchanged - When translating
./assets/<source>/xyz.jpgin<root>/<source>/abc.mdx, if<root>/<target>/assets/<target>/xyz.jpgalready exists, the reference path in the document will be changed to./assets/<target>/xyz.jpg; otherwise, it will be changed to../<source>/assets/<target>/xyz.jpg
- When translating
- When this parameter is enabled:
In particular, if you use -g '*' for a full translation, the file lists in the source and target directories will be compared. Any mismatched target files except for internalRoutes will be deleted automatically.
The translation feature requires the ALAUDA_OPENAI_BASE_URL and ALAUDA_OPENAI_API_KEY environment variables to be configured locally. Please contact your team Leader to obtain them.
You can use metadata in the documentation to control translation behavior:
For more configuration, see Translation Configuration
Export PDF
Please run yarn build before performing the export operation.
Run yarn export to export the documentation as a PDF file. Note that if you built with the -b, -p parameters, you also need to use the -b, -p parameters when exporting.
The export feature depends on playwright. In pipelines, use build-harbor.alauda.cn/frontend/playwright-runner:doom as the base image for dependency installation and documentation builds. For local development, you can set the following environment variable to speed up downloads:
In addition to exporting a complete PDF document for the entire site, doom also supports exporting a single PDF file from a specified entry point. For more configuration, see Documentation Export Configuration
Documentation Linting
doom lint is based on ESLint and cspell. If you want a better experience in your editor, you can install the corresponding plugins ESLint / CSpell, and then create the corresponding configuration files:
-
eslint.config.mjs: -
cspell.config.mjs:
At the same time, we agree that the .cspell folder under the current working directory (CWD) is used to store CSpell dictionary files. For example, you can create .cspell/k8s.txt:
For more configuration, see Documentation Linting Configuration