Coming back from a 2D animation project I really missed the onion skinning features in Maya. So I decided to dive into the Maya api a bit. The solution i was aiming for was a renderer based approach. So there I was, having no clue of anything, trying to make sense of the Maya API. With the help of the examples provided with Maya and heavy use of Google, I was able to cobble together a working version of the idea. You can try it for yourself by venturing to my Github page. If you do like it or you know ways of improving please just let me know. Email is on the about page. Here is a short tutorial on how it works.
Under the hood it works by rendering every frame one more time with only the objects that should be onionized. This rendering is then buffered and when needed put on top of the window. This allows for relative onion display, where only the onions close to the time slider are displayed. This approach has one obvious disadvantage. It updates only the frame you are currently on. So you need to rebuffer to see changes. This is especially annoying when you move the camera as you need to rebuffer everything. The advantage is, that it is independent of the complexity of the geometry. Really anything the Maya viewport can handle can be buffered.
The ui is built in QT designer, which fortunately comes with Maya. I really cannot imagine anymore coding a ui by hand. I just convert the ".ui" file that I get to python using pyside2uic. All I do in code is setting up the connections to the core and adjusting the ui if items are added.