git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] doc: don't require a SYNOPSIS in section 7

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 4, 2026, 13:17 UTC
Message-ID
<xmqqece5vc48.fsf@gitster.g>
In-Reply-To
<pull.2246.v2.git.1791033057232.gitgitgadget@gmail.com>
"Julia Evans via GitGitGadget" <gitgitgadget@gmail.com> writes:
>     Changes in v2: Tuomas rewrote the Perl script changes to be both more
>     declarative and and more correct. Previously it didn't work if there
>     were multiple files passed on the command line.
Show 25 quoted lines
> diff --git a/Documentation/lint-man-section-order.perl b/Documentation/lint-man-section-order.perl
> index 02408a0062..160c65e1be 100755
> --- a/Documentation/lint-man-section-order.perl
> +++ b/Documentation/lint-man-section-order.perl
> @@ -13,6 +13,9 @@ my %SECTIONS;
>  		},
>  		'SYNOPSIS' => {
>  			required => 1,
> +			optional_in_man_sections => {
> +				'7' => 1,
> +			},
>  			order => $order++,
>  		},
>  		'DESCRIPTION' => {
> @@ -53,10 +56,18 @@ sub report {
>  	$exit_code = 1;
>  }
>  
> +my $man_section_number;
>  my $last_was_section;
>  my @actual_order;
>  while (my $line = <>) {
>  	chomp $line;
> +
> +	if ($. == 1) {

OK, this, together with the explicit "close ARGV" later in postcontext upon seeing eof, lets us do a "special" thing on the first line.

I think for the purpose of "doc lint", this implementation is good enough, especially with documented "assumption".

If we wanted to shoot for a bit more robustness, on the other hand, we would want to handle when $1 is left undef ...

> +		# assume the first line is formatted like 'gitglossary(7)'
> +		$line =~ m/\((\d)\)/;
> +		$man_section_number = $1;
... here.  Perhaps like
	$man_section_number = ($line =~ /\((\d)\)/) ? $1 : "0";
If we left $man_section_number undef, ...
Show 10 quoted lines
>  	if ($line =~ $SECTION_RX) {
>  		push @actual_order => $line;
>  		$last_was_section = 1;
> @@ -92,7 +103,9 @@ while (my $line = <>) {
>  		@actual_sections{@actual_order} = ();
>  
>  		for my $section (sort keys %SECTIONS) {
> -			next if !$SECTIONS{$section}->{required} or exists $actual_sections{$section};
> +			next if !$SECTIONS{$section}->{required} or
> +				$SECTIONS{$section}->{optional_in_man_sections}->{$man_section_number} or
... this will access
	$SECTIONS{$section}->{optional_in_man_sections}->{undef}
and may trigger a warning on use of uninitialized value.  

Also, this would autovivify $SECTIONS{*}{optional_in_man_sections} for sections that don't have optional_in_man_sections hash (like NAME and DESCRIPTION), which may be harmless but needless.

Previous: Julia Evans via GitGitGadgetNext: Julia Evans
Message 11 of 15 in “doc: don't require a SYNOPSIS in section 7”
  1. doc: don't require a SYNOPSIS in section 7Julia Evans via GitGitGadget, Oct 2, 2026
  2. Junio C HamanoOct 2, 2026
  3. Junio C HamanoOct 2, 2026
  4. Julia EvansOct 2, 2026
  5. Julia EvansOct 2, 2026
  6. Junio C HamanoOct 2, 2026
  7. Tuomas AholaOct 3, 2026
  8. Julia EvansOct 3, 2026
  9. Tuomas AholaOct 3, 2026
  10. doc: don't require a SYNOPSIS in section 7Julia Evans via GitGitGadget, Oct 3, 2026
  11. Junio C HamanoOct 4, 2026
  12. Julia EvansOct 6, 2026
  13. Junio C HamanoOct 6, 2026
  14. doc: don't require a SYNOPSIS in section 7Julia Evans via GitGitGadget, Oct 6, 2026
  15. Junio C HamanoOct 6, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.