Skip to content

Commit d87a241

Browse files
committed
feat: enhance code examples with language support and improve styling in Core Usage and Quick Start sections
1 parent d1707b7 commit d87a241

2 files changed

Lines changed: 40 additions & 16 deletions

File tree

src/components/CoreUsage.astro

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
---
2+
import { Code } from "astro:components";
3+
24
const examples = [
35
{
46
title: "Define Components",
57
description: "Create typed components with Pydantic v2 models.",
8+
lang: "python" as const,
69
code: `from cryo_wiring_core import (
710
CooldownBuilder, ChipConfig, CooldownMetadata,
811
Attenuator, Filter, Isolator, Amplifier, Stage,
@@ -20,6 +23,7 @@ catalog = {
2023
{
2124
title: "Build a Cooldown",
2225
description: "Fluent builder API with per-line overrides.",
26+
lang: "python" as const,
2327
code: `cooldown = (
2428
CooldownBuilder(
2529
chip=ChipConfig(name="sample-8q", num_qubits=8, qubits_per_readout_line=4),
@@ -44,6 +48,7 @@ catalog = {
4448
{
4549
title: "Summary & Diagram",
4650
description: "Generate terminal tables, Markdown, HTML, and publication-quality SVG diagrams.",
51+
lang: "python" as const,
4752
code: `# Print a Rich-formatted table to the terminal
4853
cooldown.summary()
4954
@@ -57,6 +62,7 @@ cooldown.diagram(output="wiring.svg", representative=True)`,
5762
{
5863
title: "Export & Validate",
5964
description: "Write YAML files and validate against the spec.",
65+
lang: "python" as const,
6066
code: `# Export as a cooldown directory
6167
cooldown.write("output/")
6268
# output/
@@ -92,7 +98,9 @@ validate_wiring(data) # raises jsonschema.ValidationError on failure`,
9298
<p class="example-description">{example.description}</p>
9399
</div>
94100
</div>
95-
<pre class="example-code"><code>{example.code}</code></pre>
101+
<div class="example-code-wrapper">
102+
<Code code={example.code} lang={example.lang} theme="github-dark" />
103+
</div>
96104
</div>
97105
))
98106
}
@@ -177,18 +185,21 @@ validate_wiring(data) # raises jsonschema.ValidationError on failure`,
177185
color: var(--color-text-muted);
178186
}
179187

180-
.example-code {
181-
padding: 1.25rem 1.5rem;
188+
.example-code-wrapper {
182189
overflow-x: auto;
183-
margin: 0;
184190
}
185191

186-
.example-code code {
187-
font-family: var(--font-mono);
192+
.example-code-wrapper :global(pre) {
193+
margin: 0;
194+
padding: 1.25rem 1.5rem;
195+
border-radius: 0;
188196
font-size: 0.8rem;
189-
color: var(--color-success);
190197
line-height: 1.65;
191-
white-space: pre;
198+
background: transparent !important;
199+
}
200+
201+
.example-code-wrapper :global(code) {
202+
font-family: var(--font-mono);
192203
}
193204

194205
.core-links {

src/components/QuickStart.astro

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
---
2+
import { Code } from "astro:components";
3+
24
const steps = [
35
{
46
step: "01",
57
title: "Install the CLI",
8+
lang: "bash" as const,
69
code: "pip install cryo-wiring-cli",
710
},
811
{
912
step: "02",
1013
title: "Create a new fridge",
14+
lang: "bash" as const,
1115
code: "cryo-wiring new --fridge my-cryo --chip chip.yaml",
1216
},
1317
{
1418
step: "03",
1519
title: "Edit your wiring",
20+
lang: "yaml" as const,
1621
code: `# my-cryo/current/control.yaml
1722
modules:
1823
ctrl:
@@ -33,17 +38,20 @@ lines:
3338
{
3439
step: "04",
3540
title: "Build & validate",
41+
lang: "bash" as const,
3642
code: `cryo-wiring build my-cryo/current/
3743
cryo-wiring validate my-cryo/current/`,
3844
},
3945
{
4046
step: "05",
4147
title: "Generate diagrams",
48+
lang: "bash" as const,
4249
code: "cryo-wiring diagram my-cryo/current/",
4350
},
4451
{
4552
step: "06",
4653
title: "Snapshot a cooldown",
54+
lang: "bash" as const,
4755
code: "cryo-wiring snapshot my-cryo",
4856
},
4957
];
@@ -62,7 +70,9 @@ cryo-wiring validate my-cryo/current/`,
6270
<div class="step-number">{item.step}</div>
6371
<div class="step-body">
6472
<h3 class="step-title">{item.title}</h3>
65-
<pre class="step-code"><code>{item.code}</code></pre>
73+
<div class="step-code-wrapper">
74+
<Code code={item.code} lang={item.lang} theme="github-dark" />
75+
</div>
6676
</div>
6777
</div>
6878
))
@@ -114,19 +124,22 @@ cryo-wiring validate my-cryo/current/`,
114124
margin-bottom: 0.5rem;
115125
}
116126

117-
.step-code {
118-
background: var(--color-bg-card);
127+
.step-code-wrapper {
119128
border: 1px solid var(--color-border);
120129
border-radius: 0.5rem;
121-
padding: 1rem 1.25rem;
122130
overflow-x: auto;
123131
}
124132

125-
.step-code code {
126-
font-family: var(--font-mono);
133+
.step-code-wrapper :global(pre) {
134+
margin: 0;
135+
padding: 1rem 1.25rem;
136+
border-radius: 0.5rem;
127137
font-size: 0.825rem;
128-
color: var(--color-success);
129138
line-height: 1.6;
130-
white-space: pre;
139+
background: var(--color-bg-card) !important;
140+
}
141+
142+
.step-code-wrapper :global(code) {
143+
font-family: var(--font-mono);
131144
}
132145
</style>

0 commit comments

Comments
 (0)