From 9c35672aaf8204cd9a38935c26c5d5db7ab4106e Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 10 Jul 2019 10:33:19 +0200 Subject: [PATCH] add new -k option, close #32 --- README.md | 6 +++++- bin/documentable | 36 +++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 8 deletions(-) mode change 100644 => 100755 bin/documentable diff --git a/README.md b/README.md index fc74258..4629d28 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ $ zef install Perl6::Documentable ``` bin/documentable [--topdir=] [-v|--verbose] [-c|--cache] [-p|--pods] [-s|--search-index] - [-i|--indexes] [-t|--type-images] [-f|--force] [-a|--all] [--highlight] + [-i|--indexes] [-t|--type-images] [-f|--force] [-a|--all] [--highlight] [-k|--kind] ``` #### --topdir @@ -70,6 +70,10 @@ If specified, typegraph svg files will be forcibly generated and written. If specified, code blocks will be highlighted using [atom-language-perl6](https://github.com/perl6/atom-language-perl6). +#### -k, --kind + +If specified, kind files will be written for `syntax` and `routine`. + #### -a, --all Equivalent to `-p -s -i -t`. diff --git a/bin/documentable b/bin/documentable old mode 100644 new mode 100755 index bc185b4..c660c19 --- a/bin/documentable +++ b/bin/documentable @@ -2,6 +2,7 @@ use v6.c; +use lib "lib"; use File::Temp; use Perl6::Utils; use Perl6::Documentable::Registry; @@ -18,6 +19,7 @@ sub MAIN ( Bool :v(:verbose($v)) = False, Bool :c(:$cache) = True , Bool :p(:pods($p)) = False, + Bool :k(:kind($k)) = False, Bool :s(:search-index($s)) = False, Bool :i(:indexes($i)) = False, Bool :t(:type-images($t)) = False, @@ -55,15 +57,17 @@ sub MAIN ( #=================================================================== - $now = now; if ($t || $all) { + $now = now; + DEBUG("Writing type-graph representations..."); my $viz = Perl6::TypeGraph::Viz.new; $viz.write-type-graph-images(path => "html/images", force => $f, - type-graph => $registry.tg) + type-graph => $registry.tg); + + print-time("Typegraph representations", $now); } - print-time("Typegraph representations", $now); #=================================================================== @@ -83,8 +87,8 @@ sub MAIN ( #=================================================================== - $now = now; if ($p || $all ) { + $now = now; DEBUG("HTML generation phase..."); for -> $kind { for $registry.lookup($kind, :by).list -> $doc { @@ -92,13 +96,31 @@ sub MAIN ( spurt "html{$doc.url}.html", source-html($kind, $doc); } } + print-time("Writing source files", $now); + } + + #=================================================================== + + if ($k || $all) { + $now = now; + DEBUG("Writing routine files..."); + generate-kind-files($registry,"routine").map({ + spurt "html/routine/{replace-badchars-with-goodnames .[0]}.html", .[1]; + }); + print-time("Writing routine files", $now); + + $now = now; + DEBUG("Writing syntax files..."); + generate-kind-files($registry,"syntax").map({ + spurt "html/syntax/{replace-badchars-with-goodnames .[0]}.html", .[1]; + }); + print-time("Writing syntax files", $now); } - print-time("Writing source files", $now); #=================================================================== - $now = now; if ($i || $all) { + $now = now; DEBUG("Index generation phase..."); DEBUG("Writing html/programs.html ..."); @@ -126,8 +148,8 @@ sub MAIN ( spurt "html/routine-$category.html", routine-subindex-html($registry.routine-subindex(:$category), $category); } + print-time("Writing index files", $now); } - print-time("Writing index files", $now); #===================================================================