Skip to content

Commit ccfea0f

Browse files
Made improvements to the :doc:configuration tutorial (#2414)
* Attempt to use CI to update translations * try again * runs on ubuntu latest * Try to fix * again * try to use PR branch * that didn't work * will this work? * Revert "will this work?" This reverts commit 1e6543a. * Try a different action * fix attempt * another attempt * Revert "another attempt" This reverts commit 8965000. * try again * automatically generate list of all flags * remove unrelated change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * specify dep * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update tutorial Move CLI stuff to the top since it's the most important, slight rewrite, some copyediting * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * slight rephrasing * make underline long enough * Revert "Merge branch 'main' into command-output" This reverts commit e6a9d45, reversing changes made to 3f0137a. * Revert "Revert "Merge branch 'main' into command-output"" This reverts commit c823c6e. Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b4c5fa5 commit ccfea0f

File tree

5 files changed

+86
-88
lines changed

5 files changed

+86
-88
lines changed

docs/rtd-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
jupyterlab
2+
sphinxcontrib-programoutput

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"manim.utils.docbuild.manim_directive",
4646
"sphinx.ext.graphviz",
4747
"sphinx.ext.inheritance_diagram",
48+
"sphinxcontrib.programoutput",
4849
]
4950

5051
# Automatically generate stub pages when using the .. autosummary directive

docs/source/tutorials/configuration.rst

Lines changed: 66 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,68 @@ can be configured programmatically via `the ManimConfig class`_, at the time
88
of command invocation via `command-line arguments`_, or at the time the library
99
is first imported via `the config files`_.
1010

11+
The most common, simplest and recommended way to set the configure Manim is
12+
via the command-line interface (CLI), which is described directly below.
13+
14+
Command-line arguments
15+
**********************
16+
17+
By far the most commonly used command in the CLI is the ``render`` command,
18+
which is used to render scene(s) to an output file.
19+
It is used with the following arguments:
20+
21+
.. program-output:: manim render --help
22+
:ellipsis: 9
23+
24+
However, since manim defaults to the :code:`render` command whenever no command
25+
is specified, the following form is far more common and can be used instead:
26+
27+
.. code-block:: bash
28+
29+
manim [OPTIONS] FILE [SCENES]
30+
31+
An example of using the above form is:
32+
33+
.. code-block:: bash
34+
35+
manim -qm file.py SceneOne
36+
37+
This asks manim to search for a Scene class called :code:`SceneOne` inside the
38+
file ``file.py`` and render it with medium quality (specified by the ``-qm`` flag).
39+
40+
Another frequently used flag is ``-p`` ("preview"), which makes manim
41+
open the rendered video after it's done rendering.
42+
43+
.. note:: The ``-p`` flag does not change any properties of the global
44+
``config`` dict. The ``-p`` flag is only a command-line convenience.
45+
46+
Advanced examples
47+
=================
48+
49+
To render a scene in high quality, but only output the last frame of the scene
50+
instead of the whole video, you can execute
51+
52+
.. code-block:: bash
53+
54+
manim -sqh <file.py> SceneName
55+
56+
The following example specifies the output file name (with the :code:`-o`
57+
flag), renders only the first ten animations (:code:`-n` flag) with a white
58+
background (:code:`-c` flag), and saves the animation as a ``.gif`` instead of as a
59+
``.mp4`` file (``--format=gif`` flag). It uses the default quality and does not try to
60+
open the file after it is rendered.
61+
62+
.. code-block:: bash
63+
64+
manim -o myscene --format=gif -n 0,10 -c WHITE <file.py> SceneName
65+
66+
A list of all CLI flags
67+
========================
68+
69+
.. command-output:: manim --help
70+
.. command-output:: manim render --help
71+
.. command-output:: manim cfg --help
72+
.. command-output:: manim plugins --help
1173

1274
The ManimConfig class
1375
*********************
@@ -74,70 +136,18 @@ rendered in our documentation with a reference frame.
74136
self.add(Text(str(pixel_height)).next_to(d2, RIGHT))
75137

76138

