ruff/playground/ty-embed/example-dev.html

92 lines
1.9 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ty Type Checker - Interactive Example</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
sans-serif;
max-width: 900px;
margin: 0 auto;
padding: 40px 20px;
line-height: 1.6;
color: #333;
}
h1 {
color: #1a1a1a;
padding-bottom: 12px;
margin-bottom: 20px;
}
h2 {
color: #2a2a2a;
margin-top: 30px;
margin-bottom: 16px;
font-size: 1.5em;
}
p {
color: #555;
margin-bottom: 16px;
}
.intro {
font-size: 1.1em;
color: #666;
margin-bottom: 40px;
}
.editor-container {
margin: 24px 0 48px 0;
}
</style>
</head>
<body>
<h1>
ty Type Checker
</h1>
<p class="intro">
This interactive editor provides real-time type checking.
Hover over symbols to see type information, Ctrl+click to jump to definitions,
and click on errors to see quick fix suggestions.
</p>
<h2>TypedDict Keys</h2>
<p>
The code below has a typo in the dictionary key. Click on the error
and use the quick fix (lightbulb icon or Ctrl+.) to automatically fix it:
</p>
<div id="editor" class="editor-container"></div>
<script type="module">
// Development version - imports from source
import { createTyEditor } from "./src/index.ts";
const editor = createTyEditor({
container: "#editor",
id: "typeddict-example",
theme: "light",
height: "360px",
initialCode: `from typing import TypedDict
class Person(TypedDict):
name: str
age: int | None
def greet(person: Person):
print("Hello", person["name"])
`,
});
// Expose for debugging
window.tyEditor = editor;
</script>
</body>
</html>