Closed tavianator closed 4 years ago
I forgot to say it, but thanks for the patch! :-) I don't use TS myself, and nobody's maintaining sphinx-js's support at the moment, so I'm very keen to have your interest.
Sure, I'm happy to add some tests for it.
The error I was getting happens when building the docs. With the new behaviour, both overloads are listed in the docs, which is probably what you want (TypeDoc also lists both, but only one at a time, like this: https://typedoc.org/api/classes/application.html#generatedocs). Here's what the result looks like in sphinx-js: https://bistring.readthedocs.io/en/latest/JavaScript/Alignment.html#Alignment.originalBounds
The tree that reports the conflicts is used to resolve links I believe. So when you write something like :js:meth:`Alignment.originalBounds`
, it has to resolve that to the actual element to link to. This change makes it just pick the first overload arbitrarily. I'm open to other behaviours here, or other ways of rendering overloads.
You're welcome for the patch! :)
Tested it quickly, seems to work. This is definitely much better than throwing errors. Let's get some tests for this and merge it!
@graup Added a simple test!
@erikrose The code I changed doesn't distinguish between vanilla JS and TypeScript, so I'm pretty sure it won't. There's another issue as well: if you do something like .. js:autofunction:: overloaded
it will only render one of them. I guess the tree needs to hold a list of matching elements rather than just one.
@erikrose I'd be happy to contribute. Should we open a new issue to design an IR and coordinate working on a branch together?
There are also some problems with some other ts features currently not supported by the jsdoc representation that we could fix then.
I think an IR would be nice. Would enable us to have TS-specific things in the documentation as first-class citizens.
To avoid needing to mess with typedoc.py at first, since we already have TypeDoc -> JSDoc, we could start with just doing TypeDoc -> JSDoc -> IR. Then later rewrite the conversion to just do TypeDoc -> IR, and compare the results on some corpus of existing TypeScript projects.
I don't have a tremendous amount of time to contribute to this but I'm happy to review designs and implementations, and maybe do some of the TS side of it.
Alright, I started doing some of the initial spec work toward an IR over at #120. Help is welcome!
It doesn't crash anymore as of the great IR merge of #120, demonstrated by https://github.com/mozilla/sphinx-js/blob/705659ceb08de1ec1fd16bdefd53e7b2e0a8d848/tests/test_typedoc_analysis/test_typedoc_analysis.py#L336-L344. But we should probably show multiple signatures if the Sphinx templates will let us. I've opened #153 to represent that work.
Fixes #110.