Skip to content

Fix code excerpts in the docs that point at the wrong lines - #2943

Merged
pvcraven merged 1 commit into
developmentfrom
docs/fix-line-references
Oct 8, 2026
Merged

pvcraven merged 1 commit into
developmentfrom
docs/fix-line-references

Conversation

@pvcraven

@pvcraven pvcraven commented Oct 8, 2026

Copy link
Copy Markdown
Member

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 literalinclude with :lines: or :emphasize-lines: (about 180):

  1. The commit that set its numbers: found by searching the history for that spec. This follows the move from doc/examples to doc/example_code.
  2. Remap to now: each referenced line is mapped from the file as it was in that commit to the file today, with a line diff.
  3. Compare the highlighted text then and now:
    • Same text (24 excerpts): accepted.
    • Reformatted or updated code (for example on_update → update, Optional[X] → X | None, a wrapped call): checked by hand and accepted. Most of the rest are like this.
    • Rewritten code: ranges chosen by hand to highlight the code that does the same job now:
      • 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: the ScreenShake2D setup, update, start and readjust (it used to be one block of manual shake code).
      • sprite_explosion_bitmapped: the old explosions_list setup line is now explosions_list.clear() in reset().
  4. A boundary check on every include: flags ranges that start or end partway through a statement, or stop before an elif/else of 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 the super().__init__() call in half). It now highlights the camera code: window size, setup_players_cameras, zoom keys and methods, centering, on_draw and on_resize.
  • sprite_rotate_around_point: started on a closing ]) and stopped before the platform rotation. It now highlights the method and all of on_update.
  • shader_toy_glow step 3: one line off.
  • Pymunk tutorial, "Add Ladders - Game Window On Update":
    • Its :lines: started in the middle of the bullet code in on_mouse_press.
    • It now uses :pyobject: GameWindow.on_update with :lines: 1-41, highlighting the ladder checks and the up/down branches.
    • Since it selects the method by name, it can't drift again.

Checks

The changelog has an entry under Unreleased → Misc Changes.

🤖 Generated with Claude Code

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>
@pvcraven
pvcraven merged commit e08e01b into development Oct 8, 2026
7 checks passed
@pvcraven
pvcraven deleted the docs/fix-line-references branch October 8, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant