Skip to content

Commit

Permalink
add new -k option, close #32
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniogamiz committed Jul 10, 2019
1 parent abc7c09 commit 9c35672
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ zef install Perl6::Documentable

```
bin/documentable [--topdir=<Str>] [-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 <Str>
Expand Down Expand Up @@ -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`.
Expand Down
36 changes: 29 additions & 7 deletions bin/documentable
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use v6.c;

use lib "lib";
use File::Temp;
use Perl6::Utils;
use Perl6::Documentable::Registry;
Expand All @@ -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,
Expand Down Expand Up @@ -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);

#===================================================================

Expand All @@ -83,22 +87,40 @@ sub MAIN (

#===================================================================

$now = now;
if ($p || $all ) {
$now = now;
DEBUG("HTML generation phase...");
for <programs language type> -> $kind {
for $registry.lookup($kind, :by<kind>).list -> $doc {
DEBUG("Writing $kind document for {$doc.name} ...");
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 ...");
Expand Down Expand Up @@ -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);

#===================================================================

Expand Down

0 comments on commit 9c35672

Please sign in to comment.