| 1 | # Introduction |
| 2 | |
| 3 | This document outlines the procedures for writing, generating, and managing Groonga's documentation. |
| 4 | By following the steps below, you can contribute to enhancing and updating Groonga's documentation. |
| 5 | |
| 6 | ## How to fork and clone Groonga repository |
| 7 | |
| 8 | Contributing to Groonga's documentation begins with forking and cloning the Groonga repository. |
| 9 | These actions are essential first steps that enable personal modifications and experimentation in your personal repository. |
| 10 | And also, it enables you to submit them as your contributions to the Groonga repository. Follow these steps. |
| 11 | |
| 12 | 1. Go to https://github.com/groonga/groonga on GitHub |
| 13 | 2. Click the `Fork` button to create a copy of the repository |
| 14 | 3. Clone your Groonga repository with the following command |
| 15 | |
| 16 | ```console |
| 17 | % git clone --recursive [email protected]:${YOUR_GITHUB_ACCOUNT}/groonga.git |
| 18 | ``` |
| 19 | |
| 20 | ## Install dependent software |
| 21 | |
| 22 | Groonga uses [Sphinx](https://www.sphinx-doc.org/) as documentation tool. |
| 23 | |
| 24 | Here are command lines to install Sphinx. |
| 25 | |
| 26 | Debian GNU/Linux, Ubuntu: |
| 27 | |
| 28 | ```console |
| 29 | % ./setup.sh |
| 30 | % sudo pip install -r doc/requirements.txt |
| 31 | % (cd doc && bundle install) |
| 32 | ``` |
| 33 | |
| 34 | AlmaLinux, Fedora: |
| 35 | |
| 36 | ```console |
| 37 | % sudo dnf install -y python-pip gettext |
| 38 | % sudo pip install -r doc/requirements.txt |
| 39 | % (cd doc && bundle install) |
| 40 | ``` |
| 41 | |
| 42 | macOS: |
| 43 | |
| 44 | ```console |
| 45 | % brew bundle |
| 46 | % export PATH=$(brew --prefix gettext)/bin:$PATH |
| 47 | % pip install -r doc/requirements.txt |
| 48 | % (cd doc && bundle install) |
| 49 | ``` |
| 50 | |
| 51 | ## Run `cmake` with `--preset=doc` |
| 52 | |
| 53 | Groonga disables documentation generation by default. You need to |
| 54 | enable it explicitly by adding `--preset=doc` option to |
| 55 | `cmake`: |
| 56 | |
| 57 | ```console |
| 58 | % cmake -S . -B ../groonga.doc --preset=doc |
| 59 | ``` |
| 60 | |
| 61 | Now, your Groonga build is documentation ready. |
| 62 | |
| 63 | ## Generate HTML |
| 64 | |
| 65 | You can generate HTML by the following command: |
| 66 | |
| 67 | ```console |
| 68 | % cmake --build ../groonga.doc |
| 69 | ``` |
| 70 | |
| 71 | You can find generated HTML documentation at `../groonga.doc/doc/en/html/`. |
| 72 | |
| 73 | ## How to edit documentation |
| 74 | |
| 75 | The Groonga documentation is written in [reStructuredText (.rst)](https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html) or [Markdown (.md)](https://myst-parser.readthedocs.io/en/latest/) . These files are located in the `doc/source`. |
| 76 | Each page of the documentation corresponds to a `.rst` file or a `.md` file. By modifying the corresponding file, you can edit the target document. |
| 77 | For Example, if you want to edit this {doc}`introduction` page, you should edit the `doc/source/contribution/documentation/introduction.rst` file. |
| 78 | Please find the file you wish to edit and make your changes. |
| 79 | |
| 80 | (how-to-add-new-documentation)= |
| 81 | |
| 82 | ## How to add a new documentation |
| 83 | |
| 84 | If you want to add a new documentation, you need to add the new documentation into `doc/files.am` and `doc/files.cmake` by the following command lines. |
| 85 | |
| 86 | ```console |
| 87 | $ cmake -S . -B ../groonga.doc --preset=doc |
| 88 | $ cmake --build ../groonga.doc |
| 89 | $ ninja doc_update_files -C ../groonga.doc |
| 90 | ``` |
| 91 | |
| 92 | Note that you need to commit not only the new documentation but also `doc/files.am` and `doc/files.cmake` in this case. |
| 93 | |
| 94 | ## Preview changes on HTML files |
| 95 | |
| 96 | You can preview your documentation changes in your browser in HTML format. Follow these two steps. |
| 97 | |
| 98 | 1. Generate the HTML files with your changes |
| 99 | 2. Preview the generated HTML files in your Web browser |
| 100 | |
| 101 | ### Generate the HTML files with your changes |
| 102 | |
| 103 | Use the following command to generate HTML files that reflect your changes. The generated files will be located in `../groonga.doc/doc/en/html/`. Each file corresponds to a `.rst` or `.md` file: |
| 104 | |
| 105 | ```console |
| 106 | % cmake --build ../groonga.doc |
| 107 | ``` |
| 108 | |
| 109 | ### Preview the generated HTML files in your Web browser |
| 110 | |
| 111 | Open the generated file in your Web browser to preview your changes. |
| 112 | For example, if you have edited this {doc}`introduction` page, you can preview it by the following command: |
| 113 | |
| 114 | ```console |
| 115 | % open ../groonga.doc/doc/en/html/contribution/documentation/introduction.html |
| 116 | ``` |
| 117 | |
| 118 | ## Send patch |
| 119 | |
| 120 | You can submit your patch to the Groonga repository on GitHub via a pull request. |
| 121 | Feel free to send a pull request by following these steps. |
| 122 | |
| 123 | - Enable preview on your fork (optional) |
| 124 | - Prepare your pull request |
| 125 | - Submit your pull request |
| 126 | |
| 127 | ### Enable preview on your fork (optional) |
| 128 | |
| 129 | You can enable preview on your fork by following the steps below before pushing your commits: |
| 130 | |
| 131 | 1. Enable GitHub Pages on your fork: |
| 132 | - Open `https://github.com/${YOUR_GITHUB_ACCOUNT}/groonga/settings/pages` |
| 133 | - Select "GitHub Actions" as "Source" |
| 134 | 2. Accept publishing GitHub Pages from all branches on your fork: |
| 135 | - Open `https://github.com/${YOUR_GITHUB_ACCOUNT}/groonga/settings/environments` |
| 136 | - Select the "github-pages" environment |
| 137 | - Change the default "Deployment branches and tags" rule: |
| 138 | - Press the "Edit" button |
| 139 | - Change the "Name pattern" to `*` from `main` |
| 140 | |
| 141 | You can preview your changes at the following URLs after pushing your changes: |
| 142 | |
| 143 | - `https://${YOUR_GITHUB_ACCOUNT}.github.io/groonga/` |
| 144 | - `https://${YOUR_GITHUB_ACCOUNT}.github.io/groonga/ja/` |
| 145 | - `https://${YOUR_GITHUB_ACCOUNT}.github.io/groonga/reference/api/` |
| 146 | |
| 147 | ### Prepare your pull request |
| 148 | |
| 149 | Ensure your changes are committed and then push your changes to your fork repository on GitHub. |
| 150 | Follow these commands: |
| 151 | |
| 152 | ```console |
| 153 | % git switch -c your-working-branch |
| 154 | % git add doc |
| 155 | % git commit -m 'Describe your works here' |
| 156 | % git push origin your-working-branch |
| 157 | ``` |
| 158 | |
| 159 | ### Submit your pull request |
| 160 | |
| 161 | Now you're ready to submit a pull request to the upstream Groonga repository. |
| 162 | Follow these steps: |
| 163 | |
| 164 | 1. Go to your fork repository on GitHub |
| 165 | 2. Click the `Compare & pull request` button |
| 166 | 3. Make sure your changes are reflected |
| 167 | 4. Click the `Create Pull Request` button and send your pull request |
| 168 | |
| 169 | ## Optional: Translate documentation |
| 170 | |
| 171 | This is an optional step. |
| 172 | |
| 173 | After editing and previewing the Groonga documentation, the next step is to translate the documents to make them accessible to a wider range of Groonga community users. Translating into languages other than English ensures that non-English speakers can also understand the Groonga documentation. Follow these steps to translate Groonga documentation. |
| 174 | |
| 175 | 1. Translate the documentation in `.edit.po` files |
| 176 | 2. Reflect translations to `.po` files |
| 177 | 3. Preview translations on HTML files |
| 178 | |
| 179 | ### Translate the documentation in `.edit.po` files |
| 180 | |
| 181 | Use the following command to generate `.edit.po` files, which are translation files, corresponding to your changes. The generated files will be located in `../groonga.doc/doc/locale/${LANGUAGE}/LC_MESSAGES`. Each file corresponds to a `.rst` or `.md` file. Please add your translations to `.edit.po` files: |
| 182 | |
| 183 | ```console |
| 184 | % cmake --build ../groonga.doc |
| 185 | ``` |
| 186 | |
| 187 | For example, if you have edited the {doc}`introduction` page and want to add Japanese translations, update this `../groonga.doc/doc/ja/LC_MESSAGES/contribution/documentation/introduction.edit.po` file. |
| 188 | |
| 189 | ```{caution} |
| 190 | Please do not modify the `.rst` or `.md` files while adding translations to the `.edit.po` files. |
| 191 | Editing `.rst` or `.md` files without first reflecting the translations in `.po` files will result in the loss of those translations. |
| 192 | If you want to edit `.rst` or `.md` files, ensure you first reflect your translations in `.po` files. |
| 193 | The method to reflect translations will be introduced in the next step. |
| 194 | ``` |
| 195 | |
| 196 | ### Reflect translations to `.po` files |
| 197 | |
| 198 | After adding your translations to the `.edit.po` files, the next step is to reflect these translations to the `.po` files. `.po` files are the finalized translation files. These `.po` files are located in `doc/locale/${LANGUAGE}/LC_MESSAGES`. Each file corresponds to a `.rst` or `.md` file. If you want to edit your translations, edit the corresponding `.edit.po` file and then reflect your changes to the `.po` file. |
| 199 | |
| 200 | To reflect translations from the `.edit.po` files to the `.po` files, use the following command: |
| 201 | |
| 202 | ```console |
| 203 | % cmake --build ../groonga.doc |
| 204 | ``` |
| 205 | |
| 206 | For example, if you have added Japanese translations about the {doc}`introduction` page and then execute the command above, your translations will be reflected to `/doc/locale/ja/LC_MESSAGES/contribution/documentation/introduction.po` file. |
| 207 | |
| 208 | ```{note} |
| 209 | Actually, the command to generate translation `.edit.po` files is the same as the one used for reflecting translations. |
| 210 | Therefore, there's no need to memorize different commands for generating translation files and reflecting the translations. |
| 211 | ``` |
| 212 | |
| 213 | ### Preview translations on HTML files |
| 214 | |
| 215 | You can preview your translations in your Web browser in HTML format. The step for reflecting translations into `.po` files also generates the corresponding HTML files. These files are located in `../groonga.doc/doc/${LANGUAGE}/html/`. Each file corresponds to a `.rst` or `.md` file. Open the generated HTML file in your Web browser to review your translations. |
| 216 | |
| 217 | For example, to preview the Japanese translation of the {doc}`introduction` page, use the following command: |
| 218 | |
| 219 | ```console |
| 220 | % open ../groonga.doc/doc/ja/html/contribution/documentation/introduction.html |
| 221 | ``` |
| 222 | |
| 223 | If the translations seem correct after preview, please send a patch. For more information on this process, see the [Send patch](#send-patch) |