Skip to content

Commit ec75f8f

Browse files
authored
Document translation workflow (#2579)
This documents the documentation workflow.
1 parent 3103eba commit ec75f8f

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

.github/workflows/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ set -Eeuo pipefail
99
#
1010
# The src/ and third_party/ directories are left in a dirty state so
1111
# you can run `mdbook test` and other commands afterwards.
12+
#
13+
# See also TRANSLATIONS.md.
1214

1315
book_lang=${1:?"Usage: $0 <book-lang> <dest-dir>"}
1416
dest_dir=${2:?"Usage: $0 <book-lang> <dest-dir>"}

.github/workflows/publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Publish
22

3+
# See also TRANSLATIONS.md.
4+
35
on:
46
push:
57
branches:

TRANSLATIONS.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,68 @@ the hard work, even if it is incomplete.
215215

216216
[CODEOWNERS]: https://github.com/google/comprehensive-rust/blob/main/.github/CODEOWNERS
217217

218+
## Publication Workflow
219+
220+
> This section is for the developers of Comprehensive Rust, but it might give
221+
> you valuable background information on how the translations are published.
222+
223+
When a change is made to the `main` branch, the [`publish.yml`] GitHub CI
224+
workflow starts.
225+
226+
The `publish` job in this workflow will:
227+
228+
- Install dependencies as described in [`CONTRIBUTING`](CONTRIBUTING.md).
229+
230+
- Build every translation of the course, including the original English, using
231+
[`build.sh`]. The English HTML ends up in `book/html/`, the HTML for the `xx`
232+
language ends up in `book/xx/html/`.
233+
234+
- Publish the entire `book/html/` directory to
235+
https://google.github.io/comprehensive-rust/.
236+
237+
[`build.sh`]: https://github.com/google/comprehensive-rust/blob/main/.github/workflows/build.sh
238+
239+
### `build.sh`
240+
241+
The `build.sh` script is used both when testing code from a PR (with
242+
[`build.yml`]) and when publishing the finished book (with [`publish.yml`]).
243+
244+
[`build.yml`]: https://github.com/google/comprehensive-rust/blob/main/.github/workflows/build.yml
245+
[`publish.yml`]: https://github.com/google/comprehensive-rust/blob/main/.github/workflows/publish.yml
246+
247+
The job of the script is to call `mdbook build`, but with a few extra steps:
248+
249+
- It will enable the PDF output using `mdbook-pandoc`. This is disabled by
250+
default to make it easier for people to run `mdbook build` without having to
251+
configure LaTeX.
252+
253+
#### Restoring Translations
254+
255+
When building a translation (languages other than English), `build.sh` will
256+
restore all Markdown files to how they looked at the time recorded in the
257+
POT-Creation-Date header.
258+
259+
This means that:
260+
261+
- A translation does not degrade when the English text is changed.
262+
- A translation will not received the latest fixes to the English text.
263+
264+
The script restores the Markdown with a simple
265+
266+
```sh
267+
$ git restore --source $LAST_COMMIT src/ third_party/
268+
```
269+
270+
command, where `$LAST_COMMIT` is the commit at the time of the POT-Creation-Date
271+
header.
272+
273+
A consequence of this is that we use the latest theme, CSS, JavaScript, etc for
274+
each translation.
275+
276+
After `build.sh` was run, the working copy is left in this dirty state. Beware
277+
of this if you want to build the English version next, as you will have to clean
278+
up manually.
279+
218280
## Status reports
219281

220282
Two translation status reports are automatically generated:

0 commit comments

Comments
 (0)