Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Append doc source reference link to Type and Language pages
  • Loading branch information
Paul Cochrane committed Feb 26, 2015
1 parent 1160afc commit 5b89eac
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions htmlify.p6
Expand Up @@ -141,9 +141,10 @@ sub MAIN(
say 'Composing doc registry ...';
$*DR.compose;

for $*DR.lookup("language", :by<kind>).list {
say "Writing language document for {.name} ...";
spurt "html{.url}.html", p2h(.pod, 'language');
for $*DR.lookup("language", :by<kind>).list -> $doc {
$doc.pod.contents.push: doc-source-reference($doc);
say "Writing language document for {$doc.name} ...";
spurt "html{$doc.url}.html", p2h($doc.pod, 'language');
}
for $*DR.lookup("type", :by<kind>).list {
write-type-source $_;
Expand Down Expand Up @@ -301,6 +302,7 @@ multi write-type-source($doc) {
;
}
}
$pod.contents.push: doc-source-reference($doc);
}
else {
note "Type $podname not found in type-graph data";
Expand Down Expand Up @@ -755,4 +757,19 @@ def p6format(code):
}
}

#| Append a section to the pod document referencing the source on GitHub
#| Note that we link to the raw source since GitHub isn't always able to
#| render Pod6 properly.
sub doc-source-reference($doc) {
# XXX: it would be nice to have a filename attribute for pod documents
my $pod-filename = $doc.url.split(/\//)[*-1] ~ '.pod';
my $kind = $doc.kind.tclc;
my @doc-source-ref-pod =
pod-block("This documentation was generated from ",
pod-link("$pod-filename","https://github.com/perl6/doc/raw/master/lib/$kind/$pod-filename"),
".");

return @doc-source-ref-pod;
}

# vim: expandtab shiftwidth=4 ft=perl6

0 comments on commit 5b89eac

Please sign in to comment.