matplotlib/cheatsheets

Automatic building of the PDF and the PNG files

rougier opened this issue ยท 13 comments

It would be nice to have an automatic building of the PDF and PNG for each commit but I don't know if it is possible with e.g. Travis. It would require a partial TeXLive installation and I'm not sure how to setup.

Also, some have been manually post-processed with pdfcrop (to remove white margin) and this should be automatized.

We use latex as part of our test suite. You can simply define the required apt packages. See e.g. https://github.com/matplotlib/matplotlib/blob/bdf01776977706975d98c6d61b1f345a062fb191/.travis.yml#L51

For the fonts, guess I will to upload them to the repository to be able to compile.

For the fonts, guess I will to upload them to the repository to be able to compile.

๐Ÿ‘

One could write a script that loads the fonts from the respective URLs. But then again, they are not likely to change and not large, so it's probably simpler to vendor them in the repo.

You may also want to use GitHub Actions, which may be a tiny bit faster (kind of depends how you deploy it).

It seems like #57 may have resolved this issue by building the cheatsheets and handouts with GitHub Actions. What #57 does not do is commit the newly-built cheatsheets and handouts; maybe it is best to avoid tracking all the changes in the built documents and it is sufficient to just build them from a reproducible environment. Also, while the documents are currently saved only as build artifacts, it is also possible to include the artifacts in an official release.

Any thoughts on some sort of release plan? Automating the release process with softprops/action-gh-release and including the built documents in the release could further obviate the need to track them in the repository. One way to tag releases could follow semverdoc, or simply a sequence of integral revision numbers, such as r0, r1, and so on, could work.

It probably would be nice to "release" the cheat sheet at least on the same cadence as our minor releases (3.x)? It would be a shame to have the cheat sheet fall out of sync.

For the main library we now have /3.3.2/,..., /3.4.0/, /3.4.1/, and /stable/ pointing at 3.4.1. It would be great if the cheat sheet did the same thing and had the version of matplotlib it was built against on the sheet somewhere.

We also need an automated check on whether the layout is ok. for example if the number of pages is greater than the defautl, we know something is wrong. As for tracking the last version, I think it's only a matter of inserting in the top logo. Problem is that I edited it in inkscape because I was unable to produce it using Matplotlib...

It should in principle be possible to create the logo using Matplotlib (see https://matplotlib.org/stable/gallery/misc/logos2.html#sphx-glr-gallery-misc-logos2-py). However it may be simpler to replace the version number in the svg.

Hello @jklymak. Agreed, the matplotlib version should be indicated on the built cheatsheets and handouts. Currently, the matplotlib dependency is pinned, and should be updated as new matplotlib releases are made. New builds of the cheatsheets and handouts would reflect that version.

Using pdfinfo, it seems possible to run a little script as part of the GHA workflow and check that each document has the expected number of pages. Hey @rougier, can we think of other layout checks?

Thanks for the link @timhoffm. Really liking the idea of generating the logo with a script. One issue is that the Calibri font is proprietary, and not straightforward to install. Maybe it is OK to use the Carlito font in this case. Another option is to use the vanilla logo, and use the overpic (LaTeX) package to mark up the logo during the PDF generation.

@jimustafa number of pages should be a good indicator since the layout is really tight and any differences will immediately result in an increased number of pages. Ideally, a new build could send me an email for visual inspection but it might too much mails if this is done for each commit.

As for the logo, I remenbered having faild at automatically building it. Also, you might notice if you zoom a lot that the current logo includes a small text that we can get rid off.

Added a simple page count check in #60.

Thanks, it has been merged.

With #57 and #63 merged and #66 apparently resolved, it may be that this issue can be closed for now. All of the latest cheatsheets and handouts are automatically built, and, after passing a simple page count check, are pushed to the gh-pages branch. The files are made available at https://matplotlib.org/cheatsheets/cheatsheets.pdf, and similarly for the handouts.