Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class namespace collision between autodoc signatures and docutils >= 0.17 #9872

Closed
ebolyen opened this issue Nov 19, 2021 · 2 comments
Closed

Comments

@ebolyen
Copy link
Contributor

ebolyen commented Nov 19, 2021

Describe the bug

In docutils version 0.17, the following change was made:

Use HTML text-level tags <small>, <s>, <q>, <dfn>, <var>, <samp>, <kbd>, <i>, <b>, <u>, <mark>, and <bdi> if a unique, matching class value is found in inline and literal elements. Use <ins> and <del> if a unique matching class value is found in inline, literal, or container elements. Use <small> for generated code line numbers.

This appears to conflict with the signature line generated by autodoc, which adds Pygment classes to certain nodes:

sphinx/sphinx/addnodes.py

Lines 332 to 334 in ecee233

class desc_sig_literal_string(desc_sig_element):
"""Node for a string literal in a signature."""
classes = ["s"]

The result is a rather funky looking signature with an unusual DOM:
image
image


This can be fixed by changing the added class to something like pygments-s:
image
image

That said, the above probably won't play nicely with the many existing pygment stylesheets, so I don't really know the best approach.

How to Reproduce

Use a typing.Literal['foo'] in an autodoc'ed signature line.

Expected behavior

No response

Your project

qiime2/qiime2#610

Screenshots

No response

OS

Linux

Python version

3.8

Sphinx version

4.3

Sphinx extensions

sphinx.ext.autodoc

Extra tools

Firefox/Chrome

Additional context

No response

@ebolyen
Copy link
Contributor Author

ebolyen commented Nov 19, 2021

I should mention I also tried returning multiple classes like ["pygments", "s"],
but all that earned me from docutils was a <s class="pygments">...</s>

@lorenzncode
Copy link

I also see this issue building docs for another project:

https://cadquery--916.org.readthedocs.build/en/916/classreference.html#cadquery.Workplane.mirror

image

@tk0miya tk0miya added this to the 4.3.1 milestone Nov 21, 2021
@tk0miya tk0miya closed this as completed Nov 22, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants