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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 2, 2026, 21:34 UTC
Message-ID
<xmqqo6dbvlaf.fsf@gitster.g>
In-Reply-To
<01891b4b-ce04-41aa-8065-d7b88e466dbc@app.fastmail.com>
"Julia Evans" <julia@jvns.ca> writes:
Show 21 quoted lines
>> +# assume the first line is formatted like 'gitglossary(7)'
>> +my $firstline = <>;
>> +$firstline =~ m/\((\d)\)/;
>> +my $man_section_number = $1;
>> +
>>  my $last_was_section;
>>  my @actual_order;
>>  while (my $line = <>) {
>> @@ -93,6 +98,8 @@ while (my $line = <>) {
>> 
>>  		for my $section (sort keys %SECTIONS) {
>>  			next if !$SECTIONS{$section}->{required} or exists 
>> $actual_sections{$section};
>> +			# Synopsis is not required in section 7
>> +			next if ($section eq "SYNOPSIS" && $man_section_number eq "7");
>>  			report("has no required '$section' section!");
>>  		}
>
>
> I just realized that this script is actually supposed to be able to process multiple
> files as command line arguments, and that this patch won't work for that.

Yeah, your version would then notice only the first line of the first file, and my update would also do the same.

You can work from what I gave you and inside the "eof" part of the loop reset the %SECTIONS back to the original (which means you'd need to keep a separate copy of the original) and also reset the "did I tweak the %SECTIONS thing already? have I handled the first line of the current file?" variable.

> I don't understand how Perl's `<>`  works when you pass multiple files as
> command line arguments and that might be too much of a can of worms for me to
> figure right now :/

"man perlfunc" section on "eof" has an example to show what to detect and reset when you reached the end of each file within a "while (<>)" loop.

               # reset line numbering on each input file
               while (<>) {
                   next if /^\s*#/;  # skip comments
                   print "$.\t$_";
               } continue {
                   close ARGV if eof;  # Not eof()!
               }

The explicit "close ARGV if eof;" is how the example resets the $. counter (which by default counts all the lines coming from <> across multiple files).

Previous: Julia EvansNext: Tuomas Ahola
Message 6 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.