Skip to content

Commit

Permalink
Attempt to process all pod files
Browse files Browse the repository at this point in the history
Unsure if the right move here is to convert everything to string when needed, or if we
should have converted it to string when trying to save it.
  • Loading branch information
coke committed Apr 18, 2018
1 parent 57d5109 commit 10be05c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
18 changes: 6 additions & 12 deletions htmlify.p6
Expand Up @@ -207,15 +207,9 @@ sub process-pod-dir($dir, :&sorted-by = &[cmp]) {
my $total = +@pod-sources;
my $kind = $dir.lc;
for @pod-sources.kv -> $num, (:key($filename), :value($file)) {
try {
printf "% 4d/%d: % -40s => %s\n", $num+1, $total, $file.path, "$kind/$filename";
my $pod = extract-pod($file.path);
process-pod-source :$kind, :$pod, :$filename, :pod-is-complete;
CATCH {
note "Error Processing: $filename";
.resume;
}
}
printf "% 4d/%d: % -40s => %s\n", $num+1, $total, $file.path, "$kind/$filename";
my $pod = extract-pod($file.path);
process-pod-source :$kind, :$pod, :$filename, :pod-is-complete;
}
}

Expand Down Expand Up @@ -565,7 +559,7 @@ sub find-definitions(:$pod, :$origin, :$min-level = -1, :$url) {

my $new-head = Pod::Heading.new(
:level(@pod-section[$i].level),
:contents[pod-link "($origin.name()) $subkinds $name",
:contents[pod-link "($origin.name()) $subkinds {$name.gist}",
$created.url ~ "#$origin.human-kind() $origin.name()".subst(:g, /\s+/, '_')
]
);
Expand Down Expand Up @@ -674,7 +668,7 @@ sub write-search-file() {
$s.trans([</ \\ ">] => [<\\/ \\\\ \\">]);
}
my @items = $*DR.get-kinds.map(-> $kind {
$*DR.lookup($kind, :by<kind>).categorize({escape .name})\
$*DR.lookup($kind, :by<kind>).categorize({escape .name.gist})\
.pairs.sort({.key}).map: -> (:key($name), :value(@docs)) {
qq[[\{ category: "{
( @docs > 1 ?? $kind !! @docs.[0].subkinds[0] ).wordcase
Expand Down Expand Up @@ -868,7 +862,7 @@ sub write-kind($kind) {
}
.pod[0].contents[0].contents.Str.split(' ')[1] ~ '_';
}
) ~ .name.subst(' ', '_')),
) ~ .name.gist.subst(' ', '_')),
),
.pod.list,
})
Expand Down
18 changes: 9 additions & 9 deletions lib/Perl6/Documentable.pm6
@@ -1,14 +1,14 @@
use URI::Escape;
class Perl6::Documentable {
has Str $.kind; # type, language doc, routine, module
has Str @.subkinds; # class/role/enum, sub/method, prefix/infix/...
has Str @.categories; # basic type, exception, operator...
has $.kind; # type, language doc, routine, module
has @.subkinds; # class/role/enum, sub/method, prefix/infix/...
has @.categories; # basic type, exception, operator...

has Str $.name;
has Str $.url;
has $.name;
has $.url;
has $.pod;
has Bool $.pod-is-complete;
has Str $.summary = '';
has $.pod-is-complete;
has $.summary = '';

# the Documentable that this one was extracted from, if any
has $.origin;
Expand All @@ -33,8 +33,8 @@ class Perl6::Documentable {

method url() {
$!url //= $.kind eq 'operator'
?? "/language/operators#" ~ uri_escape("@.subkinds[] $.name".subst(/\s+/, '_', :g))
!! ("", $.kind, $.name).map(&uri_escape).join('/')
?? "/language/operators#" ~ uri_escape("@.subkinds[] {$.name.gist}".subst(/\s+/, '_', :g))
!! ("", $.kind, $.name.gist).map(&uri_escape).join('/')
;
}
method categories() {
Expand Down
3 changes: 2 additions & 1 deletion lib/Pod/Htmlify.pm6
Expand Up @@ -25,8 +25,9 @@ my \length = @badchars.elems;
sub replace-badchars-with-goodnames($s is copy) is export {
# return $s if $s ~~ m{^ <[a..z]>+ '://'}; # bail on external links

return "" unless $s; # Avoid issues with Any being passed in. TODO avoid passing it in!
loop (my int $i = 0; $i < length; $i++) {
$s = $s.subst(@badchars[$i], goodnames[$i], :g)
$s = $s.gist.subst(@badchars[$i], goodnames[$i], :g)
}

$s
Expand Down

0 comments on commit 10be05c

Please sign in to comment.