Skip to content

Commit 30e7dae

Browse files
author
Matthias Koeppe
committed
src/sage/doctest/parsing.py (update_optional_tags): Preserve two-column tag layout
1 parent 3c44670 commit 30e7dae

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/sage/doctest/parsing.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ def update_optional_tags(line, tags=None, *, add_tags=None, remove_tags=None, fo
442442
....: force_rewrite=True),
443443
....: update_optional_tags(' sage: also_already_aligned() # ne' 'eds scipy',
444444
....: force_rewrite='standard'),
445+
....: update_optional_tags(' sage: two_columns_first_preserved() # long time # ne' 'eds scipy',
446+
....: force_rewrite='standard'),
447+
....: update_optional_tags(' sage: two_columns_first_preserved() # long time # ne' 'eds scipy',
448+
....: force_rewrite='standard'),
445449
....: ])
446450
| V V V V V V v v v v
447451
| sage: unforced() # optional - latte_int
@@ -451,6 +455,8 @@ def update_optional_tags(line, tags=None, *, add_tags=None, remove_tags=None, fo
451455
| sage: aligned_with_below() # optional - 4ti2
452456
| sage: aligned_with_above() # optional - 4ti2
453457
| sage: also_already_aligned() # needs scipy
458+
| sage: two_columns_first_preserved() # long time # needs scipy
459+
| sage: two_columns_first_preserved() # long time # needs scipy
454460
455461
Rewriting a persistent (block-scoped) tag::
456462
@@ -517,21 +523,21 @@ def update_optional_tags(line, tags=None, *, add_tags=None, remove_tags=None, fo
517523
break
518524
line += ' '
519525

520-
if (group['optional'] or group['special']) and (group['standard'] or group['sage']):
521-
# Try if two-column mode works better
522-
first_part = unparse_optional_tags({tag: explanation
523-
for tag, explanation in new_tags.items()
524-
if (tag in group['optional']
525-
or tag in group['special'])})
526-
column = standard_tag_columns[0]
527-
if len(line + first_part) + 8 <= column:
528-
line += first_part
529-
line += ' ' * (column - len(line))
530-
line += unparse_optional_tags({tag: explanation
531-
for tag, explanation in new_tags.items()
532-
if not (tag in group['optional']
533-
or tag in group['special'])})
534-
return line.rstrip()
526+
if (group['optional'] or group['special']) and (group['standard'] or group['sage']):
527+
# Try if two-column mode works better
528+
first_part = unparse_optional_tags({tag: explanation
529+
for tag, explanation in new_tags.items()
530+
if (tag in group['optional']
531+
or tag in group['special'])})
532+
column = standard_tag_columns[0]
533+
if len(line + first_part) + 8 <= column:
534+
line += first_part
535+
line += ' ' * (column - len(line))
536+
line += unparse_optional_tags({tag: explanation
537+
for tag, explanation in new_tags.items()
538+
if not (tag in group['optional']
539+
or tag in group['special'])})
540+
return line.rstrip()
535541

536542
line += unparse_optional_tags(new_tags)
537543
return line

0 commit comments

Comments
 (0)