Skip to content

Commit 398fdf8

Browse files
authored
Continuous Release 1.0.1 (#134)
2 parents cfdf2b0 + 23b959e commit 398fdf8

25 files changed

+439
-425
lines changed

.vscode/settings.json

+2
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@
9191
"ensurepip",
9292
"github",
9393
"glxinfo",
94+
"importlib",
9495
"ipython",
9596
"Keybord",
9697
"kisak",
9798
"laggy",
9899
"libglut",
99100
"libpango",
101+
"logfile",
100102
"Logfile",
101103
"manim",
102104
"Manim",

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
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.
3030

31-
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.
31+
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.
3232

3333
## 💻 Usage
3434

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

package-lock.json

+366-370
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "manim-notebook",
33
"displayName": "Manim Notebook",
44
"description": "ManimGL with interactive previewing to easily visualize and share the beauty of mathematics and related fields.",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"publisher": "Manim-Notebook",
77
"author": {
88
"name": "Manim Notebook Contributors"

src/export.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import * as vscode from "vscode";
2-
import { window, TextDocument, CancellationToken, CodeLens } from "vscode";
2+
import { CancellationToken, CodeLens, TextDocument, window } from "vscode";
3+
import { Logger, Window } from "./logger";
4+
import { ManimClass } from "./pythonParsing";
35
import {
4-
MultiStepInput, toQuickPickItems, shouldResumeNoOp,
6+
MultiStepInput,
7+
shouldResumeNoOp,
8+
toQuickPickItems,
59
} from "./utils/multiStepQuickPickUtil";
6-
import { ManimClass } from "./pythonParsing";
7-
import { Logger, Window } from "./logger";
810
import { waitNewTerminalDelay } from "./utils/terminal";
911

1012
class VideoQuality {

src/extension.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1+
import { EventEmitter } from "events";
12
import * as vscode from "vscode";
23
import { window } from "vscode";
3-
import { ManimShell, NoActiveShellError } from "./manimShell";
4+
import { exportScene, ExportSceneCodeLens } from "./export";
5+
import { Logger, LogRecorder, Window } from "./logger";
46
import { ManimCell } from "./manimCell";
5-
import { previewManimCell, reloadAndPreviewManimCell, previewCode } from "./previewCode";
6-
import { startScene, exitScene } from "./startStopScene";
7-
import { exportScene } from "./export";
8-
import { Logger, Window, LogRecorder } from "./logger";
9-
import { registerWalkthroughCommands } from "./walkthrough";
10-
import { ExportSceneCodeLens } from "./export";
7+
import { ManimShell, NoActiveShellError } from "./manimShell";
118
import { determineManimVersion } from "./manimVersion";
12-
import { setupTestEnvironment } from "./utils/testing";
13-
import { EventEmitter } from "events";
149
import { applyWindowsPastePatch } from "./patches/applyPatches";
10+
import { previewCode, previewManimCell, reloadAndPreviewManimCell } from "./previewCode";
11+
import { exitScene, startScene } from "./startStopScene";
12+
import { setupTestEnvironment } from "./utils/testing";
1513
import { getBinaryPathInPythonEnv } from "./utils/venv";
14+
import { registerWalkthroughCommands } from "./walkthrough";
1615

1716
export let manimNotebookContext: vscode.ExtensionContext;
1817

src/logger.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import * as vscode from "vscode";
2-
import { window } from "vscode";
3-
import { LogOutputChannel } from "vscode";
4-
import { waitUntilFileExists, revealFileInOS } from "./utils/fileUtil";
5-
import * as path from "path";
61
import * as fs from "fs";
72
import * as os from "os";
3+
import * as path from "path";
4+
import * as vscode from "vscode";
5+
import { LogOutputChannel, window } from "vscode";
6+
import { revealFileInOS, waitUntilFileExists } from "./utils/fileUtil";
87

98
const LOGGER_NAME = "Manim Notebook";
109

src/manimCell.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import * as vscode from "vscode";
2-
import { window, TextDocument, CancellationToken,
3-
CodeLens, FoldingContext, FoldingRange } from "vscode";
2+
import {
3+
CancellationToken,
4+
CodeLens, FoldingContext, FoldingRange,
5+
TextDocument,
6+
window,
7+
} from "vscode";
48
import { ManimCellRanges } from "./pythonParsing";
59

610
export class ManimCell implements vscode.CodeLensProvider, vscode.FoldingRangeProvider {

src/manimVersion.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { exec } from "child_process";
22

3-
import { Window, Logger } from "./logger";
43
import * as vscode from "vscode";
4+
import { Logger, Window } from "./logger";
55

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

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

165165
try {

src/patches/applyPatches.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { exec } from "child_process";
12
import * as fs from "fs";
23
import path from "path";
3-
import { exec } from "child_process";
44

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

src/previewCode.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { EventEmitter } from "events";
12
import * as vscode from "vscode";
23
import { window } from "vscode";
3-
import { ManimShell } from "./manimShell";
4-
import { EventEmitter } from "events";
5-
import { ManimCellRanges } from "./pythonParsing";
64
import { Logger, Window } from "./logger";
5+
import { ManimShell } from "./manimShell";
76
import { hasUserMinimalManimVersionAndWarn } from "./manimVersion";
7+
import { ManimCellRanges } from "./pythonParsing";
88

99
// \x0C: is Ctrl + L, which clears the terminal screen
1010
const PREVIEW_COMMAND = "\x0Ccheckpoint_paste()";

src/pythonParsing.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as crypto from "crypto";
2-
import { TextDocument, Range } from "vscode";
2+
import { Range, TextDocument } from "vscode";
33

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

211211
/**
212212
* The 0-based line number where the Manim Class is defined.

src/startStopScene.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as vscode from "vscode";
2-
import { ManimShell, NoActiveShellError } from "./manimShell";
32
import { window, workspace } from "vscode";
43
import { Logger, Window } from "./logger";
5-
import { ManimClass } from "./pythonParsing";
4+
import { ManimShell, NoActiveShellError } from "./manimShell";
65
import { hasUserMinimalManimVersion } from "./manimVersion";
6+
import { ManimClass } from "./pythonParsing";
77

88
/**
99
* Runs the `manimgl` command in the terminal, with the current cursor's

src/utils/fileUtil.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as vscode from "vscode";
21
import * as fs from "fs";
32
import * as path from "path";
3+
import * as vscode from "vscode";
44

55
/**
66
* Waits until a file exists on the disk.

src/utils/multiStepQuickPickUtil.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import {
2-
QuickPickItem, window, Disposable, QuickInputButton, QuickInput, QuickInputButtons,
2+
Disposable,
3+
QuickInput,
4+
QuickInputButton,
5+
QuickInputButtons,
6+
QuickPickItem, window,
37
} from "vscode";
48

59
export function toQuickPickItem(names: string): QuickPickItem {

src/utils/testing.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { window, Terminal, TerminalShellExecution } from "vscode";
21
import * as path from "path";
2+
import { Terminal, TerminalShellExecution, window } from "vscode";
33
import { stripAnsiCodes } from "./terminal";
44

55
export function setupTestEnvironment() {

src/walkthrough.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as vscode from "vscode";
2-
import { ExtensionContext, window, workspace, commands } from "vscode";
3-
import { Logger } from "./logger";
41
import fs from "fs";
52
import path from "path";
3+
import * as vscode from "vscode";
4+
import { commands, ExtensionContext, window, workspace } from "vscode";
5+
import { Logger } from "./logger";
66

77
export function registerWalkthroughCommands(context: ExtensionContext) {
88
const openSampleFileCommand = commands.registerCommand(

tests/activation.test.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import { window, commands } from "vscode";
1+
import { commands, window } from "vscode";
22

3-
import { describe, it, before, afterEach } from "mocha";
3+
import { afterEach, before, describe, it } from "mocha";
44
import * as sinon from "sinon";
55
let expect: Chai.ExpectStatic;
66

7+
import { manimNotebookContext } from "../src/extension";
78
import { Logger } from "../src/logger";
89
import { applyWindowsPastePatch } from "../src/patches/applyPatches";
9-
import { manimNotebookContext } from "../src/extension";
1010

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

1513
const MANIM_VERSION_STRING_REGEX = /v\d+\.\d+\.\d+/;

tests/cellRanges.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { workspace, Range } from "vscode";
21
import { describe, it } from "mocha";
3-
import { uriInWorkspace } from "./utils/testRunner";
2+
import { Range, workspace } from "vscode";
43
import { ManimCellRanges } from "../src/pythonParsing";
4+
import { uriInWorkspace } from "./utils/testRunner";
55

66
describe("Manim Cell Ranges", function () {
77
// in the expected ranges we only care about the start and end lines
88
// line numbers are 0-based here
99
const tests = [
1010
{
1111
filename: "detection_basic.py",
12-
expectedRanges: [[5, 7], [9, 10]],
12+
expectedRanges: [[5, 7], [9, 10], [16, 18]],
1313
},
1414
{
1515
filename: "detection_class_definition.py",

tests/fixtures/detection_basic.py

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ def construct(self):
1111
print("And even more code")
1212

1313

14+
class BasicNotebookWithType(Scene):
15+
16+
def construct(self) -> None:
17+
## Cell inside construct(self) marked with "None" type
18+
print("With some code None")
19+
print("With some more code None")
20+
21+
1422
class NoManimScene(Scene):
1523
def constructtttt(self):
1624
## Should not be detected as Manim Cell

tests/preview.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { window, commands } from "vscode";
2-
import { describe, it, before } from "mocha";
1+
import { before, describe, it } from "mocha";
2+
import { commands, window } from "vscode";
3+
import { goToLine } from "./utils/editor";
34
import { onAnyTerminalOutput } from "./utils/terminal";
45
import { uriInWorkspace } from "./utils/testRunner";
5-
import { goToLine } from "./utils/editor";
66
let expect: Chai.ExpectStatic;
77

88
before(async () => {

tests/utils/editor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TextEditor, Selection } from "vscode";
1+
import { Selection, TextEditor } from "vscode";
22

33
/**
44
* Moves the cursor to the specified line number.

tests/utils/installManim.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ManimInstaller } from "./manimInstaller";
21
import * as path from "path";
2+
import { ManimInstaller } from "./manimInstaller";
33

44
async function setupManimInstallation() {
55
const baseFolder = process.cwd();

tests/utils/manimCaller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { window } from "vscode";
21
import * as path from "path";
2+
import { window } from "vscode";
33

44
export class ManimCaller {
55
public venvPath: string = "";

tests/utils/testRunner.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
// import as soon as possible
1313
import { activatedEmitter } from "../../src/extension";
1414

15-
import * as path from "path";
16-
import Mocha from "mocha";
1715
import * as assert from "assert";
1816
import { globSync } from "glob";
17+
import Mocha from "mocha";
18+
import * as path from "path";
1919
import "source-map-support/register";
2020
import "./prototype";
2121

22-
import { window, workspace, Uri, extensions } from "vscode";
22+
import { Uri, extensions, window, workspace } from "vscode";
2323

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

0 commit comments

Comments
 (0)