|
| 1 | +# Release v1.2.0 |
| 2 | + |
| 3 | +**Release Date**: November 5, 2025 |
| 4 | + |
| 5 | +This release introduces new configuration options for styling solutions that follow exercises, along with order validation to help maintain document structure consistency. |
| 6 | + |
| 7 | +## ✨ New Features |
| 8 | + |
| 9 | +### Solution Title Styling Configuration |
| 10 | + |
| 11 | +A new `exercise_style` configuration option allows you to customize how solution titles are displayed when solutions follow their exercises. |
| 12 | + |
| 13 | +**Configuration:** |
| 14 | + |
| 15 | +```python |
| 16 | +# In conf.py |
| 17 | +exercise_style = "solution_follow_exercise" |
| 18 | +``` |
| 19 | + |
| 20 | +Or for Jupyter Book: |
| 21 | + |
| 22 | +```yaml |
| 23 | +# In _config.yml |
| 24 | +sphinx: |
| 25 | + config: |
| 26 | + exercise_style: "solution_follow_exercise" |
| 27 | +``` |
| 28 | +
|
| 29 | +**Behavior:** |
| 30 | +
|
| 31 | +- **When enabled** (`exercise_style = "solution_follow_exercise"`): |
| 32 | + - Solution titles show just "Solution" (simplified) |
| 33 | + - No hyperlinks back to exercises |
| 34 | + - No exercise number references |
| 35 | + - Ideal for lecture-style content where solutions immediately follow exercises |
| 36 | + |
| 37 | +- **Default** (`exercise_style = ""`): |
| 38 | + - Solution titles show "Solution to Exercise #.#" |
| 39 | + - Clickable hyperlinks to the exercise |
| 40 | + - Full exercise references included |
| 41 | + - Maintains original behavior |
| 42 | + |
| 43 | +**Example:** |
| 44 | + |
| 45 | +````md |
| 46 | +```{exercise} |
| 47 | +:label: my-exercise |
| 48 | +
|
| 49 | +What is 2 + 2? |
| 50 | +``` |
| 51 | + |
| 52 | +```{solution} my-exercise |
| 53 | +
|
| 54 | +The answer is 4. |
| 55 | +``` |
| 56 | +```` |
| 57 | + |
| 58 | +With `exercise_style = "solution_follow_exercise"`, the solution will display with the simple title "Solution" instead of "Solution to Exercise 1". |
| 59 | + |
| 60 | +### Order Validation System |
| 61 | + |
| 62 | +When `exercise_style = "solution_follow_exercise"` is enabled, sphinx-exercise now validates that solutions appear in the correct order: |
| 63 | + |
| 64 | +**Validations performed:** |
| 65 | +- Solutions must appear **after** their referenced exercises |
| 66 | +- Solutions must be in the **same document** as their exercises |
| 67 | + |
| 68 | +**Warning messages:** |
| 69 | + |
| 70 | +``` |
| 71 | +WARNING: [sphinx-exercise] Solution 'my-solution' appears before its exercise 'my-exercise'. |
| 72 | +When exercise_style='solution_follow_exercise', solutions should follow their exercises. |
| 73 | +Location: /path/to/file.md:42 |
| 74 | +``` |
| 75 | +
|
| 76 | +``` |
| 77 | +WARNING: [sphinx-exercise] Solution 'my-solution' references exercise 'my-exercise' |
| 78 | +which is not in the same document. When exercise_style='solution_follow_exercise', |
| 79 | +solutions should appear in the same document as their exercises. |
| 80 | +``` |
| 81 | +
|
| 82 | +**Benefits:** |
| 83 | +- Helps maintain consistent document structure |
| 84 | +- Prevents confusing layouts where solutions appear before exercises |
| 85 | +- Provides clear, actionable warnings with file paths and line numbers |
| 86 | +- Warnings prefixed with `[sphinx-exercise]` for easy identification |
| 87 | +
|
| 88 | +## 👌 Improvements |
| 89 | +
|
| 90 | +### Enhanced User Experience |
| 91 | +
|
| 92 | +- **Simplified titles**: Cleaner, more concise solution headings for lecture-style content |
| 93 | +- **Better organization**: Order validation helps maintain logical document flow |
| 94 | +- **Helpful diagnostics**: Clear warnings with file locations and line numbers |
| 95 | +
|
| 96 | +### Code Quality |
| 97 | +
|
| 98 | +- Removed redundant title building logic in `post_transforms.py` |
| 99 | +- Cleaner separation between directive initialization and post-transform processing |
| 100 | +- Improved configuration naming for clarity when used alongside other extensions |
| 101 | +
|
| 102 | +## 📦 Installation |
| 103 | +
|
| 104 | +Install or upgrade via pip: |
| 105 | +
|
| 106 | +```bash |
| 107 | +pip install --upgrade sphinx-exercise |
| 108 | +``` |
| 109 | + |
| 110 | +## 🔄 Migration Notes |
| 111 | + |
| 112 | +**If you're upgrading from v1.1.1:** |
| 113 | +- **No breaking changes** - existing projects continue to work without modification |
| 114 | +- **No action required** - default behavior is unchanged |
| 115 | +- **Optional enhancement**: Add `exercise_style = "solution_follow_exercise"` if you want simplified solution titles |
| 116 | + |
| 117 | +**If you want to use the new features:** |
| 118 | + |
| 119 | +1. Add the configuration to your `conf.py`: |
| 120 | + ```python |
| 121 | + exercise_style = "solution_follow_exercise" |
| 122 | + ``` |
| 123 | + |
| 124 | +2. Rebuild your documentation: |
| 125 | + ```bash |
| 126 | + sphinx-build -b html source build/html |
| 127 | + ``` |
| 128 | + |
| 129 | +3. Review any warnings about solution ordering |
| 130 | + |
| 131 | +**Compatibility:** |
| 132 | +- Python 3.10, 3.11, 3.12, 3.13 |
| 133 | +- Sphinx 6, 7, 8 |
| 134 | +- All existing directives and configurations continue to work |
| 135 | + |
| 136 | +## 🔗 Related PRs |
| 137 | + |
| 138 | +- [#81](https://github.com/executablebooks/sphinx-exercise/pull/81) - Add `exercise_style` configuration and order validation |
| 139 | + |
| 140 | +## 📚 Documentation |
| 141 | + |
| 142 | +For complete documentation, see: |
| 143 | +- [Configuration Options](../syntax.md#solution-title-styling) |
| 144 | +- [Installation Guide](../install.md) |
| 145 | + |
| 146 | +## 💡 Use Cases |
| 147 | + |
| 148 | +This release is particularly useful for: |
| 149 | + |
| 150 | +- **Lecture notes** where solutions immediately follow exercises |
| 151 | +- **Tutorial content** with inline solutions |
| 152 | +- **Educational materials** that benefit from simplified styling |
| 153 | +- **Projects** that want validation of exercise/solution ordering |
0 commit comments