Skip to content

Commit 9ca7f29

Browse files
committed
add support for copying head3 sections
1 parent b70c31e commit 9ca7f29

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

Porting/merge-deltas.pl

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,49 @@ ( $tree, $directive, $pos = 0 )
6262
0, $delta->@[ $from .. $to ];
6363
},
6464

65+
# copy =head3 sections from known =head2 ones
66+
head3 => sub ( $master, $title, $delta ) {
67+
68+
# find the section in the delta and master
69+
my ( $master_pos, $delta_pos ) =
70+
map header_pos( $_, 1, $title ),
71+
$master, $delta;
72+
73+
# loop over the =head2 in the section
74+
while ( $delta_pos = next_header_pos( $delta, 2, $delta_pos ) ) {
75+
76+
my $section_title = $delta->[$delta_pos][2];
77+
$master_pos = # find the same =head2 in the master
78+
header_pos( $master, 2, $section_title, $master_pos );
79+
80+
# find the first =head3
81+
if ( my $from = next_header_pos( $delta, 3, $delta_pos ) ) {
82+
83+
# until the next =head2 or =head1
84+
my $to = next_header_pos( $delta, 2, $from )
85+
// next_header_pos( $delta, 1, $from );
86+
87+
# inject at the end of the =head2 section in the master
88+
my $end_pos = next_header_pos( $master, 2, $master_pos )
89+
// next_header_pos( $master, 1, $master_pos );
90+
splice @$master, $end_pos, 0, $delta->@[ $from .. $to - 1 ];
91+
}
92+
else { # copy the whole section over
93+
94+
# until the next =head2 or =head1
95+
my $to = next_header_pos( $delta, 2, $delta_pos )
96+
// next_header_pos( $delta, 1, $delta_pos );
97+
98+
# inject at the end of the =head2 section in the master
99+
my $end_pos = next_header_pos( $master, 2, $master_pos )
100+
// next_header_pos( $master, 1, $master_pos );
101+
splice @$master, $end_pos, 0,
102+
$delta->@[ $delta_pos + 1 .. $to - 1 ];
103+
}
104+
}
105+
continue { ++$delta_pos } # avoid an infinite loop
106+
},
107+
65108
# [ List each improvement as an =item entry ]
66109
item => sub ( $master, $title, $delta ) {
67110

@@ -149,7 +192,7 @@ ( $tree, $directive, $pos = 0 )
149192
'Deprecations' => 'deprecations',
150193
'Performance Enhancements' => 'item',
151194
'Modules and Pragmata' => 'skip',
152-
'Documentation' => 'skip',
195+
'Documentation' => 'head3',
153196
'Diagnostics' => 'skip',
154197
'Utility Changes' => 'head2',
155198
'Configuration and Compilation' => 'item',

0 commit comments

Comments
 (0)