Skip to content

Commit 1ecc918

Browse files
committed
Merge dev: fix notebook filename convention in docs and Binder (fixes #1176)
2 parents 088eaa3 + f729e28 commit 1ecc918

File tree

33 files changed

+2848
-557
lines changed

33 files changed

+2848
-557
lines changed

binder/postBuild

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ echo "📓 Generating student notebooks from source..."
1818
for module_dir in src/*/; do
1919
module_name=$(basename "$module_dir")
2020
py_file="$module_dir/${module_name}.py"
21+
# Strip numeric prefix for notebook name (e.g., "01_tensor" -> "tensor")
22+
short_name="${module_name#*_}"
2123

2224
if [ -f "$py_file" ]; then
2325
# Create output directory
2426
mkdir -p "modules/$module_name"
2527

2628
# Convert .py to .ipynb using jupytext
2729
echo " 📝 Converting $module_name..."
28-
jupytext --to notebook "$py_file" --output "modules/$module_name/${module_name}.ipynb" 2>/dev/null || {
30+
jupytext --to notebook "$py_file" --output "modules/$module_name/${short_name}.ipynb" 2>/dev/null || {
2931
echo " ⚠️ Warning: Could not convert $module_name"
3032
}
3133
fi

tinytorch/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ TinyTorch/
193193
194194
├── modules/ # 📓 Generated notebooks (learners work here)
195195
│ ├── 01_tensor/ # Auto-generated from src/
196-
│ │ ├── 01_tensor.ipynb # Jupyter notebook for learning
196+
│ │ ├── tensor.ipynb # Jupyter notebook for learning
197197
│ │ ├── README.md # Practical implementation guide
198198
│ │ └── tensor.py # Your implementation
199199
│ └── ... # (20 module directories)

tinytorch/binder/postBuild

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ echo "📓 Generating student notebooks from source..."
1515
for module_dir in src/*/; do
1616
module_name=$(basename "$module_dir")
1717
py_file="$module_dir/${module_name}.py"
18+
# Strip numeric prefix for notebook name (e.g., "01_tensor" -> "tensor")
19+
short_name="${module_name#*_}"
1820

1921
if [ -f "$py_file" ]; then
2022
# Create output directory
2123
mkdir -p "modules/$module_name"
2224

2325
# Convert .py to .ipynb using jupytext
2426
echo " 📝 Converting $module_name..."
25-
jupytext --to notebook "$py_file" --output "modules/$module_name/${module_name}.ipynb" 2>/dev/null || {
27+
jupytext --to notebook "$py_file" --output "modules/$module_name/${short_name}.ipynb" 2>/dev/null || {
2628
echo " ⚠️ Warning: Could not convert $module_name"
2729
}
2830
fi

tinytorch/site/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ serve: clean html
2929
pdf:
3030
@echo "🔥 Building Tiny🔥Torch PDF via XeLaTeX..."
3131
@echo ""
32+
@# PDF build needs Mermaid CLI (for diagrams). Config uses npx; Node.js must be installed.
33+
@command -v npx >/dev/null 2>&1 || { echo "❌ Error: npx not found. PDF build requires Node.js (for Mermaid diagrams). Install from https://nodejs.org/ or run: brew install node"; exit 1; }
34+
@echo "✅ Mermaid CLI (via npx) available"
3235
@# Step 1: Generate LaTeX (matches CI workflow)
3336
@echo "📚 Generating LaTeX files..."
3437
jupyter-book build . --builder latex --config _config_pdf.yml --toc _toc_pdf.yml
@@ -63,7 +66,7 @@ clean:
6366
install:
6467
@echo "📦 Installing dependencies..."
6568
pip install -U pip
66-
pip install "jupyter-book<1.0"
69+
pip install "jupyter-book>=1.0.0,<2.0.0"
6770
pip install -r requirements.txt
6871

6972
test:

tinytorch/site/_config_pdf.yml

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ description: >-
1313
Learn by implementing your own PyTorch-style framework with hands-on coding,
1414
real datasets, and production-ready practices.
1515
16-
# Execution settings - disable for PDF
16+
# Execution settings - cache mode enables {glue} computed values in ABOUT.md files
1717
execute:
18-
execute_notebooks: "off"
19-
allow_errors: false
18+
execute_notebooks: "cache"
19+
allow_errors: true
2020
timeout: 300
2121

2222
# Exclude patterns
@@ -51,12 +51,15 @@ sphinx:
5151
- sphinxcontrib.mermaid
5252
config:
5353
mermaid_version: "10.6.1"
54+
# Use npx so PDF build works without global mermaid-cli (requires Node.js)
55+
mermaid_cmd: "npx -y @mermaid-js/mermaid-cli"
5456
# Render mermaid as PDF for LaTeX
5557
# --pdfFit scales PDF to fit the diagram (not full page)
5658
# --scale 1.0 keeps diagrams at natural size (1.5 was too large for tall diagrams)
5759
mermaid_output_format: "pdf"
58-
# Width 800 constrains diagram width; scale must be integer (1 = natural size)
59-
mermaid_params: ['--pdfFit', '--scale', '1', '--width', '800', '--backgroundColor', 'white']
60+
# Width 600 constrains diagram viewport; scale 1 = natural size
61+
# Smaller viewport + pdfcrop produces tighter diagrams that don't stretch to full page width
62+
mermaid_params: ['--pdfFit', '--scale', '1', '--width', '600', '--backgroundColor', 'white']
6063
# Use pdfcrop to trim whitespace from mermaid PDFs
6164
mermaid_pdfcrop: "pdfcrop"
6265
# Use professional sans-serif font for mermaid diagrams to match document
@@ -89,6 +92,9 @@ sphinx:
8992
papersize: 'letterpaper'
9093
pointsize: '10pt'
9194
figure_align: 'H'
95+
# Pass 'export' option to adjustbox before Sphinx loads it (avoids option clash).
96+
# This enables max width/height keys in \includegraphics for mermaid figure capping.
97+
passoptionstopackages: '\PassOptionsToPackage{export}{adjustbox}'
9298
fontpkg: |
9399
% Professional academic font stack (TeX Gyre - available in TeX Live)
94100
\usepackage{fontspec}
@@ -109,6 +115,27 @@ sphinx:
109115
\usepackage{hyperref}
110116
\usepackage{float}
111117
118+
% Cap Mermaid diagram width at 75% of text width.
119+
% sphinxcontrib-mermaid hardcodes width=\linewidth for all diagrams,
120+
% which stretches small flowcharts to full page width. This override
121+
% intercepts \includegraphics and uses adjustbox's max width for
122+
% mermaid-*.pdf files while passing other images through unchanged.
123+
% Note: adjustbox 'export' option passed via passoptionstopackages above.
124+
\let\OrigIncludeGraphics\includegraphics
125+
\makeatletter
126+
\renewcommand{\includegraphics}[2][]{%
127+
\begingroup
128+
\def\@mermaidtest{mermaid-}%
129+
\@expandtwoargs\in@{\@mermaidtest}{#2}%
130+
\ifin@
131+
\OrigIncludeGraphics[max width=0.75\linewidth,max height=0.45\textheight,keepaspectratio]{#2}%
132+
\else
133+
\OrigIncludeGraphics[#1]{#2}%
134+
\fi
135+
\endgroup
136+
}
137+
\makeatother
138+
112139
% Better figure placement - keep figures inline with text
113140
\renewcommand{\topfraction}{0.9}
114141
\renewcommand{\bottomfraction}{0.9}
@@ -172,6 +199,13 @@ sphinx:
172199
\newunicodechar{ω}{$\omega$}
173200
\newunicodechar{✓}{\checkmark}
174201
\newunicodechar{✗}{$\times$}
202+
% Box-drawing (terminal/code art) - TeX Gyre Cursor has no Unicode box glyphs
203+
\newunicodechar{═}{\texttt{=}}
204+
\newunicodechar{║}{\texttt{|}}
205+
\newunicodechar{╔}{\texttt{+}}
206+
\newunicodechar{╗}{\texttt{+}}
207+
\newunicodechar{╚}{\texttt{+}}
208+
\newunicodechar{╝}{\texttt{+}}
175209
176210
% Syntax-highlighted code blocks with refined colors
177211
\usepackage{listings}

tinytorch/site/_static/custom.css

Lines changed: 90 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,16 @@ pre.mermaid {
384384
display: flex;
385385
align-items: center;
386386
font-size: 1.2rem;
387-
font-weight: 600;
388-
color: #f59e0b;
389-
text-decoration: none;
387+
font-weight: 700;
388+
color: #fbbf24 !important;
389+
text-decoration: none !important;
390390
letter-spacing: -0.01em;
391+
text-shadow: 0 0 12px rgba(251, 191, 36, 0.3);
391392
}
392393

393394
.tinytorch-bar-brand:hover {
394-
color: #fbbf24;
395+
color: #fde68a !important;
396+
text-shadow: 0 0 16px rgba(251, 191, 36, 0.45);
395397
}
396398

397399
.tinytorch-bar-brand .brand-fire {
@@ -485,26 +487,41 @@ pre.mermaid {
485487
background: rgba(249, 115, 22, 0.15);
486488
}
487489

488-
/* Responsive: hide text on small screens, keep icons */
490+
/* ── Responsive: progressive disclosure across breakpoints ── */
491+
492+
/* Tablet landscape / small desktop — drop date from version, shrink link padding */
493+
@media (max-width: 1024px) {
494+
.tinytorch-bar-version .version-date {
495+
display: none;
496+
}
497+
498+
.tinytorch-bar-links a {
499+
padding: 0.5rem 0.7rem;
500+
}
501+
}
502+
503+
/* Tablet portrait — icons only, shrink badge, ensure 44px touch targets */
489504
@media (max-width: 768px) {
490505
.tinytorch-bar-links .link-text {
491506
display: none;
492507
}
493508

494509
.tinytorch-bar-links a {
495-
padding: 0.5rem;
510+
min-width: 44px;
511+
min-height: 44px;
512+
display: flex;
513+
align-items: center;
514+
justify-content: center;
515+
padding: 0;
496516
}
497517

498518
.tinytorch-bar-links .link-icon {
499-
font-size: 1.1rem;
519+
font-size: 1.15rem;
500520
}
501521

502522
.tinytorch-bar-badge {
503-
display: none;
504-
}
505-
506-
.tinytorch-bar-version {
507-
display: none;
523+
font-size: 0.65rem;
524+
padding: 0.2rem 0.5rem;
508525
}
509526

510527
.tinytorch-bar-left {
@@ -516,23 +533,42 @@ pre.mermaid {
516533
}
517534

518535
.tinytorch-bar {
519-
height: 44px;
536+
height: 48px;
520537
}
521538

522-
/* Keep download link visible but compact on mobile */
523-
.tinytorch-bar-links a.download-link {
524-
padding: 0.4rem 0.6rem;
539+
.tinytorch-bar-links {
540+
gap: 0;
525541
}
526542
}
527543

528-
/* Extra small screens - minimal spacing */
529-
@media (max-width: 480px) {
530-
.tinytorch-bar-links {
531-
gap: 0.1rem;
544+
/* Phone — hide badge, hide secondary links, keep compact version */
545+
@media (max-width: 600px) {
546+
.tinytorch-bar-badge {
547+
display: none;
532548
}
533549

534-
.tinytorch-bar-links a {
535-
padding: 0.4rem;
550+
.tinytorch-bar-links a.link-secondary {
551+
display: none;
552+
}
553+
554+
.tinytorch-bar-version {
555+
font-size: 0.7rem;
556+
padding: 0.2rem 0.5rem;
557+
}
558+
559+
.tinytorch-bar {
560+
height: 44px;
561+
}
562+
563+
.tinytorch-bar-brand {
564+
font-size: 1.05rem;
565+
}
566+
}
567+
568+
/* Small phone — hide version too, brand + 3 primary icons */
569+
@media (max-width: 420px) {
570+
.tinytorch-bar-version {
571+
display: none;
536572
}
537573

538574
.tinytorch-bar-brand {
@@ -584,6 +620,18 @@ header.bd-header {
584620
margin-top: 3.5rem !important;
585621
}
586622

623+
@media (max-width: 768px) {
624+
header.bd-header {
625+
margin-top: 2.75rem !important;
626+
}
627+
}
628+
629+
@media (max-width: 600px) {
630+
header.bd-header {
631+
margin-top: 2.5rem !important;
632+
}
633+
}
634+
587635
/* When announcement bar is present, add extra space */
588636
body.has-announcement header.bd-header {
589637
margin-top: 6rem !important;
@@ -593,6 +641,26 @@ body.has-announcement .tinytorch-bar {
593641
top: 2.5rem !important;
594642
}
595643

644+
@media (max-width: 768px) {
645+
body.has-announcement header.bd-header {
646+
margin-top: 5rem !important;
647+
}
648+
649+
body.has-announcement .tinytorch-bar {
650+
top: 2.25rem !important;
651+
}
652+
}
653+
654+
@media (max-width: 600px) {
655+
body.has-announcement header.bd-header {
656+
margin-top: 4.5rem !important;
657+
}
658+
659+
body.has-announcement .tinytorch-bar {
660+
top: 2rem !important;
661+
}
662+
}
663+
596664
/* Hide icon links from sidebar completely - only show in top navbar */
597665
.bd-sidebar .icon-links,
598666
.bd-sidebar .navbar-icon-links,

tinytorch/site/_static/wip-banner.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ document.addEventListener('DOMContentLoaded', function() {
3232
<a href="${siteRoot}intro.html" class="tinytorch-bar-brand">
3333
Tiny<span class="brand-fire">🔥</span>Torch
3434
</a>
35+
<a href="https://github.com/harvard-edge/cs249r_book/releases" target="_blank" rel="noopener noreferrer" class="tinytorch-bar-version" title="View releases on GitHub"><span class="version-number">v${TINYTORCH_VERSION}</span><span class="version-date"> · ${TINYTORCH_RELEASE_DATE}</span></a>
3536
<span class="tinytorch-bar-badge">Under Construction</span>
36-
<a href="https://github.com/harvard-edge/cs249r_book/releases" target="_blank" rel="noopener noreferrer" class="tinytorch-bar-version" title="View releases on GitHub">v${TINYTORCH_VERSION} · ${TINYTORCH_RELEASE_DATE}</a>
3737
</div>
3838
<div class="tinytorch-bar-links">
3939
<a href="${siteRoot}_static/downloads/TinyTorch-Guide.pdf" class="download-link" title="Download Course Guide (PDF)">
@@ -44,19 +44,19 @@ document.addEventListener('DOMContentLoaded', function() {
4444
<span class="link-icon">↗</span>
4545
<span class="link-text">Paper</span>
4646
</a>
47-
<a href="https://mlsysbook.ai" target="_blank">
47+
<a href="https://mlsysbook.ai" target="_blank" class="link-secondary">
4848
<span class="link-icon">📖</span>
4949
<span class="link-text">MLSysBook</span>
5050
</a>
51-
<a href="#" class="subscribe-trigger" onclick="event.preventDefault(); if(window.openSubscribeModal) openSubscribeModal();">
51+
<a href="#" class="subscribe-trigger link-secondary" onclick="event.preventDefault(); if(window.openSubscribeModal) openSubscribeModal();">
5252
<span class="link-icon">✉️</span>
5353
<span class="link-text">Subscribe</span>
5454
</a>
5555
<a href="https://github.com/harvard-edge/cs249r_book" target="_blank">
5656
<span class="link-icon">⭐</span>
5757
<span class="link-text">Star</span>
5858
</a>
59-
<a href="${siteRoot}community.html" target="_blank">
59+
<a href="${siteRoot}community.html" target="_blank" class="link-secondary">
6060
<span class="link-icon">🌍</span>
6161
<span class="link-text">Community</span>
6262
</a>

tinytorch/site/_toc_pdf.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ parts:
121121
- file: conclusion
122122
title: "You Built Something Real"
123123

124+
# Community (referenced from TITO overview)
125+
- caption: Community
126+
numbered: false
127+
chapters:
128+
- file: community
129+
title: "Community Guide"
130+
124131
# Appendix
125132
- caption: Appendix
126133
numbered: false

tinytorch/site/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ This opens the module notebook and tracks your progress.
104104

105105
### Work in the notebook
106106

107-
Edit `modules/01_tensor/01_tensor.ipynb` in Jupyter:
107+
Edit `modules/01_tensor/tensor.ipynb` in Jupyter:
108108

109109
```bash
110-
jupyter lab modules/01_tensor/01_tensor.ipynb
110+
jupyter lab modules/01_tensor/tensor.ipynb
111111
```
112112

113113
You'll implement:

tinytorch/site/tito/modules.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,11 @@ src/ ← Developer source code
409409
410410
modules/ ← Generated notebooks (students use)
411411
├── 01_tensor/
412-
│ └── 01_tensor.ipynb ← AUTO-GENERATED for students
412+
│ └── tensor.ipynb ← AUTO-GENERATED for students
413413
├── 02_activations/
414-
│ └── 02_activations.ipynb ← AUTO-GENERATED for students
414+
│ └── activations.ipynb ← AUTO-GENERATED for students
415415
└── 03_layers/
416-
└── 03_layers.ipynb ← AUTO-GENERATED for students
416+
└── layers.ipynb ← AUTO-GENERATED for students
417417
```
418418

419419
### Where Code Exports

0 commit comments

Comments
 (0)