Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Manim type aliases in Sphinx docs + Added new TypeAliases #3484

Merged
merged 38 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
93e4cbc
Updated manim.typing and included TypeAliases in docs.source.conf
chopan050 Dec 1, 2023
74448bb
Added Vector2 and reorganized manim_type_aliases
chopan050 Dec 2, 2023
10b8d1a
Merge branch 'main' into typing_update
chopan050 Dec 2, 2023
a32b7a7
Fixed __all__ exports for __all__ of manim
MrDiver Dec 10, 2023
762df44
Merge branch 'main' into typing_update
MrDiver Dec 10, 2023
9f9e98f
Update manim/cli/render/global_options.py
MrDiver Dec 10, 2023
5d1b375
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 10, 2023
5f582bc
Draft of new typing docs and new autotyping directive
chopan050 Dec 20, 2023
ed00abc
Merge branch 'main' into typing_update
chopan050 Dec 20, 2023
5dc5e0c
Changed vertical bars to Unions
chopan050 Dec 20, 2023
232df18
Updated poetry.lock
chopan050 Dec 20, 2023
dacc639
Created custom file parser for manim.typing
chopan050 Dec 22, 2023
cd85655
??? What is going on
JasonGrace2282 Dec 23, 2023
1710faf
Got reST parser going
JasonGrace2282 Dec 23, 2023
3764d74
Updated autotyping and parsing
JasonGrace2282 Dec 23, 2023
9d65c9f
Update parsing
JasonGrace2282 Dec 24, 2023
1425388
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 24, 2023
1d50503
Added code_block toggle
JasonGrace2282 Dec 24, 2023
8d8e07a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 24, 2023
a31c697
Added typings to directives
chopan050 Dec 24, 2023
b1dee77
Renamed Tuple to tuple in manim.typings
chopan050 Dec 24, 2023
4e78940
Added missing docs for type aliases
chopan050 Dec 26, 2023
9fca6ed
Fixed exponent typo in ManimInt
chopan050 Dec 26, 2023
e56b793
Hyperlinks to types work - removed Module Attributes section
chopan050 Dec 27, 2023
04fc997
Merge branch 'main' into typing_update
chopan050 Dec 27, 2023
67f902e
Removed Unused Import
JasonGrace2282 Dec 27, 2023
7580490
Added freeglut-devel to workflows for Linux
JasonGrace2282 Dec 27, 2023
8f2391a
Fix package name
JasonGrace2282 Dec 27, 2023
86f9760
Add support for Type Aliases section in every module - Renaming of Ve…
chopan050 Dec 27, 2023
f6b80b6
Merge branch 'typing_update' of https://github.com/chopan050/manim in…
chopan050 Dec 27, 2023
3ccfee1
Add/fix docs for directive, parser and others
chopan050 Dec 27, 2023
1a8016b
Fixed alias typo in module_parsing
chopan050 Dec 27, 2023
f2dd4bf
Fix decode/import bugs, fix minor details in docs
chopan050 Dec 27, 2023
be40a7d
Added missing docs for utils.docbuild and utils.testing
chopan050 Dec 28, 2023
1980e7b
Sort alphabetically entries in utilities_misc.rst
chopan050 Dec 28, 2023
50717f6
Merge branch 'main' into typing_update
chopan050 Dec 28, 2023
600e616
Address review comments, add notes about Vector and hyperlinks inside…
chopan050 Dec 29, 2023
2599360
Merge branch 'typing_update' of https://github.com/chopan050/manim in…
chopan050 Dec 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pathlib import Path

import manim
from manim.typing import manim_type_aliases

# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -44,6 +45,7 @@
"sphinxext.opengraph",
"manim.utils.docbuild.manim_directive",
"manim.utils.docbuild.autocolor_directive",
"manim.utils.docbuild.autotyping_directive",
"sphinx.ext.graphviz",
"sphinx.ext.inheritance_diagram",
"sphinxcontrib.programoutput",
Expand All @@ -55,6 +57,11 @@

# generate documentation from type hints
autodoc_typehints = "description"
autodoc_type_aliases = {
alias: f"~manim.typing.{alias}"
for category in manim_type_aliases.values()
for alias in category
}
autoclass_content = "both"

# controls whether functions documented by the autofunction directive
Expand Down
1 change: 1 addition & 0 deletions docs/source/reference_index/utilities_misc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Module Index
.. autosummary::
:toctree: ../reference

typing
constants
~utils.bezier
~utils.color
Expand Down
1 change: 1 addition & 0 deletions manim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .utils.commands import *

# isort: on
import numpy as np

from .animation.animation import *
from .animation.changing import *
Expand Down
2 changes: 2 additions & 0 deletions manim/_config/cli_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from cloup import Context, HelpFormatter, HelpTheme, Style

__all__ = ["parse_cli_ctx"]


