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

generate styled dataset PDF #1075

Merged
merged 7 commits into from
Oct 2, 2024
Merged

generate styled dataset PDF #1075

merged 7 commits into from
Oct 2, 2024

Conversation

damonmcc
Copy link
Member

@damonmcc damonmcc commented Aug 14, 2024

related to #944, #561

This is a first pass at styling our data dictionary PDFs, not an attempt to use the exact styling that the Design fellows proposed in fIgma.

changes

  • refactor tests related to generating PDF and XLSX data dictionaries
  • use weasyprint to generate styled PDFs via templated HTML and a CSS stylesheet

old vs new PDF

Old

Screenshot 2024-10-02 at 12 38 46 PM

New

Screenshot 2024-10-02 at 12 41 04 PM

@damonmcc damonmcc force-pushed the dm-package-readme branch 7 times, most recently from 9ddbc03 to 32e4f18 Compare August 16, 2024 02:47
@damonmcc damonmcc force-pushed the dm-package-readme branch 6 times, most recently from 9879a4e to 684eb5c Compare August 26, 2024 15:24
@alexrichey alexrichey linked an issue Sep 4, 2024 that may be closed by this pull request
5 tasks
@damonmcc damonmcc force-pushed the dm-package-readme branch 4 times, most recently from b498749 to f7bb6cc Compare September 18, 2024 16:03
Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.83%. Comparing base (6c3d2bb) to head (4bd6a8d).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1075   +/-   ##
=======================================
  Coverage   68.83%   68.83%           
=======================================
  Files         108      108           
  Lines        5513     5513           
  Branches      810      809    -1     
=======================================
  Hits         3795     3795           
  Misses       1592     1592           
  Partials      126      126           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@damonmcc damonmcc force-pushed the dm-package-readme branch 4 times, most recently from 27ae351 to 9c06034 Compare September 23, 2024 14:24
@damonmcc damonmcc force-pushed the dm-package-readme branch 3 times, most recently from c8292bf to a8d30a1 Compare October 1, 2024 23:38
@damonmcc damonmcc changed the title add readme to dataset packages generate styled dataset PDF Oct 2, 2024
@damonmcc damonmcc force-pushed the dm-package-readme branch 2 times, most recently from e16f93f to da37bc1 Compare October 2, 2024 13:52
@damonmcc damonmcc marked this pull request as ready for review October 2, 2024 16:53


def generate_pdf_from_html(output_html_path: Path, output_pdf_path: Path) -> Path:
def generate_pdf_from_html(
output_html_path: Path,
Copy link
Contributor

Choose a reason for hiding this comment

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

change to input_html_path?

Copy link
Member Author

Choose a reason for hiding this comment

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

changed all of em to be shorter and consistent with write_oti_xlsx

subprocess.run(
[
"pandoc",
"weasyprint",
Copy link
Contributor

Choose a reason for hiding this comment

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

💪



def generate_pdf_from_html(output_html_path: Path, output_pdf_path: Path) -> Path:
def generate_pdf_from_html(
Copy link
Contributor

Choose a reason for hiding this comment

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

Want to add a typer command for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

was tempted to but I'd rather do that after considering whether this file generate_metadata_assets.py and oti_xlsx.py should even be separate files

if they're worth combining, that'd influence the existing/new typer commands

yaml_file_path = TEST_METADATA_YAML_PATH
output_html_path = TEMP_DATA_PATH / "metadata.html"
output_pdf_path = TEMP_DATA_PATH / "metadata.pdf"
output_xlsx_path = TEMP_DATA_PATH / "my_data_dictionary.pdf"
Copy link
Contributor

Choose a reason for hiding this comment

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

hopefully still an xlsx after this refactor?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed!

Copy link
Contributor

@alexrichey alexrichey left a comment

Choose a reason for hiding this comment

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

Good stuff! Happy to see weasyprint proven out. A few nits, but no need to re-request review if you get to them.

@@ -8,16 +8,21 @@
DEFAULT_DATA_DICTIONARY_TEMPLATE_PATH = (
RESOURCES_PATH / "data_dictionary_template.jinja"
)
DEFAULT_DATA_DICTIONARY_STYLESHEET_PATH = RESOURCES_PATH / "data_dictionary.css"
Copy link
Member Author

Choose a reason for hiding this comment

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

noting that I'm not sure if these DEFAULT_* variables are the best approach, just wanted to minimize changes in this PR

@damonmcc damonmcc merged commit 6322eb2 into main Oct 2, 2024
20 checks passed
@damonmcc damonmcc deleted the dm-package-readme branch October 2, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants