sublime_lib icon indicating copy to clipboard operation
sublime_lib copied to clipboard

Include type hints in documentation

Open FichteFoll opened this issue 5 years ago • 3 comments

The issue mentioned in https://github.com/SublimeText/sublime_lib/issues/118#issuecomment-499098498 for improving type hint rendering through sphinx has been closed (https://github.com/sphinx-doc/sphinx/issues/5868). From my understanding, this should allow us to add type hints to the documentation without the rendering problems that had been encountered before.

FichteFoll avatar May 24 '20 12:05 FichteFoll

After experimenting with the improved type hint output, I have come to the conclusion that it's still awful. But probably not totally unworkable.

Thom1729 avatar Jun 25 '20 05:06 Thom1729

Do you happen to have a screenshot with example rendering? Or do you know of another project using typehints in sphinx?

FichteFoll avatar Jun 26 '20 01:06 FichteFoll

The default rendering isn't any different, but I've used the new markup to make some basic improvements:

snip

In the type-annotations-in-docs branch, I've used a heavier weight for the parameter name, and there shouldn't be line breaks within a parameter. It's still an awful mess on longer signatures, though:

snip2

I'm experimenting with various ways of cleaning that up. It's difficult because the new markup isn't very granular and the classes are very generic.

There are also bugs; for instance, a lot of functions have the wrong arguments displayed because the function is decorated and Sphinx doesn't respect functool.wraps. The workaround on their issue tracker is to monkey-patch functools.wraps, but I think it could be done less terribly.

Thom1729 avatar Jun 26 '20 02:06 Thom1729