Coder Social home page Coder Social logo

Comments (3)

njsmith avatar njsmith commented on May 20, 2024

Would it be easy to post a tiny working example?

from sphinxcontrib-trio.

Fuyukai avatar Fuyukai commented on May 20, 2024

https://github.com/SunDwarf/sphinxcontrib-trio-issue-8
This should be all that's need to show the issue. Just pipenv install; cd docs; make html.

aaa

Notice the missing await at the beginning of test_one despite it being an async function. The trio docs don't have this issue, despite using autodoc.

from sphinxcontrib-trio.

njsmith avatar njsmith commented on May 20, 2024

Ughhhh sphiiinnnnx.

sphinx.ext.autosummary has a helper script to generate new .rst files on the fly. It's written as a standalone script, sphinx/ext/autosummary/generate.py. So it can't assume that it's run inside a normal sphinx environment – but it wants to use autodoc functionality anyway. So at import time, it attempts to set up a fake autodoc environment, by manually registering all the normal autodoc classes.

The sphinx.ext.autosummary extension has a callback for the sphinx build-inited event, which calls sphinx.ext.autosummary.process_generate_options. Then process_generate_options imports sphinx.ext.autosummary.generate. So at some point after sphinx's initial configuration is read and all plugins – like sphinxcontrib-trio are loaded – we end up running the code in generate.py to set up the fake autodoc environment, and since we're doing this inside the real sphinx process, it ends up overwriting the normal autodoc environment. And in particular it overwrites sphinxcontrib-trio's customized autofunction/automethod directives.

sphinxcontrib-asyncio is spared, because of a confusing thing where you can have multiple autodoc classes registered to provide documentation for, say, functions, and they're selected based on their .priority attributes. But each such class has an associated directive name, and you can't have multiple autodoc classes registered with the same directive name at the same time. sphinxcontrib-trio takes over the regular automethod and autofunction directives, so its classes get lost when the default classes are reloaded; sphinxcontrib-asyncio uses autocomethod and autocofunction directives, so they survive.

It looks like this was already fixed in 1.7, sort of accidentally in passing – in addition to other changes, this commit moves the fake autodoc setup code so that it's called from main rather than at import time: sphinx-doc/sphinx@5d6413b

In the mean time, there's a silly but simple fix: we can import sphinx.ext.autosummary.generate ourselves up front, to get all the import side-effects out of the way before we register our autodoc classes.

from sphinxcontrib-trio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.