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

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

Open
stelrin opened this issue Nov 6, 2024 · 1 comment
Open

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

stelrin opened this issue Nov 6, 2024 · 1 comment

Comments

@stelrin
Copy link

stelrin commented Nov 6, 2024

Details

class MovingSquareWithUpdaters(Scene):
def construct(self):
decimal = DecimalNumber(
0,
show_ellipsis=True,
num_decimal_places=3,
include_sign=True,
unit=r"\text{M-Units}",
unit_buff_per_font_unit=0.003
)
square = Square().to_edge(UP)
decimal.add_updater(lambda d: d.next_to(square, RIGHT))
decimal.add_updater(lambda d: d.set_value(square.get_center()[1]))
self.add(square, decimal)
self.play(
square.animate.to_edge(DOWN),
rate_func=there_and_back,
run_time=5,
)
self.wait()

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

@behackl
Copy link
Member

behackl commented Nov 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants