Skip to content

Commit 5b89eac

Browse files
committed
Append doc source reference link to Type and Language pages
1 parent 1160afc commit 5b89eac

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

htmlify.p6

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ sub MAIN(
141141
say 'Composing doc registry ...';
142142
$*DR.compose;
143143

144-
for $*DR.lookup("language", :by<kind>).list {
145-
say "Writing language document for {.name} ...";
146-
spurt "html{.url}.html", p2h(.pod, 'language');
144+
for $*DR.lookup("language", :by<kind>).list -> $doc {
145+
$doc.pod.contents.push: doc-source-reference($doc);
146+
say "Writing language document for {$doc.name} ...";
147+
spurt "html{$doc.url}.html", p2h($doc.pod, 'language');
147148
}
148149
for $*DR.lookup("type", :by<kind>).list {
149150
write-type-source $_;
@@ -301,6 +302,7 @@ multi write-type-source($doc) {
301302
;
302303
}
303304
}
305+
$pod.contents.push: doc-source-reference($doc);
304306
}
305307
else {
306308
note "Type $podname not found in type-graph data";
@@ -755,4 +757,19 @@ def p6format(code):
755757
}
756758
}
757759

760+
#| Append a section to the pod document referencing the source on GitHub
761+
#| Note that we link to the raw source since GitHub isn't always able to
762+
#| render Pod6 properly.
763+
sub doc-source-reference($doc) {
764+
# XXX: it would be nice to have a filename attribute for pod documents
765+
my $pod-filename = $doc.url.split(/\//)[*-1] ~ '.pod';
766+
my $kind = $doc.kind.tclc;
767+
my @doc-source-ref-pod =
768+
pod-block("This documentation was generated from ",
769+
pod-link("$pod-filename","https://github.com/perl6/doc/raw/master/lib/$kind/$pod-filename"),
770+
".");
771+
772+
return @doc-source-ref-pod;
773+
}
774+
758775
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)