@@ -424,9 +424,23 @@ def __init__(
424424 name : str | None = None ,
425425 id : str | None = None ,
426426 classes : str | None = None ,
427- disabled : bool = False ,
428427 ):
429- super ().__init__ (name = name , id = id , classes = classes , disabled = disabled )
428+ """Initialize diff view.
429+
430+ Args:
431+ path_original: Path to original code.
432+ path_modified: Path to modified code.
433+ code_original: Original code.
434+ code_modified: Modified code.
435+ split: Enable split view?
436+ annotations: Enable annotations ("+" and "-")?
437+ auto_split: Automatically enable split view if it fits?
438+ wrap: Wrap code (rather than horizontal scroll)?
439+ name: Textual CSS name.
440+ id: Textual CSS id.
441+ classes: Textual CSS classes.
442+ """
443+ super ().__init__ (name = name , id = id , classes = classes )
430444 self .set_reactive (DiffView .path_original , path_original )
431445 self .set_reactive (DiffView .path_modified , path_modified )
432446 self .set_reactive (DiffView .code_original , code_original .expandtabs ())
@@ -462,6 +476,13 @@ async def load(
462476 Args:
463477 path_original: A str or Path to the original file.
464478 path_modified: A str or Path to the modified file.
479+ split: Enable split view?
480+ annotations: Enable annotations ("+" and "-")?
481+ auto_split: Automatically enable split view if it fits?
482+ wrap: Wrap code (rather than horizontal scroll)?
483+ name: Textual CSS name.
484+ id: Textual CSS id.
485+ classes: Textual CSS classes.
465486
466487 Raises:
467488 OSError: If the file could not be loaded.
@@ -501,11 +522,8 @@ def read(path: Path) -> str:
501522 name = name ,
502523 id = id ,
503524 classes = classes ,
504- disabled = disabled ,
505525 )
506-
507526 await diff_view .prepare ()
508-
509527 return diff_view
510528
511529 async def prepare (self ) -> None :
@@ -677,12 +695,15 @@ async def on_mount(self) -> None:
677695 self ._check_auto_split (self .size .width )
678696
679697 def compose_unified (self ) -> ComposeResult :
698+ """Compose unified view."""
699+ # Branch for wrapping
680700 if self .wrap :
681701 yield from self ._compose_unified_wrap ()
682702 else :
683703 yield from self ._compose_unified ()
684704
685705 def _compose_unified (self ) -> ComposeResult :
706+ """Compose unified view (no wrapping)."""
686707 lines_a , lines_b = self .highlighted_code_lines
687708
688709 for last , group in loop_last (self .grouped_opcodes ):
@@ -823,6 +844,7 @@ def _make_continuations(self, width: int) -> Mapping[str, Content]:
823844 return continuations
824845
825846 def _compose_unified_wrap (self ) -> ComposeResult :
847+ """Compose unified view with wrapping."""
826848 lines_a , lines_b = self .highlighted_code_lines
827849
828850 for last , group in loop_last (self .grouped_opcodes ):
@@ -918,12 +940,15 @@ def _compose_unified_wrap(self) -> ComposeResult:
918940 yield Ellipsis ("⋮" )
919941
920942 def compose_split (self ) -> ComposeResult :
943+ """Compose split view"""
944+ # Branch for wrapping
921945 if self .wrap :
922946 yield from self ._compose_split_wrap ()
923947 else :
924948 yield from self ._compose_split ()
925949
926950 def _compose_split (self ) -> ComposeResult :
951+ """Compose the split view (no wrapping)."""
927952 lines_a , lines_b = self .highlighted_code_lines
928953
929954 annotation_hatch = Content .styled ("╲" * 3 , "$foreground 15%" )
@@ -1064,6 +1089,7 @@ def format_number(line_no: int | None, annotation: str) -> Content:
10641089 yield Ellipsis ("⋮" )
10651090
10661091 def _compose_split_wrap (self ) -> ComposeResult :
1092+ """Compse split view with wrapping."""
10671093 lines_a , lines_b = self .highlighted_code_lines
10681094
10691095 annotation_hatch = Content .styled ("╲" * 3 , "$foreground 15%" )
0 commit comments