Skip to content

Commit

Permalink
Improves documentation a bit by adding examples refs #49
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Dec 8, 2018
1 parent 340b36b commit 901c9b8
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.precomp/

*~
.precomp
16 changes: 8 additions & 8 deletions README.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Render Pod6 as HTML
=begin SYNOPSIS
=item
Use it integrated with Perl 6 documentation system
perl6 --doc=HTML lib/FancyModule.pm > FancyModule.html
=begin item
=begin code
=pod My I<super B<awesome>> embedded C<pod>
document!
Or as an external function to render your documentation
=begin code
=pod My I<super B<awesome>> embedded C<pod> document!
say Pod::To::HTML.render($=pod[0]);
=end code
=end item
say Pod::To::HTML.render($=pod[0]);
=end code
=end SYNOPSIS
Expand Down
2 changes: 1 addition & 1 deletion lib/Pod/To/HTML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ sub pod2html(
--> Str ) is export {

my $template-file = %?RESOURCES<templates/main.mustache>;
with $templates {
with $templates {
if "$templates/main.mustache".IO ~~ :f {
$template-file = "$templates/main.mustache".IO
}
Expand Down
26 changes: 26 additions & 0 deletions resources/examples/main.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>
<html lang="{{ lang }}">
<head>
<title>{{ title }}</title>
<meta charset="UTF-8" />
<style>
kbd { font-family: "Droid Sans Mono", "Luxi Mono", "Inconsolata", monospace }
samp, code { font-family: "Terminus", "Courier", "Lucida Console", monospace }
.nested {
margin-left: 3em;
}
aside, u { opacity: 0.7 }
a[id^="fn-"]:target { background: #ff0 }
</style>
</head>
<body class="pod">
<div id="___top"></div>
{{{ header }}}
{{# title }}<h1 class='title'>{{ title }}</h1>{{/ title }}
{{# subtitle }}<p class='subtitle'>{{ subtitle }}</p>{{/ subtitle }}
<div class="pod-body no-toc">
{{# body }}{{{ . }}}{{/ body }}
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions resources/examples/render.p6
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env perl6

use v6;
use MONKEY-SEE-NO-EVAL;
use Pod::To::HTML;

sub MAIN( $file = "../../README.pod6" ) {
my $file-content = $file.IO.slurp;
die "No pod here" if not $file-content ~~ /\=begin \s+ pod/;
my $pod;
try {
$pod = EVAL($file-content ~ "\n\$=pod");
};
die "Pod fails: $!" if $!;
my $result = pod2html( $pod, templates => '.' );
say $result;
}

0 comments on commit 901c9b8

Please sign in to comment.