Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: build and deploy PDF pages for translations #10846

Merged
merged 16 commits into from
Oct 13, 2023

Conversation

kbdharun
Copy link
Member

@kbdharun kbdharun commented Oct 4, 2023

Changes

Add support for PDFs in other languages

  • Add output flag to render.py, by default the filename without output flag is tldr-book.pdf (output flag allows specifying custom names, which I have used in CI).
  • Update pt serif font to Noto Sans (which has support for almost all typefaces and 800+ languages, and is compatible with our license).
  • Update CI to generate PDFs for individual translations (except a few languages, more information below).
  • Update the deploy script to publish the translation PDFs.
  • Update scripts/PDF README to document command changes.

Notes

I have tested all locales and verified rendering and edge cases.

The following locales ja, ko, zh, and zh_TW don't have a working render (even though the typeface is present in Noto) due to some issue in the weasyprint package. [Output of command:
missing_locales.txt for debugging]

Edit. Excluded some additional languages see #10846 (comment) for more information.

I have used the basic theme instead of the solarized-light (used on the English page) theme as it made reading certain typefaces easier.

Sample generated files in different themes

This was done during the PRs creation. Since then Tamil has been added to the exclusion list.

Tamil

tldr-pages-ta.pdf - Basic
tldr-pages-ta.pdf - Solarized light
tldr-pages-ta.pdf - Solarized dark

Related Issues

Closes #9432

@github-actions github-actions bot added documentation Issues/PRs modifying the documentation. tooling Helper tools, scripts and automated processes. labels Oct 4, 2023
@kbdharun kbdharun changed the title scripts: build and deploy PDF pages for all languages scripts: build and deploy PDF pages for translations Oct 4, 2023
@tldr-bot

This comment was marked as outdated.

@kbdharun kbdharun marked this pull request as draft October 5, 2023 14:23
Signed-off-by: K.B.Dharun Krishna <[email protected]>
@kbdharun
Copy link
Member Author

kbdharun commented Oct 5, 2023

Note: I am testing a wildcard method for CI. If you guys notice, some changes in CI it is for testing in a live environment. Once done I will rebase the changes.

Signed-off-by: K.B.Dharun Krishna <[email protected]>
Signed-off-by: K.B.Dharun Krishna <[email protected]>
@kbdharun
Copy link
Member Author

kbdharun commented Oct 5, 2023

Great, now the actions succeed and the files are uploaded (https://github.com/tldr-pages/tldr/actions/runs/6420703581). There seems to be a small issue where some files (bn, ml, ta, th) aren't rendered will trigger a rerun to debug it.

Artifact of the first run: pdf-artifacts.zip

Edit: the issue still seems to persist for the above 4 languages (the typefaces are indeed part of Noto Sans and while testing locale in a venv offline the files are rendered properly, they don't seem to render when built in the CI), will add these to the exclusion list too.

Edit 2. Done, cleaned up the additions that I used for testing in 0a73eb4 (It should be processed soon and will be reflected here). Now the PR should be good to go.

Artifact of the fixed run: pdf-artifacts (2).zip

Performance Impact on Workflow time

From testing, I can conclude that we might notice 3-5 minutes of added time to our existing PR runs since PDFs are built individually for language files.

@kbdharun kbdharun marked this pull request as ready for review October 5, 2023 15:39
@kbdharun kbdharun requested a review from MasterOdin October 5, 2023 15:41
@kbdharun kbdharun closed this Oct 5, 2023
@kbdharun kbdharun reopened this Oct 5, 2023
@kbdharun kbdharun mentioned this pull request Oct 6, 2023
5 tasks
@kbdharun kbdharun marked this pull request as draft October 6, 2023 05:21
@kbdharun
Copy link
Member Author

kbdharun commented Oct 6, 2023

Update: Migrated the building PDF part to a script that you can run inside the pdf directory. Started a test CI run, let's see how it goes.

Edit. It's done https://github.com/tldr-pages/tldr/actions/runs/6427813298?pr=10846 🎉 , I noticed I forgot to rename it to tldr-book in languages, will do it in the next commit.

Edit 2. Done, the artifact of the build can be found here.

Signed-off-by: K.B.Dharun Krishna <[email protected]>
@kbdharun kbdharun marked this pull request as ready for review October 6, 2023 05:33
Signed-off-by: K.B.Dharun Krishna <[email protected]>
@kbdharun kbdharun requested a review from MasterOdin October 6, 2023 12:59
Signed-off-by: K.B.Dharun Krishna <[email protected]>
@kbdharun kbdharun added the review needed Prioritized PRs marked for reviews from maintainers. label Oct 6, 2023
@kbdharun kbdharun requested a review from mfrw October 6, 2023 13:47
@kbdharun kbdharun merged commit a2ab577 into main Oct 13, 2023
@kbdharun kbdharun deleted the feat/scripts/translation-pdfs branch October 13, 2023 04:28
kbdharun added a commit that referenced this pull request Oct 13, 2023
kbdharun added a commit that referenced this pull request Oct 13, 2023
@kbdharun
Copy link
Member Author

kbdharun commented Oct 13, 2023

Merged the PR, there seems to be an issue with the deploy step.

+ rm -rf /home/runner/work/tldr/tldr/language_archives
+ cp -f /home/runner/work/tldr/tldr/index.json /home/runner/site/assets/
+ cp -f '/home/runner/work/tldr/tldr/scripts/pdf/tldr-book*.pdf' /home/runner/site/assets/
cp: cannot stat '/home/runner/work/tldr/tldr/scripts/pdf/tldr-book*.pdf': No such file or directory
Error: Process completed with exit code 1.

Reverted the change, will debug this later today.

@kbdharun kbdharun restored the feat/scripts/translation-pdfs branch October 13, 2023 06:54
@kbdharun kbdharun deleted the feat/scripts/translation-pdfs branch October 13, 2023 06:57
@kbdharun kbdharun restored the feat/scripts/translation-pdfs branch October 13, 2023 07:03
@kbdharun kbdharun deleted the feat/scripts/translation-pdfs branch October 13, 2023 07:06
@kbdharun kbdharun mentioned this pull request Oct 22, 2023
70 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues/PRs modifying the documentation. review needed Prioritized PRs marked for reviews from maintainers. tooling Helper tools, scripts and automated processes.
Projects
Development

Successfully merging this pull request may close these issues.

Proposal: Create seperate PDFs for translation pages
4 participants