Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

added more docstrings

Aron Fischerf5a0174bd301
diff --git a/manim/utils/tex.py b/manim/utils/tex.py
index 802c0e370..b865eaa48 100644
--- a/manim/utils/tex.py
+++ b/manim/utils/tex.py
@@ -11,7 +11,7 @@ import os
class TexTemplate:
- """A TeX template to be used for creating Tex() and MathTex() objects."""
+ """TeX templates are used for creating Tex() and MathTex() objects."""
default_documentclass = r"\documentclass[preview]{standalone}"
default_preamble = r"""
@@ -138,9 +138,7 @@ class BasicTexTemplate(TexTemplate):
class TexTemplateFromFile(TexTemplate):
- """
- A TexTemplate object created from a template file (default: tex_template.tex)
- """
+ """A TexTemplate object created from a template file (default: tex_template.tex)"""
def __init__(self, **kwargs):
self.template_file = kwargs.pop("filename", "tex_template.tex")
diff --git a/manim/utils/tex_file_writing.py b/manim/utils/tex_file_writing.py
index 24b319e3f..aa00c3c4c 100644
--- a/manim/utils/tex_file_writing.py
+++ b/manim/utils/tex_file_writing.py
@@ -22,6 +22,7 @@ def tex_hash(expression):
def tex_to_svg_file(expression, environment=None, tex_template=None):
+ """Takes a tex expression and returns the svg version of the compiled tex"""
if tex_template is None:
tex_template = config["tex_template"]
tex_file = generate_tex_file(expression, environment, tex_template)
@@ -32,6 +33,8 @@ def tex_to_svg_file(expression, environment=None, tex_template=None):
def generate_tex_file(expression, environment, tex_template):
+ """Takes a tex expression (and an optional tex environment),
+ and returns a fully formed tex file ready for compilation."""
if environment is not None:
output = tex_template.get_texcode_for_expression_in_env(expression, environment)
else:
@@ -46,6 +49,7 @@ def generate_tex_file(expression, environment, tex_template):
def tex_compilation_command(tex_compiler, output_format, tex_file, tex_dir):
+ """Prepares the tex compilation command with all necessary cli flags"""
if tex_compiler in {"latex", "pdflatex", "luatex", "lualatex"}:
commands = [
tex_compiler,
@@ -80,6 +84,7 @@ def tex_compilation_command(tex_compiler, output_format, tex_file, tex_dir):
def tex_to_dvi(tex_file, tex_compiler, output_format):
+ """Compiles a tex_file into a .dvi or a .xdv or a .pdf"""
result = tex_file.replace(".tex", output_format)
result = Path(result).as_posix()
tex_file = Path(tex_file).as_posix()
@@ -100,9 +105,7 @@ def tex_to_dvi(tex_file, tex_compiler, output_format):
def dvi_to_svg(dvi_file, extension, regen_if_exists=False, page=1):
- """
- Converts a dvi, xdv, or pdf file into an svg using dvisvgm.
- """
+ """Converts a .dvi, .xdv, or .pdf file into an svg using dvisvgm."""
result = dvi_file.replace(extension, ".svg")
result = Path(result).as_posix()
dvi_file = Path(dvi_file).as_posix()