python-trio / hip

A new Python HTTP client for everybody
Other
79 stars 22 forks source link

Improve documentation UX for sync and async APIs #214

Open sethmlarson opened 4 years ago

sethmlarson commented 4 years ago

Some discussions around how we can provide both examples and an API reference for Hip when there are namespaces with very similar but obviously have basically two separate audiences.

A great idea from @njsmith was to do something similar to a lot of projects that support multiple programming languages (Python, Java, Ruby, etc) and have a "Sync / Async" toggle on documentation navigation. Would change all code examples and autodoc refs from ahip to hip, have/exclude async/await etc.

This would be especially useful for the reference as it will be mostly symmetrical thanks to unasync.

Some thoughts and ideas that came up:

pquentin commented 4 years ago

What do you think about using something like https://djungelorm.github.io/sphinx-tabs/#code-tabs?

When you choose a different language, all other snippets in the page automatically show that language.

This specific extension does not degrade gracefully: without JS we only see the first tab instead of seeing all of them. I guess that's fixable. But at least that's a solution that already works today.

Should this slider be extended to Sync, Trio, Asyncio, Curio?

I guess ultimately including all frameworks we support is nice because I prefer code snippets that can be run as-is. It shouldn't be too hard as everything should be generated anyway. But it's not mandatory either, just a nice touch.

sethmlarson commented 4 years ago

Maybe the tabbed approach can be used for the asynclib-specific examples and the global Sync / Async can apply to the API ref