|
1 | 1 | # Dgraph Documentation |
2 | 2 |
|
3 | 3 | To read the official Dgraph documentation that is published from this repository, |
4 | | -please see https://dgraph.io/docs/. |
| 4 | +please see https://docs.dgraph.io/. |
5 | 5 |
|
| 6 | +## Technology Stack |
6 | 7 |
|
| 8 | +This documentation site is built with [Docusaurus](https://docusaurus.io/), a modern static website generator optimized for documentation. |
7 | 9 |
|
8 | | -## Contribution guidelines |
| 10 | +## Documentation Structure |
9 | 11 |
|
10 | | -As a contributor to Dgraph documentation, we ask that you do the following: |
11 | | -- **Label your PR for easy management**: Your PR title should be in the following format: **Topic (area): details**. The **topic** is either "Docs", "Nav" (aka, navigation), or "Chore" (for build fixes, cherry-picks, etc). The **area** is the feature (i.e. "GraphQL"), area of the docs (i.e., "Deployment"), or "Other" (for typo fixes and other bugfix PRs). So, example PR names include: |
12 | | - *Docs(GraphQL): Document the @deprecated annotation* or *Chore(Other): cherry-pick updates from main to release/v20.11* |
13 | | -- **Develop in the `main` branch first**: Make any changes applicable to the current (recently-released) version of Dgraph in the `main` branch first, and then cherry-pick those changes to the correct release branch (for example, `release/v20.11`). |
14 | | - |
15 | | - **Exception**: Changes that *only* apply to older Dgraph versions (for example `release/v20.07`), can occur directly in a release branch, but will not be cherry-picked forward. |
16 | | -- **Note planned cherry-pick(s) in your PR description**: If you are creating a PR in `main` and you know it needs to be cherry-picked to a release branch, please mention that in your PR description (for example: "cherry-pick to v20.07"). Cherry-pick PRs should reference the original PR. |
17 | | - |
18 | | -- **Link to discuss.dgraph.io posts when applicable**: If your PR is based on discussions on Discuss, feel free to include a link to the relevant discussion in your PR description. |
19 | | - |
20 | | -- **Technical writing style**: As much as possible, please follow technical writing style conventions (More on this below). |
21 | | - |
22 | | -- **(Dgraph core team only)**: Include the ID of any issues/tickets related to your PR in the description (i.e., "Fixes DGRAPH-12345" or "Per DGRAPH-54321"). |
23 | | - |
24 | | -### Technical writing style |
| 12 | +The documentation is organized into four main sections, each managed by its own Docusaurus content plugin: |
25 | 13 |
|
26 | | -Dgraph Labs uses a style guide for our documentation so that we can make it as easy to understand as possible. The [Dgraph Style Guide](https://discuss.dgraph.io/t/dgraph-developer-documentation-style-guide/10955) is a concise style reference for our documentation, but it isn't comprehensive. For anything not found in our style guide, use Google's [Developer Docs Style Guide](https://developers.google.com/style/highlights). |
| 14 | +1. **Docs** (`/`) - Core Dgraph database documentation including DQL, administration, installation, and design concepts |
| 15 | +2. **GraphQL** (`/graphql`) - GraphQL API documentation, schema, queries, mutations, and custom resolvers |
| 16 | +3. **Ratel UI** (`/ratel`) - Documentation for the Ratel web-based UI tool |
| 17 | +4. **Tutorials** (`/learn`) - Step-by-step tutorials and learning paths for different user types |
27 | 18 |
|
28 | | -#### Style tips for machine-translatable docs! |
| 19 | +Each section has its own sidebar navigation configured in: |
| 20 | +- `sidebars.ts` - Docs sidebar |
| 21 | +- `sidebars-graphql.ts` - GraphQL sidebar |
| 22 | +- `sidebars-ratel.ts` - Ratel sidebar |
| 23 | +- `sidebars-learn.ts` - Tutorials sidebar |
29 | 24 |
|
30 | | -Making our documentation easy to understand includes optimizing it for client-side machine translation into other languages. To help with this, please see the following technical writing style tips: |
31 | | -- Generally, use the second person ("you") rather than the third-person ("the developer") when addressing the reader. |
32 | | -- Always use the third person when describing Dgraph database or features (avoid "this lets us" in favor of "this lets Dgraph"). |
33 | | -- Write in present-tense, active voice when you can. |
34 | | -- Prefer simple sentences to complex and complex-compound sentences. |
| 25 | +## Running Locally |
35 | 26 |
|
36 | | -**Note:** Please don't let these style conventions stop you from creating a PR to share your contribution to Dgraph Docs! PR reviewers can help with style guide issues. |
| 27 | +### Prerequisites |
37 | 28 |
|
38 | | -### references ### |
| 29 | +- [Node.js](https://nodejs.org/) version 20.0 or higher |
| 30 | +- npm or yarn package manager |
39 | 31 |
|
40 | | -Use hugo shortcode for relref. |
| 32 | +### Setup and Run |
41 | 33 |
|
42 | | -Example, to reference a term, use a relref to the glossary : |
43 | | -``` |
44 | | -> [entity]({{< relref "dgraph-glossary.md#entity" >}}) |
45 | | -``` |
| 34 | +1. Navigate to the Docusaurus directory: |
| 35 | + ```bash |
| 36 | + cd docusaurus-docs |
| 37 | + ``` |
46 | 38 |
|
47 | | -### Staging doc updates locally |
| 39 | +2. Install dependencies: |
| 40 | + ```bash |
| 41 | + npm install |
| 42 | + ``` |
48 | 43 |
|
49 | | -We use [Hugo](https://gohugo.io/) for our documentation. You can use Hugo to locally stage doc updates before or after creating a PR. |
| 44 | +3. Start the development server: |
| 45 | + ```bash |
| 46 | + npm start |
| 47 | + ``` |
50 | 48 |
|
51 | | -1. Download and install hugo version v0.91 from [here](https://github.com/gohugoio/hugo/releases/tag/v0.91.0). |
| 49 | +4. Open [http://localhost:3000](http://localhost:3000) in your browser. |
52 | 50 |
|
53 | | -On mac you may have to remove the quarantine attribute to be able to execute hugo |
54 | | -''' |
55 | | -sudo xattr -d com.apple.quarantine path/to/hugo |
56 | | -''' |
| 51 | +The site will automatically reload when you make changes to the documentation files. |
57 | 52 |
|
58 | | -2. Run `./scripts/local.sh` and visit [http://localhost:1313](http://localhost:1313) to see the documentation site running on your local machine. |
| 53 | +### Build for Production |
59 | 54 |
|
60 | | -(Optional) To run queries _within_ the documentation using a different Dgraph instance, set the `DGRAPH_ENDPOINT` environment variable before starting the local web server: |
| 55 | +To build a production-ready static site: |
61 | 56 |
|
62 | 57 | ```bash |
63 | | -DGRAPH_ENDPOINT="http://localhost:8080/query?latency=true" ./scripts/local.sh |
| 58 | +npm run build |
64 | 59 | ``` |
65 | 60 |
|
66 | | -Now you can make changes to the docs and see them being updated instantly, thanks to Hugo. |
| 61 | +The built site will be in the `build/` directory. You can serve it locally with: |
67 | 62 |
|
68 | | -**Note**: While running locally, the version selector does not work because you need to build the documentation and serve it behind a reverse proxy to have multiple versions. Also, formatting of lists is less fussy when running locally; so please precede lists with a blank line in your PR. |
| 63 | +```bash |
| 64 | +npm run serve |
| 65 | +``` |
69 | 66 |
|
70 | | -### Testing for broken links |
| 67 | +## Versioning |
71 | 68 |
|
72 | | -We use [htmltest](https://github.com/wjdp/htmltest) to check for broken links in the generated documentation. To test for broken links after building the site: |
| 69 | +Docusaurus supports documentation versioning. Versioned documentation is stored in: |
| 70 | +- `docs_versioned_docs/` - Versioned docs content |
| 71 | +- `docs_versioned_sidebars/` - Versioned sidebar configurations |
| 72 | +- `docs_versions.json` - Version metadata |
73 | 73 |
|
74 | | -1. Build the Hugo site: |
75 | | - ```bash |
76 | | - hugo --destination=public --baseURL=http://example.com |
77 | | - ``` |
| 74 | +The version dropdown in the navbar automatically detects which documentation section you're viewing and shows the appropriate versions. Currently, versioning is configured for the main `docs` section. |
78 | 75 |
|
79 | | -2. Run htmltest: |
80 | | - ```bash |
81 | | - htmltest |
82 | | - ``` |
| 76 | +To create a new version: |
| 77 | +1. Use the Docusaurus CLI: `npm run docusaurus docs:version <version>` |
| 78 | +2. This creates a new version snapshot of the current docs |
83 | 79 |
|
84 | | - Or combine both steps: |
85 | | - ```bash |
86 | | - hugo --destination=public --baseURL=http://example.com && htmltest 2>&1 |
87 | | - ``` |
| 80 | +## Deployment |
88 | 81 |
|
89 | | -The htmltest configuration is in `.htmltest.yml` at the root of the repository. It automatically ignores development-only files like `livereload.js` and empty hash links used for JavaScript interactions. |
| 82 | +The documentation site is automatically deployed to CloudFlare: |
90 | 83 |
|
91 | | -### Running docs locally with Docker |
| 84 | +- **Main branch** (`main`) → Deployed to production at `https://docs.dgraph.io` |
| 85 | +- **Preview branches** (`preview/*`) → Deployed as preview deployments for review |
92 | 86 |
|
93 | | -Make sure you have docker-compose installed. |
| 87 | +The deployment process is handled automatically via CloudFlare Pages integration with GitHub. |
94 | 88 |
|
95 | | -Run: |
| 89 | +## Contribution Guidelines |
96 | 90 |
|
97 | | -```sh |
98 | | -sh scripts/docker.sh |
99 | | -``` |
100 | | - |
101 | | -### Branch |
102 | | - |
103 | | -Depending on what branch you are on, some code examples will dynamically change. |
104 | | -For example, `go-grpc` code examples will have different import path depending |
105 | | -on the branch name. |
| 91 | +As a contributor to Dgraph documentation, we ask that you do the following: |
| 92 | +- **Label your PR for easy management**: Your PR title should be in the following format: **Topic (area): details**. The **topic** is either "Docs", "Nav" (aka, navigation), or "Chore" (for build fixes, cherry-picks, etc). The **area** is the feature (i.e. "GraphQL"), area of the docs (i.e., "Deployment"), or "Other" (for typo fixes and other bugfix PRs). So, example PR names include: |
| 93 | + *Docs(GraphQL): Document the @deprecated annotation* or *Chore(Other): cherry-pick updates from main to release/v20.11* |
| 94 | +- **Develop in the `main` branch first**: Make any changes applicable to the current (recently-released) version of Dgraph in the `main` branch first, and then cherry-pick those changes to the correct release branch (for example, `release/v20.11`). |
106 | 95 |
|
107 | | -## Runnable code examples |
| 96 | + **Exception**: Changes that *only* apply to older Dgraph versions (for example `release/v20.07`), can occur directly in a release branch, but will not be cherry-picked forward. |
| 97 | +- **Note planned cherry-pick(s) in your PR description**: If you are creating a PR in `main` and you know it needs to be cherry-picked to a release branch, please mention that in your PR description (for example: "cherry-pick to v20.07"). Cherry-pick PRs should reference the original PR. |
108 | 98 |
|
109 | | -Some code examples are runnable, allowing for reader interaction with a data set. |
| 99 | +- **Link to discuss.dgraph.io posts when applicable**: If your PR is based on discussions on Discuss, feel free to include a link to the relevant discussion in your PR description. |
110 | 100 |
|
111 | | -### Custom example |
| 101 | +- **Technical writing style**: As much as possible, please follow technical writing style conventions (More on this below). |
112 | 102 |
|
113 | | -Pass custom Go-GRPC example to the runnable by passing a `customExampleGoGRPC` to the `runnable` shortcode. |
| 103 | +- **(Dgraph core team only)**: Include the ID of any issues/tickets related to your PR in the description (i.e., "Fixes DGRAPH-12345" or "Per DGRAPH-54321"). |
114 | 104 |
|
115 | | -``` |
116 | | -{{< runnable |
117 | | - customExampleGoGRPC="this\nis\nan example" |
118 | | ->}}{ |
119 | | - director(func:allofterms(name, "steven spielberg")) { |
120 | | - name@en |
121 | | - director.film (orderdesc: initial_release_date) { |
122 | | - name@en |
123 | | - initial_release_date |
124 | | - } |
125 | | - } |
126 | | -} |
127 | | -{{< /runnable >}} |
128 | | -``` |
| 105 | +### Technical Writing Style |
129 | 106 |
|
130 | | -**Note:** Runnable doesn't support passing a multiline string as an argument to a shortcode. Therefore, you have to create the whole custom example in a single line string by replacing newlines with `\n`. |
| 107 | +Please follow the [Dgraph Documentation Style Guide](documentation-style-guide.md) for writing conventions, formatting, and best practices. |
131 | 108 |
|
132 | | -## Hints |
133 | | -## Adding New Tabs and Sidebar Menus |
| 109 | +**Note:** Please don't let these style conventions stop you from creating a PR to share your contribution to Dgraph Docs! PR reviewers can help with style guide issues. |
134 | 110 |
|
135 | | -To add a new tab and configure its sidebar menu: |
| 111 | +### References |
136 | 112 |
|
137 | | -### 1. Add Tab to Navigation |
138 | | -Edit `themes/hugo-docs/layouts/partials/topbar.html` and add your tab to the `$tabs` slice: |
| 113 | +In Docusaurus, use standard Markdown links for internal references. For example, to reference a term in the glossary: |
139 | 114 |
|
140 | | -```go |
141 | | -{{ $tabs := slice |
142 | | - (dict "type" "docs" "url" "/dgraph-overview/" "label" "Docs") |
143 | | - (dict "type" "graphql" "url" "/graphql/" "label" "GraphQL") |
144 | | - (dict "type" "learn" "url" "/learn/" "label" "Tutorials") |
145 | | - (dict "type" "ratel" "url" "/ratel/overview/" "label" "Ratel UI") |
146 | | - (dict "type" "yourtype" "url" "/your-section/" "label" "Your Tab") |
147 | | -}} |
148 | | -``` |
149 | 115 |
|
150 | | -### 2. Set Page Type and Menu |
151 | | -For each page in your section, add to the frontmatter: |
152 | | - |
153 | | -```yaml |
154 | | -+++ |
155 | | -title = "Your Page Title" |
156 | | -type = "yourtype" # Must match the type in the tab definition |
157 | | -[menu.yourtype] # Must match the type |
158 | | - parent = "your-section" |
159 | | - weight = 1 |
160 | | -+++ |
| 116 | +```markdown |
| 117 | +[UID](/dgraph-glossary#uid) |
161 | 118 | ``` |
162 | 119 |
|
163 | | -### 3. Update Sidebar |
164 | | -Edit `themes/hugo-docs/layouts/partials/sidebar.html` and add: |
| 120 | +## File Structure |
165 | 121 |
|
166 | | -```go |
167 | | -{{ if eq $menuType "yourtype" }} |
168 | | - {{ $menu = .Site.Menus.yourtype }} |
169 | | -{{ end }} |
170 | 122 | ``` |
171 | | - |
172 | | -## Multi-Version Documentation |
173 | | - |
174 | | -This repository uses a build script to generate documentation for multiple versions from different Git branches. |
175 | | - |
176 | | - |
177 | | -```bash |
178 | | -./scripts/build.sh |
| 123 | +docusaurus-docs/ |
| 124 | +├── docs/ # Main documentation content |
| 125 | +├── docs-graphql/ # GraphQL documentation |
| 126 | +├── docs-ratel/ # Ratel UI documentation |
| 127 | +├── docs-learn/ # Tutorials and learning content |
| 128 | +├── docs_versioned_docs/ # Versioned documentation snapshots |
| 129 | +├── sidebars.ts # Main docs sidebar configuration |
| 130 | +├── sidebars-graphql.ts # GraphQL sidebar configuration |
| 131 | +├── sidebars-ratel.ts # Ratel sidebar configuration |
| 132 | +├── sidebars-learn.ts # Tutorials sidebar configuration |
| 133 | +├── docusaurus.config.ts # Main Docusaurus configuration |
| 134 | +└── src/ # Custom components and styles |
179 | 135 | ``` |
180 | 136 |
|
181 | | -This builds: |
182 | | -- **Latest docs** from `main` branch → `/` |
183 | | -- **Version docs** from release branches → `/v24.1/`, etc. |
184 | | - |
185 | | -## How It Works |
| 137 | +## Testing |
186 | 138 |
|
187 | | -1. **Build Script** (`build.sh`) uses Git worktrees to temporarily check out each release branch |
188 | | -2. **Hugo builds** each version into its own subdirectory with the appropriate base URL |
189 | | -3. **Version selector** loads available versions from `versions.json` and displays a dropdown |
| 139 | +### Type Checking |
190 | 140 |
|
191 | | -## Configuration |
| 141 | +Run TypeScript type checking: |
192 | 142 |
|
193 | | -Edit `build.sh` to add/remove versions: |
194 | 143 | ```bash |
195 | | -VERSION_BRANCHES=("main" "release/v24.1") |
| 144 | +npm run typecheck |
196 | 145 | ``` |
197 | 146 |
|
198 | | -```bash |
199 | | -VERSION_BRANCHES=("release/v25.0" "release/v24.1") |
200 | | -``` |
201 | | - |
202 | | -## File Structure |
203 | | - |
204 | | -``` |
205 | | -layouts/partials/ |
206 | | - └── version-selector.html # Dropdown component |
207 | | -scripts/ |
208 | | - └── build.sh # Build script |
209 | | -public/ # Generated output |
210 | | - ├── index.html # Latest docs (main) |
211 | | - ├── versions.json # Version metadata |
212 | | - ├── v24.1/ # Version 24.1 docs |
213 | | - └── v24.2/ # Version 24.2 docs |
214 | | -``` |
| 147 | +### Link Checking |
215 | 148 |
|
216 | | -### Version Selector |
| 149 | +After building the site, you can check for broken links using external tools or by manually testing the built site. |
217 | 150 |
|
218 | | -In layout |
| 151 | +## Runnable Code Examples |
219 | 152 |
|
220 | | -```html |
221 | | -{{ partial "version-selector.html" . }} |
222 | | -``` |
| 153 | +Some code examples in the documentation are interactive and runnable, allowing readers to execute queries directly in the browser. These are implemented using custom Docusaurus components. |
0 commit comments