跳到主要内容

编写文档

本文档包含向 Ent 文档网站提交更改的指南。

Ent 文档网站由项目的主 GitHub 代码仓库 生成。

请遵循以下简短指南,为文档改进和新增内容贡献力量:

设置

1. 开启分支并本地克隆 主代码仓库

2. 文档网站使用 Docusaurus。你需要 安装 Node.js 来运行它。

3. 安装依赖:

cd doc/website && npm install

4. 开发模式运行网站:

cd doc/website && npm start

5. 浏览器打开 http://localhost:3000

一般准则

  • 文档文件位于 doc/md, 它们是 Markdown格式 的,并在顶部使用 "front-matter" 风格注释。 了解更多 关于 Docusaurus 文档格式。
  • Ent 使用 Golang 提交信息 格式来保持历史记录的清晰可读。 因此请使用如下形式的提交信息
doc/md: adding a guide on contribution of docs to ent

新增文件

1. 在 doc/md 目录新增一个 Markdown 文件,例如 doc/md/writing-docs.md

2. 文件应像如下一样格式化:

---
id: writing-docs
title: Writing Docs
---
...

文档的 id 应是唯一识别符,应与除 .md 后缀的文件的名称相同,title 是文档的标题,也会出现在页面本身和网站的导航元素。

3. 如果你想要文档出现在网站的侧边栏,id 添加到 website/sidebars.js ,例如:

{
type: 'category',
label: 'Misc',
items: [
'templates',
'graphql',
'sql-integration',
'testing',
'faq',
'generating-ent-schemas',
'feature-flags',
'translations',
'contributors',
+ 'writing-docs',
'slack'
],
collapsed: false,
},