Skip to content

Compatibility with Sphinx ≥ 4 #14115

Closed

Description

@saimn

Creating this issue to summarize the situation with Sphinx 4, and gather the pieces of information from the various issues/PRs.

So we are pinning Sphinx<4 since May, 2021 (#11724, #11725), because of some duplicate object description warnings with coordinates.builtin_frames and units.function.logarithmic, e.g.:

astropy/coordinates/builtin_frames/galactic.py:docstring of astropy.coordinates.builtin_frames.galactic.Galactic:1:
WARNING: duplicate object description of astropy.coordinates.builtin_frames.galactic.Galactic,
other instance in api/astropy.coordinates.Galactic, use :noindex: for one of them

(Note latest version of Sphinx is 5.3.0)

I tried various solutions:

The reasons for these warnings are described here : sphinx-doc/sphinx#10348 (comment). This is a long comment so I will not copy/paste it here, but it gives a clear explanation of the issue (and possible solutions, except :noindex: doesn't really work).
So if we want to unpin Sphinx (and we should rather not wait too long or other incompatibilities may arise with time), we should find a different solution to document the API for such cases. Maybe with some Sphinx directives manually ?

cc coordinates and units maintainers, @adrn @eteq @eerovaher @mhvk @nstarman

Activity

  1. saimn commented on Dec 6, 2022

    @saimn
    ContributorAuthor

    Also, this is related to how we define our public API (#13910). We expect people to import everything from the top-level sub-packages, so should astropy.coordinates.builtin_frames appear in the API docs (https://docs.astropy.org/en/latest/coordinates/#module-astropy.coordinates.builtin_frames) ? It appears here because of the convenient way to document related functions/classes with automodapi, but maybe that should be done with manual directives instead.

  2. pllim commented on Dec 6, 2022

    @pllim
    Member

    If it is just a matter of some manual doc directives and we can unpin maxversion of Sphinx, I'll call that a big win, so 👍 for manual directives where needed.

    And eventually if we go with an entirely new theme for RTD, then maybe we won't even use automodapi anymore, see astropy/astropy-sphinx-theme#29

  3. mhvk commented on Dec 6, 2022

    @mhvk
    Contributor

    Good point that, indeed, logically if we want people to import from the sub-package top levels, it is not obvious that it makes much sense to give full API for the lower-level ones -- really, that is mostly helpful for developers. And it is good to be able to describe a class as u.Quantity instead of astropy.units.quantity.Quantity.

    But from the sphinx comment you linked to, it looks like the main problem is in fact that at times we ask for API documentation of more than the top-level (astropy.units.LogUnit) and definition-level (astropy.units.function.logarithmic.LogUnit); I think it is in fact fine to not have an index that includes astropy.units.function.LogUnit -- or perhaps even not discuss astropy.units.function at all.

    I'll see if I can get astropy.units to behave at least and will report back...

  4. mhvk commented on Dec 6, 2022

    @mhvk
    Contributor

    Yes, got astropy.units to behave...

  5. saimn commented on Dec 6, 2022

    @saimn
    ContributorAuthor

    But from the sphinx comment you linked to, it looks like the main problem is in fact that at times we ask for API documentation of more than the top-level (astropy.units.LogUnit) and definition-level (astropy.units.function.logarithmic.LogUnit); I think it is in fact fine to not have an index that includes astropy.units.function.LogUnit -- or perhaps even not discuss astropy.units.function at all.

    Yes indeed, the comment on Sphinx explains that better than me :). There is this alias thing but only one alias is possible (without a warning), and the problem is that we have three levels here:
    https://docs.astropy.org/en/latest/api/astropy.units.LogUnit.html
    https://docs.astropy.org/en/latest/api/astropy.units.function.LogUnit.html
    https://docs.astropy.org/en/latest/api/astropy.units.function.logarithmic.LogUnit.html

  6. saimn commented on Dec 6, 2022

    @saimn
    ContributorAuthor

    And eventually if we go with an entirely new theme for RTD, then maybe we won't even use automodapi anymore, see astropy/astropy-sphinx-theme#29

    Just to be clear, the theme is independent from the way to document the API (which generates some RST directives for Sphinx's autodoc plugin). But I'm 👍 on moving to pydata-sphinx-theme which is better maintained than our theme and already used by many pydata projects (numpy, scipy etc.).

  7. mhvk commented on Dec 6, 2022

    @mhvk
    Contributor

    @saimn - indeed, I got units to work by removing the "middle" level -- in your attempt, I think you had mistakenly taken out the lower one -- and also by changing a few references in the docs to point to the canonical level.

  8. saimn commented on Dec 6, 2022

    @saimn
    ContributorAuthor

    Oh, so you removed the units.function one ? Yeah, makes sense now.

  9. mhvk commented on Dec 6, 2022

    @mhvk
    Contributor

    Yes. Also, wcs was just a problem with links inside the file not going to canonical. Now on to coordinates -- which is a grand mess...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions