Repository: ManimCommunity/manim

Issue:
Better Error Messages for Manim Directive when Failing Animations are Present with Documentation Generation
The `_log_rendering_times` function in `manim_directive.py` throws an index out of bounds error if an animation has failed during rendering because then parameter list contains empty lists instead of the usual animation name and a "FAILED" for the time

```
[['examples', 'ManimCELogo', '0.084'], [], ['examples', 'BraceAnnotation', '0.241'], [], ['examples', 'VectorArrow', '0.086'], [], ['examples', 'GradientImageFromArray', '0.066'], [], ['examples', 'BooleanOperations', '2.433'], [], ['examples', 'PointMovingOnShapes', '0.120'], [], ['examples', 'MovingAround', '0.095'], [], ['examples', 'MovingAngle', '0.188'], [], ['examples', 'MovingDots', '0.088'], [], ['examples', 'MovingGroupToDestination', '0.092'], [], ['examples', 'MovingFrameBox', '1.350'], [], ['examples', 'RotationUpdater', '0.090'], [], ['examples', 'PointWithTrace', '0.115'], [], ['examples', 'SinAndCosFunctionPlot', '0.471'], [], ['examples', 'ArgMinExample', '0.252'], [], ['examples', 'GraphAreaPlot', '0.214'], [], ['examples', 'PolygonOnAxes', '0.357'], [], ['examples', 'HeatDiagramPlot', '0.292'], [], ['examples', 'FollowingGraphCamera', '0.221'], [], ['examples', 'MovingZoomedSceneAround', '2.053'], [], ['examples', 'FixedInFrameMObjectTest', '0.554'], [], ['examples', 'ThreeDLightSourcePosition', '1.532'], [], ['examples', 'ThreeDCameraRotation', '2.676'], [], ['examples', 'ThreeDCameraIllusionRotation', '1.044'], [], ['examples', 'ThreeDSurfacePlot', '1.853'], [], ['examples', 'OpeningManim', '3.526'], [], ['examples', 'SineCurveUnitCircle', '0.263'], [], ['guides/configuration', 'ShowScreenResolution', '0.068'], [], ['guides/deep_dive', 'ToyExample', '0.123'], [], ['guides/deep_dive', 'VMobjectDemo', '0.052'], [], ['guides/using_text', 'HelloWorld', '0.093'], [], ['guides/using_text', 'SingleLineColor', '0.132'], [], ['guides/using_text', 'FontsExample', '0.116'], [], ['guides/using_text', 'SlantsExample', '0.073'], [], ['guides/using_text', 'DifferentWeight', '0.782'], [], ['guides/using_text', 'SimpleColor', '0.097'], [], ['guides/using_text', 'Textt2cExample', '0.101'], [], ['guides/using_text', 'GradientExample', '0.057'], [], ['guides/using_text', 't2gExample', '0.113'], [], ['guides/using_text', 'LineSpacing', '0.171'], [], ['guides/using_text', 'DisableLigature', 
'0.190'], [], ['guides/using_text', 'IterateColor', '0.082'], [], ['guides/using_text', 'MarkupTest', '0.252'], [], ['guides/using_text', 'HelloLaTeX', '0.080'], [], ['guides/using_text', 'MathTeXDemo', '0.151'], [], ['guides/using_text', 'AMSLaTeX', '0.097'], [], ['guides/using_text', 'LaTeXAttributes', '0.099'], [], ['guides/using_text', 'AddPackageLatex', '0.091'], [], ['guides/using_text', 'LaTeXSubstrings', '0.124'], [], ['guides/using_text', 'IncorrectLaTeXSubstringColoring', '0.223'], [], ['guides/using_text', 'CorrectLaTeXSubstringColoring', '0.258'], [], ['guides/using_text', 'IndexLabelsMathTex', '0.113'], [], ['guides/using_text', 'LaTeXMathFonts', '0.137'], []]
```


This might be fixed by rewriting how failed animations are handled before this functino is called


Discussion:
Taking a look at this, it seems that the empty lists are not from failed rendering attempts or anything like that; they're quite literally just empty lists that have somehow been appended to the file (I could not figure out how). As such, a simple fix like changing line 346 of `manim\utils\docbuild\manim_directive.py` from
```py
max_file_length = max(len(row[0]) for row in data)
```
to
```py
max_file_length = max(len(row[0]) for row in data if row)
```
should fix the problem without skipping out on any of the rendering data.

Resolving patch:
diff --git a/manim/utils/docbuild/manim_directive.py b/manim/utils/docbuild/manim_directive.py
--- a/manim/utils/docbuild/manim_directive.py
+++ b/manim/utils/docbuild/manim_directive.py
@@ -343,6 +343,9 @@ def _log_rendering_times(*args):
 
         print("\nRendering Summary\n-----------------\n")
 
+        # filter out empty lists caused by csv reader
+        data = [row for row in data if row]
+
         max_file_length = max(len(row[0]) for row in data)
         for key, group in it.groupby(data, key=lambda row: row[0]):
             key = key.ljust(max_file_length + 1, ".")


Test patch: