Hi! Thanks for the library, it looks very promising and I can't wait to try it. I would like to use the extension with ArviZ docs. So far I haven't managed to get it to work so I'll try to go over my experience here so that you can hopefully guide me into opening proper issues for bug reports (if any) and enhancements as well as some PRs to improve documentation of the extension?
The first thing is that it took me a while to see if the extension would work at all in our case, as we don't really have any .. code::
blocks, we use matplotlib's, ipython's or bokeh's directives to get the code to autoexecute and include the output, as well as jupyter notebooks parsed with myst_parser. All three directives seem to also use highlight-python notranslate
so it looks like they should be compatible out of the box and I did try using the matplotlib example on your homepage to use the plot directive and worked. But it might be worth it to explain what are the actual requirements for this to work or include some examples in the docs, perhaps with ipython and matplotlib ones that are quite popular to show they work too.
myst seems to use highlight-ipython3 notranslate
which I'm not sure how easy it would be to cover too. This page for example is generated from a jupyter notebook: https://arviz-devs.github.io/arviz/getting_started/Introduction.html.
I naively added the highlight-ipython3 notranslate
to https://github.com/felix-hilden/sphinx-codeautolink/blob/master/src/sphinx_codeautolink/extension/block.py#L193 to see what happened and added a jupyter notebook file to the example docs in my fork. The code in the notebook was not hyperlinked, but at least it did not break the rendering nor links for the rest of the pages, which for now is good enough.
I eventually moved to try it on in ArviZ docs, installed the extension, added it to conf.py and set codeautolink_autodoc_inject = False
as we don't want the auto tables there, they would quickly become quite large and we'd rather users focus on the examples in the docstring for quick reference or on the dedicated plotting, labeling... guides for specific tasks which are also useful even if the exact function is not being used as many arguments are common between most plotting functions for example. But I still haven't managed to get the docs to build, I get the following error:
Extension error (sphinx_codeautolink.extension):
Handler <bound method SphinxCodeAutoLink.generate_backref_tables of <sphinx_codeautolink.extension.SphinxCodeAutoLink object at 0x7f8d6a43b2e0>> for event 'doctree-resolved' threw an exception (exception: 'builtin_function_or_method' object has no attribute '__annotations__')
I am trying to build only part of the docs to see if I can identify what triggers that error, but so far all the subsets I have tried end up just like this. I was also wondering if this step is always necessary or if it's only necessary when planning to generate example tables either automatically or with the directive. In our case, even a hacky workaround that completely disables the feature and only adds links to code would be amazing, not sure if it's possible.
I also removed autodoc in one of the experiments when trying to remove the api section completely from the equation which triggered a whole different error. I didn't completely understood the error nor why was it triggered by autodoc being missing, but I think the extension would be also extremely useful in documentation that doesn't use autodoc at all. I am thinking for example about collections of tutorials and case studies like https://pymc-examples.readthedocs.io/en/latest/ that thanks to the integration with intersphinx could easily link from case studies to the api docs in the main documentation website.