Repository navigation
Fix code excerpts in the docs that point at the wrong lines - #2943
Merged
Merged
Conversation
Example code changed after the docs set their line numbers, so many :emphasize-lines: and :lines: options highlighted or showed the wrong code. Each one is remapped from the commit that set its numbers to where that code is now. Where the code was rewritten, the excerpt highlights the code that does the same job now. The pymunk ladder on_update excerpt uses :pyobject: so it can't drift again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Docs only. Fixes 62 code excerpts whose
:emphasize-lines:or:lines:pointed at the wrong code: 48 in tutorials and 14 on example pages. The example code had changed since their line numbers were set. Some had been wrong for years: the background image example last highlighted the right lines in 2021.How the numbers were found
For each
literalincludewith:lines:or:emphasize-lines:(about 180):doc/examplestodoc/example_code.on_update→update,Optional[X]→X | None, a wrapped call): checked by hand and accepted. Most of the rest are like this.sprite_collect_coins_background: loading and drawing the background.sprite_face_left_or_right: the left/right textures and switching between them.sprite_move_scrolling_shake: theScreenShake2Dsetup, update, start and readjust (it used to be one block of manual shake code).sprite_explosion_bitmapped: the oldexplosions_listsetup line is nowexplosions_list.clear()inreset().elif/elseof a block they started. I looked at each flagged one in context. The 14 still flagged are deliberate: one argument of a call, the body of a loop, GLSL lines inside a shader string, or one branch of an if/elif.Already wrong when they were written
camera2d_splitscreen: off by about a line since it was added in Add a split screen example using Camera2D #2789 (for example, it cut thesuper().__init__()call in half). It now highlights the camera code: window size,setup_players_cameras, zoom keys and methods, centering,on_drawandon_resize.sprite_rotate_around_point: started on a closing])and stopped before the platform rotation. It now highlights the method and all ofon_update.shader_toy_glowstep 3: one line off.:lines:started in the middle of the bullet code inon_mouse_press.:pyobject: GameWindow.on_updatewith:lines: 1-41, highlighting the ladder checks and the up/down branches.Checks
sphinx-buildproduces no literalinclude or line-range warnings.The changelog has an entry under Unreleased → Misc Changes.
🤖 Generated with Claude Code