Skip to content

Commit 10d333e

Browse files
pks-tgitster
authored andcommitted
Documentation: teach "cmd-list.perl" about out-of-tree builds
The "cmd-list.perl" script generates a list of commands that can be included into our manpages. The script doesn't know about out-of-tree builds and instead writes resulting files into the source directory. Adapt it such that we can read data from the source directory and write data into the build directory. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1a63c39 commit 10d333e

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

Documentation/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ cmds_txt = cmds-ancillaryinterrogators.txt \
306306
$(cmds_txt): cmd-list.made
307307

308308
cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
309-
$(QUIET_GEN)$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(cmds_txt) $(QUIET_STDERR) && \
309+
$(QUIET_GEN)$(PERL_PATH) ./cmd-list.perl .. . $(cmds_txt) && \
310310
date >$@
311311

312312
mergetools_txt = mergetools-diff.txt mergetools-merge.txt

Documentation/cmd-list.perl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
use File::Compare qw(compare);
44

55
sub format_one {
6-
my ($out, $nameattr) = @_;
6+
my ($source_dir, $out, $nameattr) = @_;
77
my ($name, $attr) = @$nameattr;
8+
my ($path) = "$source_dir/Documentation/$name.txt";
89
my ($state, $description);
910
my $mansection;
1011
$state = 0;
11-
open I, '<', "$name.txt" or die "No such file $name.txt";
12+
open I, '<', "$path" or die "No such file $path.txt";
1213
while (<I>) {
1314
if (/^(?:git|scalar)[a-z0-9-]*\(([0-9])\)$/) {
1415
$mansection = $1;
@@ -29,7 +30,7 @@ sub format_one {
2930
}
3031
close I;
3132
if (!defined $description) {
32-
die "No description found in $name.txt";
33+
die "No description found in $path.txt";
3334
}
3435
if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) {
3536
print $out "linkgit:$name\[$mansection\]::\n\t";
@@ -43,9 +44,9 @@ sub format_one {
4344
}
4445
}
4546

46-
my ($input, @categories) = @ARGV;
47+
my ($source_dir, $build_dir, @categories) = @ARGV;
4748

48-
open IN, "<$input";
49+
open IN, "<$source_dir/command-list.txt";
4950
while (<IN>) {
5051
last if /^### command list/;
5152
}
@@ -63,17 +64,17 @@ sub format_one {
6364

6465
for my $out (@categories) {
6566
my ($cat) = $out =~ /^cmds-(.*)\.txt$/;
66-
open O, '>', "$out+" or die "Cannot open output file $out+";
67+
my ($path) = "$build_dir/$out";
68+
open O, '>', "$path+" or die "Cannot open output file $out+";
6769
for (@{$cmds{$cat}}) {
68-
format_one(\*O, $_);
70+
format_one($source_dir, \*O, $_);
6971
}
7072
close O;
7173

72-
if (-f "$out" && compare("$out", "$out+") == 0) {
73-
unlink "$out+";
74+
if (-f "$path" && compare("$path", "$path+") == 0) {
75+
unlink "$path+";
7476
}
7577
else {
76-
print STDERR "$out\n";
77-
rename "$out+", "$out";
78+
rename "$path+", "$path";
7879
}
7980
}

0 commit comments

Comments
 (0)