diff mbox series

[3/3] git.txt: add list of guides

Message ID 9374d80f0c37a6b6a7f5f76601ee757f89712d0c.1596381647.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series List all guides in git(1) | expand

Commit Message

Linus Arver via GitGitGadget Aug. 2, 2020, 3:20 p.m. UTC
From: Philippe Blain <levraiphilippeblain@gmail.com>

Not all guides are mentioned in the 'git(1)' documentation,
which makes the missing ones somewhat hard to find.

Add a list of the guides to git(1).

Tweak `Documentation/cmd-list.perl` so that it also generates
a file `cmds-guide.txt` which gets included in git.txt.

Also, do not hard-code the manual section '1'. Instead, use a regex so
that the manual section is discovered from the first line of each
`git*.txt` file.

This addition was hinted at in 1b81d8cb19 (help: use command-list.txt for
the source of guides, 2018-05-20).

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
 Documentation/cmd-list.perl | 10 ++++++++--
 Documentation/git.txt       |  7 +++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

Comments

Junio C Hamano Aug. 2, 2020, 9:44 p.m. UTC | #1
"Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Philippe Blain <levraiphilippeblain@gmail.com>
>
> Not all guides are mentioned in the 'git(1)' documentation,
> which makes the missing ones somewhat hard to find.
>
> Add a list of the guides to git(1).
>
> Tweak `Documentation/cmd-list.perl` so that it also generates
> a file `cmds-guide.txt` which gets included in git.txt.

Who cleans this?  Do we need a change to Makefile?
Junio C Hamano Aug. 2, 2020, 10:05 p.m. UTC | #2
Junio C Hamano <gitster@pobox.com> writes:

> "Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> From: Philippe Blain <levraiphilippeblain@gmail.com>
>>
>> Not all guides are mentioned in the 'git(1)' documentation,
>> which makes the missing ones somewhat hard to find.
>>
>> Add a list of the guides to git(1).
>>
>> Tweak `Documentation/cmd-list.perl` so that it also generates
>> a file `cmds-guide.txt` which gets included in git.txt.
>
> Who cleans this?  Do we need a change to Makefile?

A band-aid patch would look like this, BUT.

    diff --git a/Documentation/Makefile b/Documentation/Makefile
    index 39f6fc8de7..616449da88 100644
    --- a/Documentation/Makefile
    +++ b/Documentation/Makefile
    @@ -295,6 +295,7 @@ cmds_txt = cmds-ancillaryinterrogators.txt \
            cmds-plumbingmanipulators.txt \
            cmds-synchingrepositories.txt \
            cmds-synchelpers.txt \
    +       cmds-guide.txt \
            cmds-purehelpers.txt \
            cmds-foreignscminterface.txt

I think with a bit more work, we can be at a lot better place.  How
about something along the following line (untested)?

 Documentation/Makefile      |  3 ++-
 Documentation/cmd-list.perl | 21 ++++++++-------------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 39f6fc8de7..80d1908a44 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -295,6 +295,7 @@ cmds_txt = cmds-ancillaryinterrogators.txt \
 	cmds-plumbingmanipulators.txt \
 	cmds-synchingrepositories.txt \
 	cmds-synchelpers.txt \
+	cmds-guide.txt \
 	cmds-purehelpers.txt \
 	cmds-foreignscminterface.txt
 
@@ -302,7 +303,7 @@ $(cmds_txt): cmd-list.made
 
 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
 	$(QUIET_GEN)$(RM) $@ && \
-	$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
+	$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(cmds_txt) $(QUIET_STDERR) && \
 	date >$@
 
 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
index 99f01a0910..af5da45d28 100755
--- a/Documentation/cmd-list.perl
+++ b/Documentation/cmd-list.perl
@@ -43,12 +43,15 @@ sub format_one {
 	}
 }
 
