question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@vectorize-decorated functions are not found by sphinx

See original GitHub issue

I use sphinx with the apidoc extension to have a reference documentation generated automatically. For functions decorated with njit this works without any complications, for vectorize however, the function disappears from the docs, indicating that apidoc either cannot find it or decides not to include it. (Sorry for the lack of better info).

Since this is sphinx related I am not sure how to include a minimal example, but if it would help and I find some time I can try to set up a mini-repository.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:18 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
guilhermeleobascommented, Apr 11, 2021

@HPLegion, thanks for the sphinx extension for autodoc. I tried to change it to work with autosummary + @intrinsic:

import numba
from typing import List, Optional
from sphinx.ext.autodoc import FunctionDocumenter


class NumbaDocumenter(FunctionDocumenter):
    """Sphinx directive that also understands numba decorators"""

    objtype = 'function'  # This must be assigned to 'function' to work!!
    directivetype = 'function'

    @classmethod
    def can_document_member(cls, member, membername, isattr, parent):
        if isinstance(member, numba.core.extending._Intrinsic):
            return True
        return super(RBCDocumenter, cls).can_document_member(member, membername, isattr, parent)


def setup(app):
    """Setup Sphinx extension."""

    # Register the new documenters and directives (autojitfun, autovecfun)
    # Set the default prefix which is printed in front of the function signature
    app.setup_extension('sphinx.ext.autodoc')
    app.add_autodocumenter(NumbaDocumenter)

    return {
        'parallel_read_safe': True
    }

Also, in order for this to work, one needs to update the intrinsic wrapper:

import functools
functools.update_wrapper(my_intrinsic, my_intrinsic._defn)  # _defn is the inner function
1reaction
soleticommented, Aug 28, 2020

I tried adapting the jit-documenter stuff but I couldn’t get it to work. I adopted a solution that I am ashamed of but that works: running this before sphinx 😃

find mypackage/ -name '*.py' -exec sed -i -e 's/@cuda/#@cuda/g' {} \;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sphinx can't find my functions (probably due to imports or ...
I found that docs/source/packagename.rst contains automodule:: scriptname but it should (it was only correct before I made folder structure ...
Read more >
Uncovering Secrets of the Sphinx - Smithsonian Magazine
After decades of research, American archaeologist Mark Lehner has some answers about the mysteries of the Egyptian colossus.
Read more >
Sphinx | Definition, History, Examples, & Facts | Britannica
sphinx, mythological creature with a lion's body and a human head, an important image in Egyptian and Greek art and legend. The word...
Read more >
Sphinx water erosion hypothesis - Wikipedia
Contents · 2.1.1 Causeway · 2.1.2 Sphinx Temple and Khafre Valley Temple · 2.1.3 Missing archaeological evidence for an earlier civilization.
Read more >
HERODOTUS AND THE MISSING SPHINX | Journal for Semitics
HERODOTUS AND THE MISSING SPHINX ... have been familiar with the sphinx which features in the story of Oedipus, mythical king of Thebes....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found