Skip to content

Conversation

finanalyst
Copy link
Collaborator

The problem

In the pod sources there are multiple uses of what appears to be a non-cannonical link, eg. L<Iterable>.

The pod description doc/Language/pod.pod6 and S26 would indicate that this should be a link to the local source Iterable.pod6. Instead the link is automagically converted by the doc system into a html link /type/iterable.

There is no indication that I can find to indicate why a single word link should be converted to point at a file in the arbitrary subdirectory html/type

Solution provided

Consequently, I have written a short program to convert any L<link> where link matches \w+ into L<link|/type/link> and any link of the form L<description|link> to L<description|/type/link>. The program is given below.

The changes in this PR are the result of these alterations.

I have run make html; make xtest and checked that individual links that I manually identified continue to work as before. (make xtest throws up a number of failure from xt/ directory tests, but none of these appear to be a consequence of the changes in this commit.

#! /usr/bin/env perl6
use v6.c;

my  $top-dir = '../perl6-doc/doc/';
#my $url = 'https\:\/\/docs\.perl6\.org';
my @extensions = <pod pod6>;

#| Recursively finds all pod files
my @pods = my sub recurse ($dir) {
     gather for dir($dir) {
         take .Str if  .extension ~~ any( @extensions );
         take slip sort recurse $_ if .d;
     }
}($top-dir); # is the first definition of $dir
my SetHash $tainted-files .= new;
for @pods -> $p {
    my @file = $p.IO.lines;
    my $tainted = False;
    for @file {
        next unless m/ 'L<' \w+ '>' /;
        s:g[ 'L<'~'>' (\w+) ] = "L<$0|\/type\/$0>";
        s:g[ 'L<' ~ '>' [ (.+) '|' (\w+)] ] = "L<$0|/type/$1>";
        $tainted = True;
    }
    $p.IO.spurt(@file.join("\n")) if $tainted;
    say "Changed: $p" if $tainted;
    $tainted-files{ ~$p }++ if $tainted;
}
'tainted-files'.IO.spurt: $tainted-files.keys.join("\n")

@finanalyst finanalyst requested a review from JJ December 20, 2018 17:31
Copy link
Contributor

@JJ JJ left a comment

Choose a reason for hiding this comment

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

If there's some error, must not be a big one. It probably makes sense, and it will make also sense to eliminate the htmlify.p6 part that does this...

@JJ JJ merged commit c5fb804 into Raku:master Dec 20, 2018
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.

2 participants