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

autodoc strips spaces from values #8446

Closed
hansonap opened this issue Nov 18, 2020 · 3 comments
Closed

autodoc strips spaces from values #8446

hansonap opened this issue Nov 18, 2020 · 3 comments

Comments

@hansonap
Copy link

If I define a module level data as:

INDENT: str = '    ' 
"""
: Defines the single level indentation that will be used in the generated stubs /  wrapper. Default is four spaces. 
Can be overridden if necessary.
"""

and in my .rst file

.. autodata:: INDENT

It is rendered as as a single space
image

Expected result is four spaces as defined in .py file.

Same result if defined with .. data:: directive.

@tk0miya
Copy link
Member

tk0miya commented Nov 19, 2020

It is converted to the following HTML:

<code class="sig-prename descclassname">example.</code><code class="sig-name descname">INDENT</code><em class="property">: str</em><em class="property"> = '    '</em>

The four spaces are kept as is. But HTML browsers consider them as one space. It should be escaped on generating HTML.

@hansonap
Copy link
Author

Got it, thanks for the explanation.

I can probably tackle this if no one has started working it yet. Looks like HTMLTranslator in sphinx/writers/html.py is a logical starting point?

@tk0miya
Copy link
Member

tk0miya commented Nov 21, 2020

I still don't have time to investigate this yet. So I don't have an answer for your question. But it and sphinx/domains/python.py would be related to this problem, I suppose.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Nov 22, 2020
…space

In HTML, consective spaces are considered as single space by HTML
browsers.  To represent them as is, we have to escape them on rendering
them into HTML.  This starts to escape the whole of desc_signature node.
tk0miya added a commit to tk0miya/sphinx that referenced this issue Nov 22, 2020
…space

In HTML, consective spaces are considered as single space by HTML
browsers.  To represent them as is, we have to escape them on rendering
them into HTML.  This starts to escape the whole of desc_signature node.
tk0miya added a commit to tk0miya/sphinx that referenced this issue Nov 22, 2020
… space

In HTML, consecutive spaces are considered as single space by HTML
browsers.  To represent them as is, we have to escape them on rendering
them into HTML.  This starts to escape the whole of desc_signature node.
tk0miya added a commit to tk0miya/sphinx that referenced this issue Nov 22, 2020
… space

In HTML, consecutive spaces are considered as single space by HTML
browsers.  To represent them as is, we have to escape them on rendering
them into HTML.  This starts to escape the whole of desc_signature node.
@tk0miya tk0miya modified the milestones: 3.4.0, 3.5.0 Dec 19, 2020
tk0miya added a commit that referenced this issue Jan 31, 2021
…signatures

Fix #8446: html: consecutive spaces are displayed as single space
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 14, 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

2 participants