def parse_cli_ctx(parser: configparser.SectionProxy) -> Context:
formatter_settings: dict[str, str | int] = {
Expand Down
2 changes: 2 additions & 0 deletions manim/_config/logger_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
if TYPE_CHECKING:
from pathlib import Path

__all__ = ["make_logger", "parse_theme", "set_file_logger", "JSONFormatter"]

HIGHLIGHTED_KEYWORDS = [ # these keywords are highlighted specially
"Played",
"animations",
Expand Down
2 changes: 2 additions & 0 deletions manim/_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
from ..utils.color import ManimColor
from ..utils.tex import TexTemplate, TexTemplateFromFile

__all__ = ["config_file_paths", "make_config_parser", "ManimConfig", "ManimFrame"]


def config_file_paths() -> list[Path]:
"""The paths where ``.cfg`` files will be searched for.
Expand Down
2 changes: 2 additions & 0 deletions manim/animation/speedmodifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from ..mobject.mobject import Mobject, Updater, _AnimationBuilder
from ..scene.scene import Scene

__all__ = ["ChangeSpeed"]


class ChangeSpeed(Animation):
"""Modifies the speed of passed animation.
Expand Down
11 changes: 11 additions & 0 deletions manim/cli/cfg/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
"""
RICH_NON_STYLE_ENTRIES: str = ["log.width", "log.height", "log.timestamps"]

__all__ = [
"value_from_string",
"value_from_string",
"is_valid_style",
"replace_keys",
"cfg",
"write",
"show",
"export",
]


def value_from_string(value: str) -> str | int | bool:
"""Extracts the literal of proper datatype from a string.
Expand Down
2 changes: 2 additions & 0 deletions manim/cli/checkhealth/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from ..._config import config

__all__ = ["HEALTH_CHECKS"]

HEALTH_CHECKS = []


Expand Down
2 changes: 2 additions & 0 deletions manim/cli/checkhealth/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from .checks import HEALTH_CHECKS

__all__ = ["checkhealth"]


@cloup.command(
context_settings=None,
Expand Down
2 changes: 2 additions & 0 deletions manim/cli/init/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"resolution": (854, 480),
}

__all__ = ["select_resolution", "update_cfg", "project", "scene"]


def select_resolution():
"""Prompts input of type click.Choice from user. Presents options from QUALITIES constant.
Expand Down
2 changes: 2 additions & 0 deletions manim/cli/plugins/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from ...constants import CONTEXT_SETTINGS, EPILOG
from ...plugins.plugins_flags import list_plugins

__all__ = ["plugins"]


@cloup.command(
context_settings=CONTEXT_SETTINGS,
Expand Down
2 changes: 2 additions & 0 deletions manim/cli/render/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from .output_options import output_options
from .render_options import render_options

__all__ = ["render"]


@cloup.command(
context_settings=None,
Expand Down
2 changes: 2 additions & 0 deletions manim/cli/render/ease_of_access_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from cloup import Choice, option, option_group

__all__ = ["ease_of_access_options"]

ease_of_access_options = option_group(
"Ease of access options",
option(
Expand Down
2 changes: 2 additions & 0 deletions manim/cli/render/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from ... import logger

__all__ = ["global_options"]


def validate_gui_location(ctx, param, value):
if value:
Expand Down
2 changes: 2 additions & 0 deletions manim/cli/render/output_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from cloup import IntRange, Path, option, option_group

__all__ = ["output_options"]

output_options = option_group(
"Output options",
option(
Expand Down
2 changes: 2 additions & 0 deletions manim/cli/render/render_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from ... import logger

__all__ = ["render_options"]


def validate_scene_range(ctx, param, value):
try:
Expand Down
2 changes: 2 additions & 0 deletions manim/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from .. import __version__, config
from ..utils.module_ops import scene_classes_from_file

__all__ = ["configure_pygui"]

if dearpygui_imported:
dpg.create_context()
window = dpg.generate_uuid()
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/opengl/opengl_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from ...constants import RendererType

__all__ = ["ConvertToOpenGL"]


class ConvertToOpenGL(ABCMeta):
"""Metaclass for swapping (V)Mobject with its OpenGL counterpart at runtime
Expand Down
26 changes: 26 additions & 0 deletions manim/mobject/opengl/opengl_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,32 @@
DEFAULT_ARROW_TIP_LENGTH = 0.35
DEFAULT_ARROW_TIP_WIDTH = 0.35

__all__ = [
"OpenGLTipableVMobject",
"OpenGLArc",
"OpenGLArcBetweenPoints",
"OpenGLCurvedArrow",
"OpenGLCurvedDoubleArrow",
"OpenGLCircle",
"OpenGLDot",
"OpenGLEllipse",
"OpenGLAnnularSector",
"OpenGLSector",
"OpenGLAnnulus",
"OpenGLLine",
"OpenGLDashedLine",
"OpenGLTangentLine",
"OpenGLElbow",
"OpenGLArrow",
"OpenGLVector",
"OpenGLDoubleArrow",
"OpenGLCubicBezier",
"OpenGLPolygon",
"OpenGLRegularPolygon",
"OpenGLTriangle",
"OpenGLArrowTip",
]


class OpenGLTipableVMobject(OpenGLVMobject):
"""
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/opengl/opengl_image_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from manim.mobject.opengl.opengl_surface import OpenGLSurface, OpenGLTexturedSurface
from manim.utils.images import get_full_raster_image_path

__all__ = ["OpenGLImageMobject"]


class OpenGLImageMobject(OpenGLTexturedSurface):
def __init__(
Expand Down
3 changes: 3 additions & 0 deletions manim/mobject/opengl/opengl_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def wrapper(self):
return wrapper


__all__ = ["OpenGLMobject", "OpenGLGroup", "OpenGLPoint", "_AnimationBuilder"]


class OpenGLMobject:
"""Mathematical Object: base class for objects that can be displayed on screen.
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/opengl/opengl_point_cloud_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from manim.utils.config_ops import _Uniforms
from manim.utils.iterables import resize_with_interpolation

__all__ = ["OpenGLPMobject", "OpenGLPGroup", "OpenGLPMPoint"]


class OpenGLPMobject(OpenGLMobject):
shader_folder = "true_dot"
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/opengl/opengl_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from manim.utils.iterables import listify
from manim.utils.space_ops import normalize_along_axis

__all__ = ["OpenGLSurface", "OpenGLTexturedSurface"]


class OpenGLSurface(OpenGLMobject):
r"""Creates a Surface.
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/opengl/opengl_three_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from manim.mobject.opengl.opengl_surface import OpenGLSurface
from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVGroup, OpenGLVMobject

__all__ = ["OpenGLSurfaceMesh"]


class OpenGLSurfaceMesh(OpenGLVGroup):
def __init__(
Expand Down
9 changes: 9 additions & 0 deletions manim/mobject/opengl/opengl_vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
z_to_vector,
)

__all__ = [
"triggers_refreshed_triangulation",
"OpenGLVMobject",
"OpenGLVGroup",
"OpenGLVectorizedPoint",
"OpenGLCurvesAsSubmobjects",
"OpenGLDashedVMobject",
]


def triggers_refreshed_triangulation(func):
@wraps(func)
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/svg/brace.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from ...utils.color import BLACK
from ..svg.svg_mobject import VMobjectFromSVGPath

__all__ = ["Brace", "BraceBetweenPoints", "BraceLabel", "ArcBrace"]


class Brace(VMobjectFromSVGPath):
"""Takes a mobject and draws a brace adjacent to it.
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/text/code_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from manim.mobject.types.vectorized_mobject import VGroup
from manim.utils.color import WHITE

__all__ = ["Code"]


class Code(VGroup):
"""A highlighted source code listing.
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/text/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

string_to_mob_map = {}

__all__ = ["DecimalNumber", "Integer", "Variable"]


class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
"""An mobject representing a decimal number.
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/text/text_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def construct(self):
DEFAULT_LINE_SPACING_SCALE = 0.3
TEXT2SVG_ADJUSTMENT_FACTOR = 4.8

__all__ = ["Text", "Paragraph", "MarkupText", "register_font"]


def remove_invisible_chars(mobject: SVGMobject) -> SVGMobject:
"""Function to remove unwanted invisible characters from some mobjects.
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/types/image_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from ...utils.color import WHITE, ManimColor, color_to_int_rgb
from ...utils.images import change_to_rgba_array, get_full_raster_image_path

__all__ = ["ImageMobject", "ImageMobjectFromCamera"]


class AbstractImageMobject(Mobject):
"""
Expand Down
2 changes: 2 additions & 0 deletions manim/mobject/types/point_cloud_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
)
from ...utils.iterables import stretch_array_to_length

__all__ = ["PMobject", "Mobject1D", "Mobject2D", "PGroup", "PointCloudDot", "Point"]


class PMobject(Mobject, metaclass=ConvertToOpenGL):
"""A disc made of a cloud of Dots
Expand Down
10 changes: 10 additions & 0 deletions manim/mobject/types/vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@
# - Think about length of self.points. Always 0 or 1 mod 4?
# That's kind of weird.

__all__ = [
"VMobject",
"VGroup",
"VDict",
"VectorizedPoint",
"CurvesAsSubmobjects",
"VectorizedPoint",
"DashedVMobject",
]


class VMobject(Mobject):
"""A vectorized mobject.
Expand Down
2 changes: 2 additions & 0 deletions manim/renderer/cairo_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from manim.animation.animation import Animation
from manim.scene.scene import Scene

__all__ = ["CairoRenderer"]


class CairoRenderer:
"""A renderer using Cairo.
Expand Down
2 changes: 2 additions & 0 deletions manim/renderer/opengl_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
render_opengl_vectorized_mobject_stroke,
)

__all__ = ["OpenGLCamera", "OpenGLRenderer"]


class OpenGLCamera(OpenGLMobject):
euler_angles = _Data()
Expand Down
2 changes: 2 additions & 0 deletions manim/renderer/opengl_renderer_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from .. import __version__, config

__all__ = ["Window"]


class Window(PygletWindow):
fullscreen = False
Expand Down
2 changes: 2 additions & 0 deletions manim/renderer/shader_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# of a dict holding all the relevant information
# to that shader

__all__ = ["ShaderWrapper"]


def get_shader_dir():
return Path(__file__).parent / "shaders"
Expand Down
Loading
Loading