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

tweak, and heavily add comments to the Extutils::ParseXS code #22445

Merged
merged 6 commits into from
Aug 2, 2024

Conversation

iabyn
Copy link
Contributor

@iabyn iabyn commented Jul 30, 2024

A few trivial commits, followed by one huge commit which adds many code comments to ParseXS.pm and related files.

@iabyn
Copy link
Contributor Author

iabyn commented Jul 30, 2024

For anyone reviewing this PR: note that in the last commit ("add many code comments"), GH by default hides the huge diff against ParseXS.pm because it's too big. So it's easy to miss.

# Note that the pod for this module is separate in ParseXS.pod.
#
# This module provides the guts for the xsubpp XS-to-C translator utility.
# By having it as a module separate from xsubpp, it makes it easier to
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an important advantage, but to the best of my knowledge that's not why most of the code was moduled out. The direct cause was making it more usable from Module::Build and friends (so they don't have to shell out).


=over 4
=item C<<$self->death(@messages)>>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not rendering correctly in POD formatters like perldoc or pod2text. You are trying to say $self-> but it's only coming out as $self-. I believe the tip of the arrow needs to be an escaped greater-than sign. The same problem occurs in these instances:

$ pod2text < dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm | ack '\$self-(?!>)'
        conditional nesting. In particular, it updates "@{$self-"{XSStack}}>
    "<$self-"Warn(@messages)>>
    "<$self-"blurt(@messages)>>
    "<$self-"death(@messages)>>
    "<$self-"WarnHint(@messages, $hints)>>
        Warn if the lines in "@{ $self-"{line} }> don't have balanced "#if",

Copy link
Contributor

Choose a reason for hiding this comment

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

The issue is that the syntax to use the double-chevron POD escape is: C<< ... >> - there must be whitespace after the double chevron. Otherwise it is parsed as C<...>death(@messages)>>, where the part in the code escape is only <$self-.

=item * Arguments
It is used for something like a syntax error, where parsing can't
continue. However, this is inconvenient for testing purposes, as the
error can't be trapped. So if <$self> is created with the C<die_on_error>
Copy link
Contributor

Choose a reason for hiding this comment

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

is <$self> meant to be C<$self> ?


=item * Return Value
This is a more obscure twin to C<Warn>, which does the same as C<Warn>,
but afterwards, outputs any lines contained in the <$hints> string, with
Copy link
Contributor

Choose a reason for hiding this comment

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

C<> for $hints too

@iabyn iabyn force-pushed the davem/xscomments branch from 7244f64 to ddfb833 Compare August 1, 2024 11:03
@iabyn
Copy link
Contributor Author

iabyn commented Aug 1, 2024

All comments so far have been addressed; rebased and pushed.

Copy link
Contributor

@jkeenan jkeenan left a comment

Choose a reason for hiding this comment

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

My concerns re POD formatting have been addressed. @Grinnz's diagnosis was correct.

iabyn added 6 commits August 2, 2024 09:33
It's easy to confuse these two:

    XS::Typemap
    ExtUtils::Typemaps

Update the description of the XS::Typemap files in MANIFEST to aid
in deconfusion.
Add a few lines to the top of this file explaining what its purpose is.
Crude tool to collect before and after snapshots of all .c files created
by xsubpp, in order to see what (if anything) has changed in
functionality while working on ParseXS files.
Consolidate the POD for the various warning- and error-raising methods
into a single block of text, to give a better overview of which method
should be used when (e.g. warning vs deferred errors vs die immediately)

The diff looks confusing, but its basically deleting the individual
chunk of pod directly above each method, then adding a complete new
block of pod. This contains completely new text, rather than copying
and pasting.
To aid the understanding of this module and its sub-modules:

 - add lots of code comments
 - add blank lines
 - reformat and/or line-wrap a few long code lines

There should be no functional changes.

In particular, the line count of ParseXS.pm is increased by about 60%
with this commit.

I've tried to consistently use the word 'emit' rather than 'print' or
'output' in comments about the code that gets generated and ends up in
the .c file. At the moment most of this code code is indeed just
immediately printed to STDOUT, but in the longer term I would like to
separate out code generation and output stages.
@iabyn iabyn force-pushed the davem/xscomments branch from ddfb833 to 82436f9 Compare August 2, 2024 08:40
@iabyn iabyn merged commit 2595cc7 into blead Aug 2, 2024
67 checks passed
@iabyn iabyn deleted the davem/xscomments branch August 2, 2024 09:50
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.

5 participants