-while (<>) {
+my ($input, @categories) = @ARGV;
+
+open IN, "<$input";
+while (<IN>) {
 	last if /^### command list/;
 }
 
 my %cmds = ();
-for (sort <>) {
+for (sort <IN>) {
 	next if /^#/;
 
 	chomp;
@@ -56,18 +59,10 @@ sub format_one {
 	$attr = '' unless defined $attr;
 	push @{$cmds{$cat}}, [$name, " $attr "];
 }
+close IN;
 
-for my $cat (qw(ancillaryinterrogators
-		ancillarymanipulators
-		mainporcelain
-		plumbinginterrogators
-		plumbingmanipulators
-		synchingrepositories
-		foreignscminterface
-		purehelpers
-		synchelpers
-		guide)) {
-	my $out = "cmds-$cat.txt";
+for my $out (@categories) {
+	my ($cat) = $out =~ /^cmds-(.*)\.txt$/;
 	open O, '>', "$out+" or die "Cannot open output file $out+";
 	for (@{$cmds{$cat}}) {
 		format_one(\*O, $_);
Philippe Blain Aug. 3, 2020, 2:16 p.m. UTC | #3
Hi Junio, 

> Le 2 août 2020 à 18:05, Junio C Hamano <gitster@pobox.com> a écrit :
> 
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> "Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com> writes:
>> 
>>> From: Philippe Blain <levraiphilippeblain@gmail.com>
>>> 
>>> Not all guides are mentioned in the 'git(1)' documentation,
>>> which makes the missing ones somewhat hard to find.
>>> 
>>> Add a list of the guides to git(1).
>>> 
>>> Tweak `Documentation/cmd-list.perl` so that it also generates
>>> a file `cmds-guide.txt` which gets included in git.txt.
>> 
>> Who cleans this?  Do we need a change to Makefile?

Oups! I checked /.gitignore, but forgot to thoroughly check the Makefile.

> 
> A band-aid patch would look like this, BUT.
> 
>    diff --git a/Documentation/Makefile b/Documentation/Makefile
>    index 39f6fc8de7..616449da88 100644
>    --- a/Documentation/Makefile
>    +++ b/Documentation/Makefile
>    @@ -295,6 +295,7 @@ cmds_txt = cmds-ancillaryinterrogators.txt \
>            cmds-plumbingmanipulators.txt \
>            cmds-synchingrepositories.txt \
>            cmds-synchelpers.txt \
>    +       cmds-guide.txt \
>            cmds-purehelpers.txt \
>            cmds-foreignscminterface.txt
> 
> I think with a bit more work, we can be at a lot better place.  How
> about something along the following line (untested)?
> 
> Documentation/Makefile      |  3 ++-
> Documentation/cmd-list.perl | 21 ++++++++-------------
> 2 files changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index 39f6fc8de7..80d1908a44 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -295,6 +295,7 @@ cmds_txt = cmds-ancillaryinterrogators.txt \
> 	cmds-plumbingmanipulators.txt \
> 	cmds-synchingrepositories.txt \
> 	cmds-synchelpers.txt \
> +	cmds-guide.txt \
> 	cmds-purehelpers.txt \
> 	cmds-foreignscminterface.txt
> 
> @@ -302,7 +303,7 @@ $(cmds_txt): cmd-list.made
> 
> cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
> 	$(QUIET_GEN)$(RM) $@ && \
> -	$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
> +	$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(cmds_txt) $(QUIET_STDERR) && \
> 	date >$@
> 
> mergetools_txt = mergetools-diff.txt mergetools-merge.txt
> diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
> index 99f01a0910..af5da45d28 100755
> --- a/Documentation/cmd-list.perl
> +++ b/Documentation/cmd-list.perl
> @@ -43,12 +43,15 @@ sub format_one {
> 	}
> }
> 
> -while (<>) {
> +my ($input, @categories) = @ARGV;
> +
> +open IN, "<$input";
> +while (<IN>) {
> 	last if /^### command list/;
> }
> 
> my %cmds = ();
> -for (sort <>) {
> +for (sort <IN>) {
> 	next if /^#/;
> 
> 	chomp;
> @@ -56,18 +59,10 @@ sub format_one {
> 	$attr = '' unless defined $attr;
> 	push @{$cmds{$cat}}, [$name, " $attr "];
> }
> +close IN;
> 
> -for my $cat (qw(ancillaryinterrogators
> -		ancillarymanipulators
> -		mainporcelain
> -		plumbinginterrogators
> -		plumbingmanipulators
> -		synchingrepositories
> -		foreignscminterface
> -		purehelpers
> -		synchelpers
> -		guide)) {
> -	my $out = "cmds-$cat.txt";
> +for my $out (@categories) {
> +	my ($cat) = $out =~ /^cmds-(.*)\.txt$/;
> 	open O, '>', "$out+" or die "Cannot open output file $out+";
> 	for (@{$cmds{$cat}}) {
> 		format_one(\*O, $_);

Thanks for the suggestion. I tested it and it works correctly. 
I've incorporated it to v2.


Philippe.
diff mbox series

Patch

diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
index 5aa73cfe45..99f01a0910 100755
--- a/Documentation/cmd-list.perl
+++ b/Documentation/cmd-list.perl
@@ -6,9 +6,14 @@  sub format_one {
 	my ($out, $nameattr) = @_;
 	my ($name, $attr) = @$nameattr;
 	my ($state, $description);
+	my $mansection;
 	$state = 0;
 	open I, '<', "$name.txt" or die "No such file $name.txt";
 	while (<I>) {
+		if (/^git[a-z0-9-]*\(([0-9])\)$/) {
+			$mansection = $1;
+			next;
+		}
 		if (/^NAME$/) {
 			$state = 1;
 			next;
@@ -27,7 +32,7 @@  sub format_one {
 		die "No description found in $name.txt";
 	}
 	if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) {
-		print $out "linkgit:$name\[1\]::\n\t";
+		print $out "linkgit:$name\[$mansection\]::\n\t";
 		if ($attr =~ / deprecated /) {
 			print $out "(deprecated) ";
 		}
@@ -60,7 +65,8 @@  sub format_one {
 		synchingrepositories
 		foreignscminterface
 		purehelpers
-		synchelpers)) {
+		synchelpers
+		guide)) {
 	my $out = "cmds-$cat.txt";
 	open O, '>', "$out+" or die "Cannot open output file $out+";
 	for (@{$cmds{$cat}}) {
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 3e50065198..81349a84e7 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -304,6 +304,13 @@  users typically do not use them directly.
 
 include::cmds-purehelpers.txt[]
 
+Guides
+------
+
+The following documentation pages are guides about Git concepts.
+
+include::cmds-guide.txt[]
+
 
 Configuration Mechanism
 -----------------------