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

podcheck.t: Fix multiple link targets bug #22771

Merged
merged 5 commits into from
Nov 28, 2024

Conversation

khwilliamson
Copy link
Contributor

podcheck.t would wrongly warn about duplicate link targets. It is
ambiguous if you have, say

=head1 foo
...
=item foo

and then try to create a link to 'foo'. Which 'foo' should it go to?
So podcheck looks for such ambiguous links. However, it was incorrectly
warning on

=head1 foo
...
=item * foo

The latter is a bullet list, which is not an appropriate link target.
The logic was flawed in the node() method, when it encountered the
second foo, it didn't realize it was for a bullet list, and pushed it
onto a list which caused the count to be larger than 1, which caused it
later to think there were two link targets with the same name.

The solution here is to instead note that linkable targets are only in
=headN or definition lists. The acquisition of the names of them are
moved to the methods that get called upon the termination of each of
these by the parsing routines. The count is incremented at that point.
This means the node() method extension no longer does anything useful
and is removed; as well as an auxiliary field, linkable_item. We no
longer need to distinguish between =headN and =item.

  • This set of changes does not require a perldelta entry.

end_head1() extends SUPER::end_head1().  So call that.  It turns out
that this didn't matter currently, but is bad practice.
Prior to this commit, the resetting of certain variables was done just
for =head1.  But there is nothing special about this level for these
variables, so do it for all.
podcheck looks through the source distribution for pod.  It skips
internal checking of ones in /cpan (unless a command line option says
to.  If you do this, be prepared for finding gobs of problems in
these!).

But any such module found is fair game to be linked to by modules we do
examine.  It is a simple matter to add them to the list of known modules
that can be linked to.

Prior to this commit this was done surreptitiously by extending the
Pod::Checker node() method.  But a future commit will take this away.
podcheck.t would wrongly warn about duplicate link targets.  It is
ambiguous if you have, say

 =head1 foo
 ...
 =item foo

and then try to create a link to 'foo'.  Which 'foo' should it go to?
So podcheck looks for such ambiguous links.  However, it was incorrectly
warning on

 =head1 foo
 ...
 =item * foo

 The latter is a bullet list, which is not an appropriate link target.
 The logic was flawed in the node() method, when it encountered the
 second foo, it didn't realize it was for a bullet list, and pushed it
 onto a list which caused the count to be larger than 1, which caused it
 later to think there were two link targets with the same name.

 The solution here is to instead note that linkable targets are only in
 =headN or definition lists.  The acquisition of the names of them are
 moved to the methods that get called upon the termination of each of
 these by the parsing routines.  The count is incremented at that point.
 This means the node() method extension no longer does anything useful
 and is removed; as well as an auxiliary field, linkable_item.  We no
 longer need to distinguish between =headN and =item.
@khwilliamson khwilliamson merged commit 6366047 into Perl:blead Nov 28, 2024
34 checks passed
@khwilliamson khwilliamson deleted the podcheck branch November 28, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant