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

Update requirements.txt file for changes in #452 #530

Merged

Conversation

glinesbdev
Copy link
Contributor

@glinesbdev glinesbdev commented Jan 3, 2024

Supersedes and closes #452
Original OP follows:


It may seem a bit convoluted, but it works:

8mb.video-WRi-EDN02djp.mp4

Some more stuff is needed to merge this but we should be already at a pretty good point:

  • move from pygal to matplotlib Migrate from pygal  #449
  • make the output SVG use the CSS variables instead of hardcoded colross
  • update requirements.txt
  • move the call to the plot generation from the renderer to the preproc step of mdbook, otherwise the output SVG files cannot be inline injected
    • We should consider just calling a python script, instead of having the single calls for every plot like it is now here. @ISSOtm opinions?
  • replace the two img tags with #import in the MBC5 article so the svg is actually injected in the HTML

Fixes #322

@ISSOtm
Copy link
Member

ISSOtm commented Jan 3, 2024

Alright, I have edited the OP to replicate the original PR's. That means what's left is only mdBook "wiring up", which falls under my responsibility... so I'll have to do that then. :P

Thank you @glinesbdev!

Copy link
Sponsor Member

@avivace avivace left a comment

Choose a reason for hiding this comment

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

This is amazing, @glinesbdev . Putting some sense into what I wrote and making this modular will be super useful also when not generating graphs but when we'll want to make other svgs "theme-able". Thanks a lot!

I'm trying the command line usage but when I run:

python graph_render.py MBC5_Rumble_Mild.csv "MBC5_Rumble_Mild"

The svg is printed out in the stdout and then two svg are actually generate, a "test.svg" and an "output.svg"..

Is this expected?

And also use the newly-generated graphs in the MBC5 page
@ISSOtm
Copy link
Member

ISSOtm commented Feb 20, 2024

I finally found some time to hook up this PR's Python to a mdBook preproc.

It has to be a preproc, not a renderer/backend, because the files are {{#include}}d, and those are processed by the built-in links preproc. So they must be generated before then.

I used a separate script for the preproc, so that graph_render.py can still be invoked stand-alone. (For any reason.) I thus made the CLI logic only run if not imported. I also modified the "core" logic to make matplotlib write to an in-memory buffer rather than to a temporary file, to avoid any problems with the file already existing or whatnot.

Also, the generated files cannot go under src, otherwise they trigger mdBook's "did something change?", which re-builds... thus in a loop.

@ISSOtm ISSOtm dismissed avivace’s stale review February 20, 2024 09:12

The output logic was changed

@ISSOtm ISSOtm requested a review from avivace February 20, 2024 09:12
Copy link
Member

@ISSOtm ISSOtm left a comment

Choose a reason for hiding this comment

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

Thank you @glinesbdev! My apologies for taking this long to do the mdBook part of this PR.

Copy link
Sponsor Member

@avivace avivace left a comment

Choose a reason for hiding this comment

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

Amazing work. Thanks for cleaning up my initial work and hooking it up @glinesbdev and @ISSOtm !

@avivace avivace merged commit 0a909c1 into gbdev:master Feb 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow SVG to be affected by theme
3 participants