2
2
3
3
import Base. Docs: meta, @var , DocStr, parsedoc
4
4
5
+ const curmod = current_module ()
6
+ const curmod_name = fullname (curmod)
7
+ const curmod_prefix = " $([" $m ." for m in curmod_name]. .. ) "
8
+
5
9
# Test helpers.
6
10
function docstrings_equal (d1, d2)
7
11
io1 = IOBuffer ()
@@ -450,10 +454,13 @@ end
450
454
end
451
455
452
456
let T = meta (DocVars)[@var (DocVars. T)],
453
- S = meta (DocVars)[@var (DocVars. S)]
457
+ S = meta (DocVars)[@var (DocVars. S)],
458
+ Tname = Markdown. parse (" ```\n $(curmod_prefix) DocVars.T\n ```" ),
459
+ Sname = Markdown. parse (" ```\n $(curmod_prefix) DocVars.S\n ```" )
460
+ # Splicing the expression directly doesn't work
454
461
@test docstrings_equal (T. docs[Union{}],
455
462
doc"""
456
- DocVars.T
463
+ $Tname
457
464
458
465
# Fields
459
466
@@ -464,7 +471,7 @@ let T = meta(DocVars)[@var(DocVars.T)],
464
471
)
465
472
@test docstrings_equal (S. docs[Union{}],
466
473
doc"""
467
- DocVars.S
474
+ $Sname
468
475
469
476
"""
470
477
)
@@ -545,11 +552,12 @@ end
545
552
546
553
@doc " This should document @m1... since its the result of expansion" @m2_11993
547
554
@test (@doc @m1_11993 ) != = nothing
548
- let d = (@doc :@m2_11993 )
555
+ let d = (@doc :@m2_11993 ),
556
+ macro_doc = Markdown. parse (" `$(curmod_prefix) @m2_11993` is a macro." )
549
557
@test docstring_startswith (d, doc"""
550
558
No documentation found.
551
559
552
- `@m2_11993` is a macro. """ )
560
+ $macro_doc """ )
553
561
end
554
562
555
563
@doc " Now @m2... should be documented" :@m2_11993
@@ -707,56 +715,60 @@ undocumented(x,y) = 3
707
715
708
716
end
709
717
710
- @test docstrings_equal ( @doc (Undocumented . bindingdoesnotexist), doc """
718
+ doc_str = Markdown . parse ( """
711
719
No documentation found.
712
720
713
- Binding `Undocumented.bindingdoesnotexist` does not exist.
721
+ Binding `$(curmod_prefix) Undocumented.bindingdoesnotexist` does not exist.
714
722
""" )
723
+ @test docstrings_equal (@doc (Undocumented. bindingdoesnotexist), doc " $doc_str" )
715
724
716
- @test docstrings_equal ( @doc (Undocumented . A), doc """
725
+ doc_str = Markdown . parse ( """
717
726
No documentation found.
718
727
719
728
**Summary:**
720
729
```
721
- abstract Undocumented.A <: Any
730
+ abstract $(curmod_prefix) Undocumented.A <: Any
722
731
```
723
732
724
733
**Subtypes:**
725
734
```
726
- Undocumented.B
727
- Undocumented.C
735
+ $(curmod_prefix) Undocumented.B
736
+ $(curmod_prefix) Undocumented.C
728
737
```
729
738
""" )
739
+ @test docstrings_equal (@doc (Undocumented. A), doc " $doc_str" )
730
740
731
- @test docstrings_equal ( @doc (Undocumented . B), doc """
741
+ doc_str = Markdown . parse ( """
732
742
No documentation found.
733
743
734
744
**Summary:**
735
745
```
736
- abstract Undocumented.B <: Undocumented.A
746
+ abstract $(curmod_prefix) Undocumented.B <: $(curmod_prefix) Undocumented.A
737
747
```
738
748
739
749
**Subtypes:**
740
750
```
741
- Undocumented.D
751
+ $(curmod_prefix) Undocumented.D
742
752
```
743
753
""" )
754
+ @test docstrings_equal (@doc (Undocumented. B), doc " $doc_str" )
744
755
745
- @test docstrings_equal ( @doc (Undocumented . C), doc """
756
+ doc_str = Markdown . parse ( """
746
757
No documentation found.
747
758
748
759
**Summary:**
749
760
```
750
- type Undocumented.C <: Undocumented.A
761
+ type $(curmod_prefix) Undocumented.C <: $(curmod_prefix) Undocumented.A
751
762
```
752
763
""" )
764
+ @test docstrings_equal (@doc (Undocumented. C), doc " $doc_str" )
753
765
754
- @test docstrings_equal ( @doc (Undocumented . D), doc """
766
+ doc_str = Markdown . parse ( """
755
767
No documentation found.
756
768
757
769
**Summary:**
758
770
```
759
- immutable Undocumented.D <: Undocumented.B
771
+ immutable $(curmod_prefix) Undocumented.D <: $(curmod_prefix) Undocumented.B
760
772
```
761
773
762
774
**Fields:**
@@ -766,14 +778,15 @@ two :: String
766
778
three :: Float64
767
779
```
768
780
""" )
781
+ @test docstrings_equal (@doc (Undocumented. D), doc " $doc_str" )
769
782
770
783
let d = @doc Undocumented. f
771
784
io = IOBuffer ()
772
785
show (io, MIME " text/markdown" (), d)
773
786
@test startswith (takebuf_string (io),"""
774
787
No documentation found.
775
788
776
- `Undocumented.f` is a `Function`.
789
+ `$(curmod_prefix) Undocumented.f` is a `Function`.
777
790
""" )
778
791
end
779
792
@@ -783,7 +796,7 @@ let d = @doc Undocumented.undocumented
783
796
@test startswith (takebuf_string (io), """
784
797
No documentation found.
785
798
786
- `Undocumented.undocumented` is a `Function`.
799
+ `$(curmod_prefix) Undocumented.undocumented` is a `Function`.
787
800
""" )
788
801
end
789
802
@@ -862,7 +875,7 @@ let x = Binding(Base, :bindingdoesnotexist)
862
875
@test @var (Base. bindingdoesnotexist) == x
863
876
end
864
877
865
- let x = Binding (Main , :bindingdoesnotexist )
878
+ let x = Binding (current_module () , :bindingdoesnotexist )
866
879
@test defined (x) == false
867
880
@test @var (bindingdoesnotexist) == x
868
881
end
0 commit comments