ManimCommunity / ManimCommunity/manim

Manim directive duplicates code

Open
#3,994 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior
When using manim_directive for including Manim videos in a Sphinx document, the code snippet is duplicated in the rendered output.
For example, given this .rst file:

```rst
My Plugin Documentation
=======================

Test
----

TODO

.. manim:: MyScene

class MyScene(Scene):
def construct(self):
circle = Circle()
self.play(Create(circle))
self.wait()
```

This is the result:

![image](https://github.com/user-attachments/assets/62427f18-e2bd-46b1-a273-6baba1c85dad)

## Expected behavior
The second code snippet should not be there. A workaround is removing the relative HTML code, that is:

```HTML

class MyScene(Scene):

def construct(self):
circle = Circle()
self.play(Create(circle))
self.wait()


```

This is the result:

![image](https://github.com/user-attachments/assets/e76cffac-a57f-40d9-ab16-3a02956e73b5)

## How to reproduce the issue
1. Use manim_directive with a simple scene, as shown in the example below.
2. Render the scene.

## System specifications

System Details

- OS: macOS 12.7.5 (Monterey)
- RAM: 8GB
- Python version (`python/py/python3 --version`): 3.12.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided .rst example and inspect the manim_directive output during Sphinx rendering. Compare the generated HTML with the workaround, and consider the issue done when the rendered scene contains the video without a duplicated code snippet.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.