77-
Command-line arguments
78-
**********************
79-
80-
Usually, manim is run from the command-line by executing
81-
82-
.. code-block:: bash
83-
84-
manim <file.py> SceneName
85-
86-
This asks manim to search for a Scene class called :code:`SceneName` inside the
87-
file <file.py> and render it. One can also specify the render quality by using
88-
the flags :code:`-ql`, :code:`-qm`, :code:`-qh`, or :code:`-qk`, for low, medium,
89-
high, and 4k quality, respectively.
90-
91-
.. code-block:: bash
92-
93-
manim -ql <file.py> SceneName
94-
95-
These flags set the values of the config options ``config.pixel_width``,
96-
``config.pixel_height``, ``config.frame_rate``, and ``config.quality``.
97-
98-
Another frequent flag is ``-p`` ("preview"), which makes manim show the rendered video
99-
right after it's done rendering.
100-
101-
.. note:: The ``-p`` flag does not change any properties of the global
102-
``config`` dict. The ``-p`` flag is only a command-line convenience.
103-
104-
Examples
105-
========
106-
107-
To render a scene in high quality, but only output the last frame of the scene
108-
instead of the whole video, you can execute
109-
110-
.. code-block:: bash
111-
112-
manim -sqh <file.py> SceneName
113-
114-
The following example specifies the output file name (with the :code:`-o`
115-
flag), renders only the first ten animations (:code:`-n` flag) with a white
116-
background (:code:`-c` flag), and saves the animation as a .gif instead of as a
117-
.mp4 file (:code:`-i` flag). It uses the default quality and does not try to
118-
open the file after it is rendered.
119-
120-
.. code-block:: bash
121-
122-
manim -o myscene -i -n 0,10 -c WHITE <file.py> SceneName
123-
124-
.. tip:: There are many more command-line flags that manim accepts. All the
125-
possible flags are shown by executing ``manim render --help``. A complete list
126-
of CLI flags is at the end of this document.
127-
128-
129139
The config files
130140
****************
131141

132142
As the last example shows, executing manim from the command-line may involve
133143
using many flags at the same time. This may become a nuisance if you must
134144
execute the same script many times in a short time period, for example when
135-
making small incremental tweaks to your scene script. For this purpose, manim
145+
making small incremental tweaks to your scene script. For this reason, manim
136146
can also be configured using a configuration file. A configuration file is a
137147
file ending with the suffix ``.cfg``.
138148

139-
To use a configuration file when rendering your scene, you must create a file
140-
with name ``manim.cfg`` in the same directory as your scene code.
149+
To use a local configuration file when rendering your scene, you must create a
150+
file with name ``manim.cfg`` in the same directory as your scene code.
141151

142152
.. warning:: The config file **must** be named ``manim.cfg``. Currently, manim
143153
does not support config files with any other name.
@@ -154,7 +164,7 @@ and serve the same purpose. Take for example the following config file.
154164
save_as_gif = True
155165
background_color = WHITE
156166
157-
Config files are read with the standard python library ``configparser``. In
167+
Config files are parsed with the standard python library ``configparser``. In
158168
particular, they will ignore any line that starts with a pound symbol ``#``.
159169

160170
Now, executing the following command
@@ -354,34 +364,3 @@ A list of all config options
354364
'verbosity', 'video_dir', 'webgl_renderer_path', 'window_position',
355365
'window_monitor', 'window_size', 'write_all', 'write_to_movie', 'enable_wireframe',
356366
'force_window']
357-
358-
359-
A list of all CLI flags
360-
***********************
361-
362-
.. code::
363-
364-
manim --help
365-
366-
Usage: manim [OPTIONS] COMMAND [ARGS]...
367-
368-
Animation engine for explanatory math videos
369-
370-
Options:
371-
--version Show the version and exit.
372-
--help Show this message and exit.
373-
374-
Commands:
375-
render* Render SCENE(S) from the input FILE.
376-
cfg Manages Manim configuration files.
377-
plugins Manages Manim plugins.
378-
379-
Made with <3 by Manim Community developers.
380-
381-
Each of the subcommands has its own help page which can be
382-
383-
.. code::
384-
385-
manim render --help
386-
manim cfg --help
387-
manim plugins --help

poetry.lock

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ flake8-rst-docstrings = "^0.2.3"
9393
flake8-pytest-style = "^1.5.0"
9494
flake8-simplify = "^0.14.1"
9595
flake8-comprehensions = "^3.7.0"
96+
sphinxcontrib-programoutput = "^0.17"
9697
data-science-types = "^0.2.23"
9798

9899

0 commit comments

Comments
 (0)