File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations as _annotations
2
2
3
3
import re
4
+ import difflib
4
5
from subprocess import PIPE , Popen
5
6
from textwrap import indent
6
7
from typing import TYPE_CHECKING
@@ -68,7 +69,9 @@ def replace_offset(m: re.Match):
68
69
69
70
70
71
def code_diff (example : CodeExample , after : str , config : ExamplesConfig ) -> str :
71
- def replace_at_line (match : re .Match ) -> str :
72
+ before_lines = sub_space (example .source , config ).splitlines (keepends = True )
73
+ after_lines = sub_space (after , config ).splitlines (keepends = True )
74
+ diff = '' .join (difflib .unified_diff (before_lines , after_lines , 'before' , 'after' ))
72
75
offset = re .sub (r'\d+' , lambda m : str (int (m .group (0 )) + example .start_line ), match .group (2 ))
73
76
return f'{ match .group (1 )} { offset } { match .group (3 )} '
74
77
You can’t perform that action at this time.
0 commit comments