Skip to content

Continuous Release 1.0.1 #134

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

Merged
merged 6 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@
"ensurepip",
"github",
"glxinfo",
"importlib",
"ipython",
"Keybord",
"kisak",
"laggy",
"libglut",
"libpango",
"logfile",
"Logfile",
"manim",
"Manim",
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

Manim Notebook is a VSCode extension tailored to your needs when writing Python code to animate mathematical concepts with 3Blue1Brown's [Manim library](https://github.com/3b1b/manim). It's *NOT* a Jupyter Notebook; instead it enriches your existing Python files with interactive Manim cells that let you live-preview parts of the code and instantly see the animations.

Originally, the motivation for this extension was Grant Sanderson's video [How I animate 3Blue1Brown](https://youtu.be/rbu7Zu5X1zI?feature=shared) where he shows his Manim workflow in Sublime Text. This extension brings a similar workflow to VSCode but even goes further and provides a rich VSCode integration.
Originally, the motivation for this extension was Grant Sanderson's video [How I animate 3Blue1Brown](https://youtu.be/rbu7Zu5X1zI) where he shows his Manim workflow in Sublime Text. This extension brings a similar workflow to VSCode but even goes further and provides a rich VSCode integration.

## 💻 Usage

Expand Down Expand Up @@ -64,3 +64,5 @@ In the long run, we aim to even provide a <strong>Debugger for Manim code</stron
<a href="https://marketplace.visualstudio.com/items?itemName=Manim-Notebook.manim-notebook">
<img src="https://github.com/user-attachments/assets/b13a01f6-7d24-4bfb-9d3f-fee7b8a456a3" alt="Manim Notebook Logo with a fancy color-gradient background"/>
</a>

