Skip to content

Proper alignment for diff rendering #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
angely-dev opened this issue Mar 8, 2023 · 0 comments
Closed

Proper alignment for diff rendering #2

angely-dev opened this issue Mar 8, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@angely-dev
Copy link
Owner

The current diff rendering may be confusing:

hostname R1
interface FastEthernet0/0
 description LAN
 no ip address
 shutdown
 duplex auto
 speed auto
+ no shutdown
router bgp 64512
 neighbor 172.16.0.1 remote-as 100
 address-family ipv4
  neighbor 172.16.0.1 activate
  neighbor 172.16.0.1 prefix-list IN in
  neighbor 172.16.0.1 prefix-list OUT out
+  neighbor 172.16.0.1 allowas-in 1
+  network 192.168.1.0 mask 255.255.255.0
ip prefix-list IN seq 5 permit 192.168.2.0/24
ip prefix-list OUT seq 5 permit 192.168.1.0/24
+no ip domain lookup
+interface FastEthernet0/0.10
+ description LAN
+ encapsulation dot1Q 10
+ ip address 192.168.1.254 255.255.255.0

This could lead to think that some of the new items are nested in existing ones. Adding an extra space for non-plus lines will result in a proper alignment:

 hostname R1
 interface FastEthernet0/0
  description LAN
  no ip address
  shutdown
  duplex auto
  speed auto
+ no shutdown
 router bgp 64512
  neighbor 172.16.0.1 remote-as 100
  address-family ipv4
   neighbor 172.16.0.1 activate
   neighbor 172.16.0.1 prefix-list IN in
   neighbor 172.16.0.1 prefix-list OUT out
+  neighbor 172.16.0.1 allowas-in 1
+  network 192.168.1.0 mask 255.255.255.0
 ip prefix-list IN seq 5 permit 192.168.2.0/24
 ip prefix-list OUT seq 5 permit 192.168.1.0/24
+no ip domain lookup
+interface FastEthernet0/0.10
+ description LAN
+ encapsulation dot1Q 10
+ ip address 192.168.1.254 255.255.255.0

Actually, this is what GitHub does in its diff rendering (e.g., 03a24ab).

This enhancement requires to:

  • Change the IncrementalDiff._to_str() method
  • Update the unit tests
  • Update the diff outputs on the documentation
@angely-dev angely-dev added the enhancement New feature or request label Mar 8, 2023
@angely-dev angely-dev added this to the 1.2.0 milestone Mar 8, 2023
@angely-dev angely-dev self-assigned this Mar 8, 2023
angely-dev added a commit that referenced this issue Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant