Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autodoc: Handle apidoc continuation lines #22373

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions autodoc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,26 @@ ($$)

my $file_is_C = $file =~ / \. [ch] $ /x;

# Count lines easier
my $get_next_line = sub { $line_num++; return <$fh> };
# Count lines easier and handle apidoc continuation lines
my $get_next_line = sub {
my $contents = <$fh>;
return unless defined $contents;

$line_num++;
while ($contents =~ s/ ^ ( =for \ apidoc .*) \s* \\ \n /$1/x) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows only a single space between =for and apidoc, but the match in the loop below allows 1 or multiple.

This line should remove the \n but you also chomp below.

It might be good to allow extra whitespace between the \\ and the newline to avoid trailing whitespace looking like it should continue to a person reading the code, while autodoc.pl doesn't treat it as one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These points have made me close this request, and integrate the relevant portions into some commits in #22377

my $next = <$fh>;
last unless defined $next;
chomp $contents;

$line_num++;
$contents .= $next;
}

# Read the file
while ($in = $get_next_line->()) {
last unless defined $in;
return $contents;
};

# Read the file
while (defined ($in = $get_next_line->())) {
next unless ( $in =~ / ^ =for [ ]+ apidoc /x
# =head1 lines only have effect in C files
|| ($file_is_C && $in =~ /^=head1/));
Expand Down
Loading