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

feat/scripts: support generating PDFs for platforms #11195

Merged
merged 5 commits into from
Oct 23, 2023
Merged

Conversation

kbdharun
Copy link
Member

@kbdharun kbdharun commented Oct 23, 2023

Changes

As discussed in the chatroom, this PR adds a way to generate custom PDFs for specific platforms manually. Currently, we use python3 render.py <../../pages> to generate PDFs (tldr-book.pdf by default) and there is a -o or --output flag to give a custom name to the PDF.

This PR adds a new optional flag -p or --platform, allowing pages to be generated for the specified platform alone. For example, python3 render.py ../../pages -p android will generate a PDF file named tldr-book-android.pdf.

You can pass multiple platforms as arguments, for example, python3 render.py ../../pages -p android sunos will generate a PDF file named tldr-book-android+sunos.pdf.

In the case of custom file names, the platform name is just appended behind the filename, for example python3 render.py ../../pages -p android sunos -o tldr-book.pdf will generate a file named tldr-book-android+sunos.pdf.

Reference Outputs

(venv) kbdharun@homeserver:~/Downloads/tldr/scripts/pdf$ python3 render.py ../../pages -p android sunos
Rendered page 1 of the directory android
Rendered page 2 of the directory android
Rendered page 3 of the directory android
Rendered page 4 of the directory android
Rendered page 5 of the directory android
Rendered page 6 of the directory android
Rendered page 7 of the directory android
Rendered page 8 of the directory android
Rendered page 9 of the directory android
Rendered page 10 of the directory android
Rendered page 11 of the directory android
Rendered page 12 of the directory android
Rendered page 13 of the directory android
Rendered page 14 of the directory android
Rendered page 1 of the directory sunos
Rendered page 2 of the directory sunos
Rendered page 3 of the directory sunos
Rendered page 4 of the directory sunos
Rendered page 5 of the directory sunos
Rendered page 6 of the directory sunos
Rendered page 7 of the directory sunos
Rendered page 8 of the directory sunos
Rendered page 9 of the directory sunos

Converting all pages to PDF...

Created tldr-book-android+sunos.pdf in the current directory!
(venv) kbdharun@homeserver:~/Downloads/tldr/scripts/pdf$ python3 render.py ../../pages -p androi
No pages found for platform androi. Skipping.
(venv) kbdharun@homeserver:~/Downloads/tldr/scripts/pdf$ python3 render.py ../../pages -p android -o "tldr-books.pdf"
Rendered page 1 of the directory android
Rendered page 2 of the directory android
Rendered page 3 of the directory android
Rendered page 4 of the directory android
Rendered page 5 of the directory android
Rendered page 6 of the directory android
Rendered page 7 of the directory android
Rendered page 8 of the directory android
Rendered page 9 of the directory android
Rendered page 10 of the directory android
Rendered page 11 of the directory android
Rendered page 12 of the directory android
Rendered page 13 of the directory android
Rendered page 14 of the directory android

Converting all pages to PDF...

Created tldr-books-android.pdf in the current directory!

Reference assets

Assets generated in the above steps:

tldr-book-android+sunos.pdf
tldr-books-android.pdf

Checklist

  • All changes have been tested and verified
  • The code has been formatted in black
  • README has been updated

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
@kbdharun kbdharun changed the title feat/scripts: support generating PDFs for platform feat/scripts: support generating PDFs for platforms Oct 23, 2023
@github-actions github-actions bot added documentation Issues/PRs modifying the documentation. tooling Helper tools, scripts and automated processes. labels Oct 23, 2023
@kbdharun kbdharun mentioned this pull request Oct 23, 2023
70 tasks
Copy link
Member

@Magrid0 Magrid0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

scripts/pdf/render.py Outdated Show resolved Hide resolved
scripts/pdf/render.py Outdated Show resolved Hide resolved
Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
@kbdharun kbdharun merged commit 4e53530 into main Oct 23, 2023
8 checks passed
@kbdharun kbdharun deleted the feat/pdf4platforms branch October 23, 2023 19:29
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. tooling Helper tools, scripts and automated processes.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants