sphinxext-opengraph
sphinxext-opengraph copied to clipboard
Refactor social card to enable customizing generation
trafficstars
Closes #145
So... I ended up involuntarily refactoring a large part of social card, here's what happened:
- First, I needed to differentiate the parameters that are here to give context to the image, vs the parameters that are needed for the specific MPL template we're using, so that we don't use them at all if we set up custom images.
- And I needed to split cleanly the code that is MLP-related vs generic
- Then it became quite unclear what the settings actually were because we were reading the config dict in a lot of places. So I made that a dataclass, and tried to group together all the settings
- Then I realized that the tests didn't test the PNG generation so I added that too.
I think I'm also solving a few bugs (some text colors that should have been customizable were not, and an advertised text_color parameter was likely not working).
I'm sorry about the large commit, but I really didn't know how to split it in a way that makes sense.