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

Improper X<> in =head #4550

Open
finanalyst opened this issue Jan 16, 2025 · 0 comments
Open

Improper X<> in =head #4550

finanalyst opened this issue Jan 16, 2025 · 0 comments

Comments

@finanalyst
Copy link
Collaborator

tl;dr headings with =head and X<> have several forms, all but three fit a few relatively simple regexes. The three seem to be typos and easily fixed.

The 'Usage' one leads to a loss of text because the rendering regexes do not catch the last X<>, changing the other two have no effect on rendering.

They are

	=head2 X<sub USAGE|Tutorial,USAGE>X<|Tutorial,$*USAGE>
in file: raku-docs/Language/create-cli.rakudoc

	=head2 dbm functionsX<|Other languages,dbm - perlfunc>
in file: raku-docs/Language/5to6-perlfunc.rakudoc

	=head2 __FILE__X<|Other languages,__FILE__ - perlfunc>
in file: raku-docs/Language/5to6-perlfunc.rakudoc

Replace with (respectively)

=head2 X<sub USAGE|Tutorial,USAGE> and X<C«$*USAGE»|Tutorial,$*USAGE>
=head2 X<dbm functions|Other languages,dbm - perlfunc>
=head2 X<__FILE__|Other languages,__FILE__ - perlfunc>

FWIW: The analysis program is as follows (naive regexes to do the analysis quickly)

#!/usr/bin/env raku
use v6.d;
my $dir = 'raku-docs/';
my @todo = $dir.IO;
my @srcs;
while @todo {
    for @todo.pop.dir -> $path {
        if $path.d {
            @todo.push: $path
        }
        else {
            @srcs.push: $path
        }
    }
}
my %count;
my @unmatched;

my regex head { ^ '=head' \d* \s };
for @srcs -> $fn {
    for $fn.lines {
        next unless m/ <head> /;
        when / <head> <-[<]>+ [ 'X<'] <-[|]>+ '|' <-[>]>+ '>' $ / {
            %count<text-comp-index>.push: $_
        }
        when / <head> 'X«' <-[|]>+ '|' <-[ » ]>+ '»' $ / {
            %count<comp-index-only>.push: $_
        }
        when / <head> 'X<' <-[|]>+ '|' <-[>]>+ '>' $ / {
            %count<comp-index-only>.push: $_
        }
        when / <head> [ 'X<' <-[|]>+ '|' <-[>]>+ '>' [',' \s ]? [\s+ 'and' \s+]? ]+ $ / {
            %count<duplicated-comp-index>.push: $_
        }
        when / <head> [ 'X<' | 'X«' ] <-[>]>+ '>' $ / { 
            %count<simple-index-only>.push: $_
        }
        when / <head> [ 'X<' | 'X«' ] <-[|]>+ '|' <-[>]>+ '>' <-[<]>+  $ / {
            %count<comp-index-text>.push: $_
        }
        when / <head> [ 'X<' | 'X«' ] <-[>]>+ '>' <-[<]>+ $ / { 
            %count<simple-index-text>.push: $_
        }
        when / <head> .*? 'L<' / {
            %count<got-link>.push: $_
        }
        when / <head> .*? [ 'C<' | 'C«' ]/ {
            %count<got-code>.push: $_
        }
        when / <head> 'sub infix:' / {
            %count<infix-foo>.push: $_
        }
        when / <head> [
            '<>' | '$<' | 'I<' | '(<=)' | '(<)'
            | <-[<]>
            ]+ $ / {
            %count<text-only>.push: $_
        }
        default {
            @unmatched.push: [$fn, $_] ;
        }
    }
}
for %count.kv -> $k, $v { say "\n$k"; say "\t$_" for $v.list }
say "\n{+@unmatched} unmatched:";
say "\n\t" ~ .[1] ~ "\nin file: " ~ .[0] for @unmatched;
finanalyst added a commit that referenced this issue Jan 16, 2025
finanalyst added a commit that referenced this issue Jan 16, 2025
dontlaugh pushed a commit that referenced this issue Jan 17, 2025
dontlaugh pushed a commit that referenced this issue Jan 18, 2025
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

No branches or pull requests

1 participant