If you enjoy Manim, you might also like [Motion Canvas](https://motioncanvas.io/) by aarthificial. It even has its own editor integrated and uses HTML5 Canvas to render the animations. The learning curve is less steep and it's also very powerful.
736 changes: 366 additions & 370 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "manim-notebook",
"displayName": "Manim Notebook",
"description": "ManimGL with interactive previewing to easily visualize and share the beauty of mathematics and related fields.",
"version": "1.0.0",
"version": "1.0.1",
"publisher": "Manim-Notebook",
"author": {
"name": "Manim Notebook Contributors"
Expand Down
10 changes: 6 additions & 4 deletions src/export.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as vscode from "vscode";
import { window, TextDocument, CancellationToken, CodeLens } from "vscode";
import { CancellationToken, CodeLens, TextDocument, window } from "vscode";
import { Logger, Window } from "./logger";
import { ManimClass } from "./pythonParsing";
import {
MultiStepInput, toQuickPickItems, shouldResumeNoOp,
MultiStepInput,
shouldResumeNoOp,
toQuickPickItems,
} from "./utils/multiStepQuickPickUtil";
import { ManimClass } from "./pythonParsing";
import { Logger, Window } from "./logger";
import { waitNewTerminalDelay } from "./utils/terminal";

class VideoQuality {
Expand Down
17 changes: 8 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { EventEmitter } from "events";
import * as vscode from "vscode";
import { window } from "vscode";
import { ManimShell, NoActiveShellError } from "./manimShell";
import { exportScene, ExportSceneCodeLens } from "./export";
import { Logger, LogRecorder, Window } from "./logger";
import { ManimCell } from "./manimCell";
import { previewManimCell, reloadAndPreviewManimCell, previewCode } from "./previewCode";
import { startScene, exitScene } from "./startStopScene";
import { exportScene } from "./export";
import { Logger, Window, LogRecorder } from "./logger";
import { registerWalkthroughCommands } from "./walkthrough";
import { ExportSceneCodeLens } from "./export";
import { ManimShell, NoActiveShellError } from "./manimShell";
import { determineManimVersion } from "./manimVersion";
import { setupTestEnvironment } from "./utils/testing";
import { EventEmitter } from "events";
import { applyWindowsPastePatch } from "./patches/applyPatches";
import { previewCode, previewManimCell, reloadAndPreviewManimCell } from "./previewCode";
import { exitScene, startScene } from "./startStopScene";
import { setupTestEnvironment } from "./utils/testing";
import { getBinaryPathInPythonEnv } from "./utils/venv";
import { registerWalkthroughCommands } from "./walkthrough";

export let manimNotebookContext: vscode.ExtensionContext;

Expand Down
9 changes: 4 additions & 5 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as vscode from "vscode";
import { window } from "vscode";
import { LogOutputChannel } from "vscode";
import { waitUntilFileExists, revealFileInOS } from "./utils/fileUtil";
import * as path from "path";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as vscode from "vscode";
import { LogOutputChannel, window } from "vscode";
import { revealFileInOS, waitUntilFileExists } from "./utils/fileUtil";

const LOGGER_NAME = "Manim Notebook";

Expand Down
8 changes: 6 additions & 2 deletions src/manimCell.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import * as vscode from "vscode";
import { window, TextDocument, CancellationToken,
CodeLens, FoldingContext, FoldingRange } from "vscode";
import {
CancellationToken,
CodeLens, FoldingContext, FoldingRange,
TextDocument,
window,
} from "vscode";
import { ManimCellRanges } from "./pythonParsing";

export class ManimCell implements vscode.CodeLensProvider, vscode.FoldingRangeProvider {
Expand Down
4 changes: 2 additions & 2 deletions src/manimVersion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { exec } from "child_process";

import { Window, Logger } from "./logger";
import * as vscode from "vscode";
import { Logger, Window } from "./logger";

/**
* Manim version that the user has installed without the 'v' prefix,
Expand Down Expand Up @@ -159,7 +159,7 @@ export async function determineManimVersion(pythonBinary: string | undefined) {
}, 3000);
});

const versionCommand = `${pythonBinary} -c \"from importlib.metadata import version; `
const versionCommand = `"${pythonBinary}" -c \"from importlib.metadata import version; `
+ " print(version('manimgl'))\"";

try {
Expand Down
2 changes: 1 addition & 1 deletion src/patches/applyPatches.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { exec } from "child_process";
import * as fs from "fs";
import path from "path";
import { exec } from "child_process";

import { Logger, Window } from "../logger";

Expand Down
6 changes: 3 additions & 3 deletions src/previewCode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { EventEmitter } from "events";
import * as vscode from "vscode";
import { window } from "vscode";
import { ManimShell } from "./manimShell";
import { EventEmitter } from "events";
import { ManimCellRanges } from "./pythonParsing";
import { Logger, Window } from "./logger";
import { ManimShell } from "./manimShell";
import { hasUserMinimalManimVersionAndWarn } from "./manimVersion";
import { ManimCellRanges } from "./pythonParsing";

// \x0C: is Ctrl + L, which clears the terminal screen
const PREVIEW_COMMAND = "\x0Ccheckpoint_paste()";
Expand Down
4 changes: 2 additions & 2 deletions src/pythonParsing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as crypto from "crypto";
import { TextDocument, Range } from "vscode";
import { Range, TextDocument } from "vscode";

/**
* Cache is a simple key-value store that keeps a maximum number of entries.
Expand Down Expand Up @@ -206,7 +206,7 @@ export class ManimClass {
/**
* Regular expression to match the construct() method definition.
*/
private static CONSTRUCT_METHOD_REGEX = /^\s*def\s+construct\s*\(self\)\s*:/;
private static CONSTRUCT_METHOD_REGEX = /^\s*def\s+construct\s*\(self\)\s*(->\s*None)?\s*:/;

/**
* The 0-based line number where the Manim Class is defined.
Expand Down
4 changes: 2 additions & 2 deletions src/startStopScene.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as vscode from "vscode";
import { ManimShell, NoActiveShellError } from "./manimShell";
import { window, workspace } from "vscode";
import { Logger, Window } from "./logger";
import { ManimClass } from "./pythonParsing";
import { ManimShell, NoActiveShellError } from "./manimShell";
import { hasUserMinimalManimVersion } from "./manimVersion";
import { ManimClass } from "./pythonParsing";

/**
* Runs the `manimgl` command in the terminal, with the current cursor's
Expand Down
2 changes: 1 addition & 1 deletion src/utils/fileUtil.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";
import * as fs from "fs";
import * as path from "path";
import * as vscode from "vscode";

/**
* Waits until a file exists on the disk.
Expand Down
6 changes: 5 additions & 1 deletion src/utils/multiStepQuickPickUtil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {
QuickPickItem, window, Disposable, QuickInputButton, QuickInput, QuickInputButtons,
Disposable,
QuickInput,
QuickInputButton,
QuickInputButtons,
QuickPickItem, window,
} from "vscode";

export function toQuickPickItem(names: string): QuickPickItem {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/testing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { window, Terminal, TerminalShellExecution } from "vscode";
import * as path from "path";
import { Terminal, TerminalShellExecution, window } from "vscode";
import { stripAnsiCodes } from "./terminal";

export function setupTestEnvironment() {
Expand Down
6 changes: 3 additions & 3 deletions src/walkthrough.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as vscode from "vscode";
import { ExtensionContext, window, workspace, commands } from "vscode";
import { Logger } from "./logger";
import fs from "fs";
import path from "path";
import * as vscode from "vscode";
import { commands, ExtensionContext, window, workspace } from "vscode";
import { Logger } from "./logger";

export function registerWalkthroughCommands(context: ExtensionContext) {
const openSampleFileCommand = commands.registerCommand(
Expand Down
8 changes: 3 additions & 5 deletions tests/activation.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { window, commands } from "vscode";
import { commands, window } from "vscode";

import { describe, it, before, afterEach } from "mocha";
import { afterEach, before, describe, it } from "mocha";
import * as sinon from "sinon";
let expect: Chai.ExpectStatic;

import { manimNotebookContext } from "../src/extension";
import { Logger } from "../src/logger";
import { applyWindowsPastePatch } from "../src/patches/applyPatches";
import { manimNotebookContext } from "../src/extension";

// eslint-disable-next-line no-unused-vars
import * as manimNotebook from "../src/extension";
import { onTerminalOutput } from "../src/utils/terminal";

const MANIM_VERSION_STRING_REGEX = /v\d+\.\d+\.\d+/;
Expand Down
6 changes: 3 additions & 3 deletions tests/cellRanges.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { workspace, Range } from "vscode";
import { describe, it } from "mocha";
import { uriInWorkspace } from "./utils/testRunner";
import { Range, workspace } from "vscode";
import { ManimCellRanges } from "../src/pythonParsing";
import { uriInWorkspace } from "./utils/testRunner";

describe("Manim Cell Ranges", function () {
// in the expected ranges we only care about the start and end lines
// line numbers are 0-based here
const tests = [
{
filename: "detection_basic.py",
expectedRanges: [[5, 7], [9, 10]],
expectedRanges: [[5, 7], [9, 10], [16, 18]],
},
{
filename: "detection_class_definition.py",
Expand Down
8 changes: 8 additions & 0 deletions tests/fixtures/detection_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ def construct(self):
print("And even more code")


class BasicNotebookWithType(Scene):

def construct(self) -> None:
## Cell inside construct(self) marked with "None" type
print("With some code None")
print("With some more code None")


class NoManimScene(Scene):
def constructtttt(self):
## Should not be detected as Manim Cell
Expand Down
6 changes: 3 additions & 3 deletions tests/preview.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { window, commands } from "vscode";
import { describe, it, before } from "mocha";
import { before, describe, it } from "mocha";
import { commands, window } from "vscode";
import { goToLine } from "./utils/editor";
import { onAnyTerminalOutput } from "./utils/terminal";
import { uriInWorkspace } from "./utils/testRunner";
import { goToLine } from "./utils/editor";
let expect: Chai.ExpectStatic;

before(async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TextEditor, Selection } from "vscode";
import { Selection, TextEditor } from "vscode";

/**
* Moves the cursor to the specified line number.
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/installManim.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ManimInstaller } from "./manimInstaller";
import * as path from "path";
import { ManimInstaller } from "./manimInstaller";

async function setupManimInstallation() {
const baseFolder = process.cwd();
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/manimCaller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { window } from "vscode";
import * as path from "path";
import { window } from "vscode";

export class ManimCaller {
public venvPath: string = "";
Expand Down
6 changes: 3 additions & 3 deletions tests/utils/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// import as soon as possible
import { activatedEmitter } from "../../src/extension";

import * as path from "path";
import Mocha from "mocha";
import * as assert from "assert";
import { globSync } from "glob";
import Mocha from "mocha";
import * as path from "path";
import "source-map-support/register";
import "./prototype";

import { window, workspace, Uri, extensions } from "vscode";
import { Uri, extensions, window, workspace } from "vscode";

const WORKSPACE_ROOT: string = workspace.workspaceFolders![0].uri.fsPath;

Expand Down