Commit f900c34
committed
Fix trailing text in doctest-syntax plot_directive.
The problem was that an input like
```
Some text.
>>> python_code()
The end.
```
would get split to
```
Some text.
>>> python_code()
```
and
```
The end.
```
and that unescape_doctest would then believe that `The end.` is already
python code (as it doesn't contain a `>>>`) and try to run it as is.
To fix this, instead of repeatedly calling `contains_doctest` everywhere
to guess whether fragments are doctest or python, just do it once at the
beginning, do the escaping once if needed at the beginning and then call
the new _functions (`_split_code_at_show`, `_run_code`) which don't try to
guess anymore. Because of the new (non-guessing) semantics these must
go to new functions, so let's make them private and just deprecate the old
(public) ones.
The escaping itself was done by `unescape_doctest`, but that had a
separate bug misparsing
```
This is an example...
>>> some_python()
... isn't it?
```
the last line would get incorrectly misparsed as a line continuation,
despite the blank line in between. Instead of trying to fix that
ourselves, just use `doctest.script_from_examples` which exactly serves
that purpose.1 parent 679ca17 commit f900c34
File tree
3 files changed
+37
-9
lines changed- doc/api/next_api_changes/deprecations
- lib/matplotlib
- sphinxext
- tests/tinypages
3 files changed
+37
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
301 | 302 | | |
302 | 303 | | |
303 | 304 | | |
| 305 | + | |
304 | 306 | | |
305 | 307 | | |
306 | 308 | | |
307 | 309 | | |
308 | 310 | | |
309 | 311 | | |
310 | 312 | | |
311 | | - | |
312 | 313 | | |
313 | 314 | | |
314 | 315 | | |
| |||
321 | 322 | | |
322 | 323 | | |
323 | 324 | | |
| 325 | + | |
324 | 326 | | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
325 | 332 | | |
326 | 333 | | |
327 | 334 | | |
328 | | - | |
329 | 335 | | |
330 | 336 | | |
331 | 337 | | |
| |||
337 | 343 | | |
338 | 344 | | |
339 | 345 | | |
340 | | - | |
| 346 | + | |
341 | 347 | | |
342 | 348 | | |
343 | 349 | | |
| |||
437 | 443 | | |
438 | 444 | | |
439 | 445 | | |
| 446 | + | |
440 | 447 | | |
441 | 448 | | |
442 | 449 | | |
443 | 450 | | |
444 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
445 | 460 | | |
446 | 461 | | |
447 | 462 | | |
| |||
466 | 481 | | |
467 | 482 | | |
468 | 483 | | |
469 | | - | |
470 | 484 | | |
471 | 485 | | |
472 | 486 | | |
| |||
529 | 543 | | |
530 | 544 | | |
531 | 545 | | |
532 | | - | |
| 546 | + | |
533 | 547 | | |
534 | 548 | | |
535 | 549 | | |
| |||
593 | 607 | | |
594 | 608 | | |
595 | 609 | | |
596 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
597 | 613 | | |
598 | 614 | | |
599 | 615 | | |
| |||
816 | 832 | | |
817 | 833 | | |
818 | 834 | | |
819 | | - | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
820 | 838 | | |
821 | 839 | | |
822 | 840 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
0 commit comments