Skip to content

Commit 2e3b1ed

Browse files
authored
Merge pull request #334 from apiraino/add-pdf-skip-script-param
Add pdf skip script param
2 parents fd1a176 + 10c90ca commit 2e3b1ed

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

annual-survey.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,10 @@ $ source venv/bin/activate
5858
(venv) $ pip install -U pillow # this might be needed if the code fails
5959
```
6060

61-
#### PDF report
62-
To generate the report, copy the `main.py` file from the previous year, go through all questions and patch up the question IDs to match the contents of the actual survey (questions can move around, be added or removed, so it needs manual analysis). After the questions are patched, a PDF report will be generated by the Python file.
63-
64-
After the PDF report is prepared, send a PR to the [surveys](https://github.com/rust-lang/surveys) repository.
65-
6661
#### Blog post
67-
The same Python file is also used to render a blog post. The way it works is that we use a template Markdown file (e.g. `surveys/2023-annual-survey/report/2024-02-19-2023-Rust-Annual-Survey-2023-results.md`) with the contents of the blog post, which is rendered by the `main.py` script. The render process adds charts to the blog post and copies all the used image files and the final rendered Markdown file into a checkout of the [blog repository][blog repository], which you must have somewhere at your filesystem.
62+
To generate the blog post, copy the `main.py` file from the previous year, go through all questions and patch up the question IDs to match the contents of the actual survey (questions can move around, be added or removed, so it needs manual analysis). After the questions are patched, run the python script. Optionally with `--skip-pdf` to skip the PDF report generation.
63+
64+
The way it works is that we use a template Markdown file (e.g. `surveys/2023-annual-survey/report/2024-02-19-2023-Rust-Annual-Survey-2023-results.md`) with the contents of the blog post, which is rendered by the `main.py` script. The render process adds charts to the blog post and copies all the used image files and the final rendered Markdown file into a checkout of the [blog repository][blog repository], which you must have somewhere at your filesystem.
6865

6966
To test the contents of the rendered blog post, you have to run the `main.py` script, then run `cargo run` in the blog repository directory and open the built HTML file in your browser of choice. Note that for faster feedback, I would recommend commenting out the rendering of the PDF in `main.py` (which is relatively slow) when making frequent changes to the blog post template.
7067

@@ -75,3 +72,8 @@ After the blog post is prepared, send a PR to the [blog repository][blog reposit
7572
You will then also need to update the blog template in the `surveys` repo, but that can be done asynchronously.
7673

7774
[blog repository]: https://github.com/rust-lang/blog.rust-lang.org
75+
76+
#### PDF report
77+
To also generate the PDF report, run the python script without additional parameters.
78+
79+
After the PDF report is prepared, send a PR to the [surveys](https://github.com/rust-lang/surveys) repository.

surveys/2024-annual-survey/report/main.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -461,19 +461,24 @@ def annual_survey_2024_report() -> ChartReport:
461461

462462
report = annual_survey_2024_report()
463463

464-
render_report_to_pdf(
465-
report,
466-
Path(__file__).parent / "annual-survey-2024-report.pdf",
467-
"Rust Annual survey 2024 report",
468-
include_labels=False
469-
)
470-
471464
resource_dir = "2025-02-13-rust-survey-2024"
472465
# Fill path to blog root (i.e. a checkout of https://github.com/rust-lang/blog.rust-lang.org)
473466
blog_root = Path("/projects/personal/rust/blog.rust-lang.org")
467+
# relative path in this repository where the survey Markdown template is
468+
template_path = Path("surveys/2024-annual-survey/report/2025-02-13-2024-State-Of-Rust-Survey-results.md")
474469
render_blog_post(
475-
template=Path("2025-02-13-2024-State-Of-Rust-Survey-results.md"),
470+
template=template_path,
476471
blog_root=blog_root,
477472
resource_dir=resource_dir,
478473
report=report
479474
)
475+
476+
if len(sys.argv) == 2 and sys.argv[1] == "--skip-pdf":
477+
sys.exit(0)
478+
479+
render_report_to_pdf(
480+
report,
481+
Path(__file__).parent / "annual-survey-2024-report.pdf",
482+
"Rust Annual survey 2024 report",
483+
include_labels=False
484+
)

0 commit comments

Comments
 (0)