Skip to content
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
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.PHONY: help prereqs check-python check-poetry install pre-commit-install jupyter list-notebooks list-chapters clean lint lint-fix format format-check type-check check test

# Shorthand: CH=01 expands to CHAPTER=chapter_01
ifdef CH
CHAPTER := chapter_$(CH)
endif

# Default target
help:
@echo "Learning Python - Makefile Commands"
Expand All @@ -14,9 +19,9 @@ help:
@echo " make check-poetry Check/install Poetry"
@echo ""
@echo "Notebooks:"
@echo " make jupyter CHAPTER=chapter_01 Open chapter notebooks in Jupyter Lab"
@echo " make list-notebooks CHAPTER=chapter_01"
@echo " make list-chapters"
@echo " make jupyter CH=01 Open chapter notebooks in Jupyter Lab"
@echo " make list-notebooks CH=01 List notebooks in a chapter"
@echo " make list-chapters List all available chapters"
@echo ""
@echo "Code Quality:"
@echo " make lint Run ruff linter"
Expand Down Expand Up @@ -71,13 +76,13 @@ pre-commit-install:

jupyter:
@if [ -z "$(CHAPTER)" ]; then \
echo "Usage: make jupyter CHAPTER=chapter_XX"; \
echo "Usage: make jupyter CH=01"; \
exit 1; \
fi
@if [ -d "src/$(CHAPTER)" ]; then \
poetry run jupyter lab src/$(CHAPTER)/; \
else \
echo "Chapter $(CHAPTER) not found"; \
echo "Chapter '$(CHAPTER)' not found"; \
exit 1; \
fi

Expand Down Expand Up @@ -123,14 +128,14 @@ list-chapters:

list-notebooks:
@if [ -z "$(CHAPTER)" ]; then \
echo "Usage: make list-notebooks CHAPTER=chapter_XX"; \
echo "Usage: make list-notebooks CH=01"; \
exit 1; \
fi
@if [ -d "src/$(CHAPTER)" ]; then \
echo "Notebooks in $(CHAPTER):"; \
find src/$(CHAPTER) -name "*.ipynb" | sed 's|src/$(CHAPTER)/||' | sort; \
else \
echo "Chapter $(CHAPTER) not found"; \
echo "Chapter '$(CHAPTER)' not found"; \
exit 1; \
fi

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ make pre-commit-install
make list-chapters

# List notebooks in a chapter
make list-notebooks CHAPTER=chapter_01
make list-notebooks CH=01

# Open a chapter's notebooks in Jupyter Lab
make jupyter CHAPTER=chapter_01
make jupyter CH=01
```

## Prerequisites
Expand Down Expand Up @@ -173,7 +173,7 @@ Jupyter notebooks are the primary learning material:

```bash
# Open a specific chapter in Jupyter Lab
make jupyter CHAPTER=chapter_01
make jupyter CH=01

# Or launch directly with Poetry
poetry run jupyter lab src/chapter_01/
Expand Down