Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Corrected docstrings and formatting

Philipp Imhofdad3d5baf1ad
diff --git a/manim/utils/tex_file_writing.py b/manim/utils/tex_file_writing.py
index 892a0b37b..a19e5740b 100644
--- a/manim/utils/tex_file_writing.py
+++ b/manim/utils/tex_file_writing.py
@@ -28,15 +28,14 @@ def tex_to_svg_file(expression, environment=None, tex_template=None):
----------
expression : :class:`str`
String containing the TeX expression to be rendered, e.g. ``\\sqrt{2}`` or ``foo``
- environment : :class:`str`
+ environment : Optional[:class:`str`], optional
The string containing the environment in which the expression should be typeset, e.g. ``align*``
- Optional. If not set, the expression will be rendered in text mode.
- tex_template : :class:`TexTemplate`
- Template class used to typesetting.
- Optional. If not set, the default template will be used.
+ tex_template : Optional[:class:`TexTemplate`], optional
+ Template class used to typesetting. If not set, use default template set via `config["tex_template"]`
Returns
-------
- Path to generated SVG file.
+ :class:`str`
+ Path to generated SVG file.
"""
if tex_template is None:
tex_template = config["tex_template"]
@@ -55,16 +54,17 @@ def generate_tex_file(expression, environment=None, tex_template=None):
----------
expression : :class:`str`
String containing the TeX expression to be rendered, e.g. ``\\sqrt{2}`` or ``foo``
- environment : :class:`str`
+ environment : Optional[:class:`str`], optional
The string containing the environment in which the expression should be typeset, e.g. ``align*``
- Optional. If not set, the expression will be rendered in text mode.
- tex_template : :class:`TexTemplate`
- Template class used to typesetting.
- Optional. If not set, the default template will be used.
+ tex_template : Optional[:class:`TexTemplate`], optional
+ Template class used to typesetting. If not set, use default template set via `config["tex_template"]`
Returns
-------
- Generated TeX file ready for compilation
+ :class:`string`
+ Path to generated TeX file
"""
+ if tex_template is None:
+ tex_template = config["tex_template"]
if environment is not None:
output = tex_template.get_texcode_for_expression_in_env(expression, environment)
else:
@@ -87,14 +87,14 @@ def tex_compilation_command(tex_compiler, output_format, tex_file, tex_dir):
String containing the compiler to be used, e.g. ``pdflatex`` or ``lualatex``
output_format : :class:`str`
String containing the output format generated by the compiler, e.g. ``.dvi`` or ``.pdf``
- Optional. If not set, the expression will be rendered in text mode.
tex_file : :class:`str`
File name of TeX file to be typeset.
tex_dir : :class:`str`
Path to the directory where compiler output will be stored.
Returns
-------
- Path to generated output file.
+ :class:`str`
+ Compilation command according to given parameters
"""
if tex_compiler in {"latex", "pdflatex", "luatex", "lualatex"}:
commands = [
@@ -140,10 +140,10 @@ def compile_tex(tex_file, tex_compiler, output_format):
String containing the compiler to be used, e.g. ``pdflatex`` or ``lualatex``
output_format : :class:`str`
String containing the output format generated by the compiler, e.g. ``.dvi`` or ``.pdf``
- Optional. If not set, the expression will be rendered in text mode.
Returns
-------
- Path to generated output file.
+ :class:`str`
+ Path to generated output file in desired format (DVI, XDV or PDF).
"""
result = tex_file.replace(".tex", output_format)
result = Path(result).as_posix()
@@ -173,13 +173,14 @@ def convert_to_svg(dvi_file, extension, regen_if_exists=False, page=1):
File name of the input file to be converted.
extension : :class:`str`
String containing the file extension and thus indicating the file type, e.g. ``.dvi`` or ``.pdf``
- regen_if_exists : `bool`
- Setting if SVG has to be regenerated even if it already exists. Optional, defaulting to False.
- page : `int`
- Page to be converted if input file is multi-page. Optional, defaulting to 1.
+ regen_if_exists : Optional[:class:`bool`], optional
+ Setting if SVG has to be regenerated even if it already exists.
+ page : Optional[:class:`int`], optional
+ Page to be converted if input file is multi-page.
Returns
-------
- Path to generated SVG file."""
+ :class:`str`
+ Path to generated SVG file."""
result = dvi_file.replace(extension, ".svg")
result = Path(result).as_posix()
dvi_file = Path(dvi_file).as_posix()