From ec99e90b53518fb156821ee6548cb4b8dc5b1ca3 Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 5 Aug 2019 13:10:50 +0200 Subject: [PATCH] update tests and docs, close #73 --- docs/reference/perl6-documentable-file.md | 22 +++++++++------------- t/201-documentable-file.t | 7 ------- t/202-references.t | 4 ---- t/302-process-pod-source.t | 6 ------ t/303-process-pod-dir.t | 9 --------- 5 files changed, 9 insertions(+), 39 deletions(-) diff --git a/docs/reference/perl6-documentable-file.md b/docs/reference/perl6-documentable-file.md index f3d7428..0b08bea 100644 --- a/docs/reference/perl6-documentable-file.md +++ b/docs/reference/perl6-documentable-file.md @@ -6,15 +6,11 @@ You can create one by typing: ```perl6 use Pod::Load; -use Perl6::TypeGraph; use Perl6::Documentable::File; -my $tg = Perl6::TypeGraph.new-from-file; my $pod = load("Type/int.pod6")[0]; my $doc = Perl6::Documentable::File.new( - dir => "Type", # used to determine the kind filename => "int" , # Type/int.pod6 => int - tg => $tg , # to complete the information about Type pods pod => $pod , # the pod ); ``` @@ -26,7 +22,15 @@ say $doc.defs.map({.name}) say $doc.refs.map({.name}) ``` -**Note:** `=TITLE` and `=SUBTITLE` elements must be present at the beginning of the file, otherwise, a `X::Documentable::TitleNotFound` or `X::Documentable::SubtitleNotFound` exception will be thrown. +**Note 1:** `=TITLE` and `=SUBTITLE` elements must be present at the beginning of the file, otherwise, a `X::Documentable::TitleNotFound` or `X::Documentable::SubtitleNotFound` exception will be thrown. + +**Note 2:** Some additional config muts be present in the pod passed to to the constructor: The first line of the pod file should be something like: + +``` +=begin pod :kind("") :subkind("") :category("") +``` + +These attributes are used to classify the pods. If any of these values is missing, a `X::Documentable::MissingMetadata` exception will be thrown. ### Attributes @@ -118,15 +122,11 @@ Example: ```perl6 use Pod::Load; -use Perl6::TypeGraph; my $pod = load("type/Any.pod6").first; -my $tg = Perl6::TypeGraph.new-from-file; my $origin = Perl6::Documentable::File.new( - dir => "Type", # used to determine the kind filename => "Any" , # Type/int.pod6 => int - tg => $tg , # to complete the information about Type pods pod => $pod , # the pod ); @@ -153,15 +153,11 @@ Example: ```perl6 use Pod::Load; -use Perl6::TypeGraph; my $pod = load("type/Any.pod6").first; -my $tg = Perl6::TypeGraph.new-from-file; my $origin = Perl6::Documentable::File.new( - dir => "Type", # used to determine the kind filename => "Any" , # Type/int.pod6 => int - tg => $tg , # to complete the information about Type pods pod => $pod , # the pod ); diff --git a/t/201-documentable-file.t b/t/201-documentable-file.t index 3f9a286..7e40c4e 100644 --- a/t/201-documentable-file.t +++ b/t/201-documentable-file.t @@ -1,6 +1,5 @@ use Perl6::Documentable; use Perl6::Documentable::File; -use Perl6::TypeGraph; use Pod::Load; use Pod::Utilities; use Pod::Utilities::Build; @@ -9,12 +8,9 @@ use Test; plan *; my $pod = load("t/test-doc/Native/int.pod6")[0]; -my $tg = Perl6::TypeGraph.new-from-file; my $doc = Perl6::Documentable::File.new( - :dir("Type"), :$pod, - :$tg, :filename("int") ); @@ -103,7 +99,6 @@ subtest "Index X<> heading" => { =end pod - subtest '=TITLE =SUBTITLE compulsory' => { test-exception($=pod[0], "=TITLE and =SUBTITLE"); test-exception($=pod[1], "=TITLE"); @@ -135,9 +130,7 @@ sub test-scope($name, $str) { sub test-exception($pod, $msg) { dies-ok { Perl6::Documentable::File.new( - :dir("Type"), :$pod, - :$tg, :filename("int") )}, $msg; } diff --git a/t/202-references.t b/t/202-references.t index b4569fe..c10aa0b 100644 --- a/t/202-references.t +++ b/t/202-references.t @@ -3,18 +3,14 @@ use Perl6::Documentable::Index; use Pod::Load; use Pod::Utilities; use Pod::Utilities::Build; -use Perl6::TypeGraph; use Test; plan *; my $pod = load("t/test-doc/Programs/02-reading-docs.pod6")[0]; -my $tg = Perl6::TypeGraph.new-from-file; my $origin = Perl6::Documentable::File.new( - dir => "Type", pod => $pod, - tg => $tg, filename => "test", ); diff --git a/t/302-process-pod-source.t b/t/302-process-pod-source.t index c9005dd..214b093 100644 --- a/t/302-process-pod-source.t +++ b/t/302-process-pod-source.t @@ -1,26 +1,20 @@ use Test; use Perl6::Documentable::File; -use Perl6::TypeGraph; use Pod::Load; plan *; my $pod = load("t/test-doc/Native/int.pod6").first; -my $tg = Perl6::TypeGraph.new-from-file; my $doc1 = Perl6::Documentable::File.new( - dir => "Type", pod => $pod, filename => "int", - tg => $tg ); # change the kind to test the setting of attributes like my $doc2 = Perl6::Documentable::File.new( - dir => "Language", pod => load("t/test-doc/Language/operators.pod6")[0], filename => "int", - tg => $tg ); subtest "Basic attributes" => { diff --git a/t/303-process-pod-dir.t b/t/303-process-pod-dir.t index 9dd8830..0d8dab5 100644 --- a/t/303-process-pod-dir.t +++ b/t/303-process-pod-dir.t @@ -1,7 +1,6 @@ use Test; use Perl6::Documentable::Registry; -use Perl6::TypeGraph; use Pod::Load; plan *; @@ -12,13 +11,9 @@ my $registry = Perl6::Documentable::Registry.new( :verbose(False) ); -my $tg = Perl6::TypeGraph.new-from-file; - my $expected = Perl6::Documentable::File.new( - dir => "Type", pod => load("t/test-doc/Native/int.pod6")[0], filename => "int", - tg => $tg ); subtest "process pod dir" => { @@ -43,16 +38,12 @@ subtest "multi-class support" => { # expected documentables my @pods = load("t/test-doc/Native/multi-class.pod6"); my $doc1 = Perl6::Documentable::File.new( - dir => "Native", pod => @pods[0], filename => "multi-class", - tg => $tg ); my $doc2 = Perl6::Documentable::File.new( - dir => "Native", pod => @pods[1], filename => "multi-class", - tg => $tg ); is-deeply @docs, [$doc1, $doc2], "multi-class file declaration";