manim icon indicating copy to clipboard operation
manim copied to clipboard

Sphinx is interpreting `\t` as a tab character in the docstring

Open stelrin opened this issue 1 year ago • 2 comments

Details

https://github.com/ManimCommunity/manim/blob/ee0501c2b6a1e1d2e6171d9b24380c3473df817f/manim/mobject/text/numbers.py#L60-L80 In the code, the unit argument is set to r"\text{M-Units}", but Sphinx’s docstring extraction processes \t as a tab space. The documentation and the animation renders incorrectly as a result.

Screenshot of the documentation issue (link):

swappy-20241106_202037

stelrin avatar Nov 06 '24 19:11 stelrin

This is actually a pretty interesting problem. A simple workaround would be to rewrite the raw string to a normal one, while properly escaping the backslash.

I think that a proper fix, allowing our directive to read the content as a raw string (actually: preserving the raw string behavior in raw strings within the content passed to the directive) would require significantly more effort.

behackl avatar Nov 06 '24 20:11 behackl

Hi, I want to work on this issue and contribute, can I work on this issue please? Thank you.

SgtApone117 avatar Dec 07 '24 01:12 SgtApone117

I just forked the repo and locally cloned it onto my machine, if I am not wrong it might be something to do with using the character " (line 67) in a block which is already using """ (line 25)

Has someone tried writing it as :

unit=r'\text{M-Units}',

Technically, ' ' is used withing a block which is already enclosed in a " " or """ """ block

So instead this could be done :

r"""An mobject representing a decimal number.
    # code
    unit=r'\text{M-Units}',
    # code
"""

Should I submit a pull request implementing this?

adityakiran1423 avatar Jan 25 '25 08:01 adityakiran1423

Feel free to try whether this fixes the issue @adityakiran1423, sure!

behackl avatar Jan 25 '25 09:01 behackl

@behackl sorry for my late response, I was travelling. Sure, I will make a PR and see if it fixes the issue

adityakiran1423 avatar Jan 28 '25 17:01 adityakiran1423

Hi, is this issue still open ? I'm new to open source but i'd like to work on this.

Rohan-lahane avatar Jul 19 '25 10:07 Rohan-lahane

Hi, is this issue still open ? I'm new to open source but i'd like to work on this.

I just checked https://docs.manim.community/en/stable/reference/manim.mobject.text.numbers.DecimalNumber.html and it appears that the problem has been resolved in the meantime. There is lots of other issues that would need a helping hand though! 👋

behackl avatar Jul 19 '25 10:07 behackl