aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/documentation.lux
blob: 684556ecfa555ddd175b07a63bae38148441b9e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
(.using
 [library
  [lux "*"
   ["_" test {"+" Test}]
   ["[0]" meta]
   [control
    ["[0]" try]
    ["[0]" exception]
    [parser
     ["<[0]>" code]]]
   [data
    ["[0]" text ("[1]#[0]" equivalence)
     ["%" format]]
    [format
     ["md" markdown]]]
   ["[0]" macro
    [syntax {"+" syntax:}]
    ["[0]" template]
    ["[0]" code]]]]
 [\\library
  ["[0]" /]])

(syntax: (macro_error [macro <code>.any])
  (function (_ compiler)
    {try.#Success [compiler (list (code.bit (case ((macro.expansion macro) compiler)
                                              {try.#Failure error}
                                              true
                                              
                                              {try.#Success _}
                                              false)))]}))

(syntax: (description [])
  (# meta.monad each
     (|>> %.nat code.text list)
     meta.seed))

(template.with_locals [g!default]
  (with_expansions ['definition_description' (..description)
                    'sub_description' (..description)
                    'super_description' (..description)]
    (these (def: .public g!default
             Nat
             123)

           (/.documentation: /.documentation:
             'definition_description')

           (def: .public test
             Test
             (<| (_.covering /._)
                 (all _.and
                      (_.for [/.Definition]
                             (all _.and
                                  (_.coverage [/.default]
                                    (case (`` (/.default (~~ (template.symbol [.._] [g!default]))))
                                      (pattern (list definition))
                                      (and (|> definition
                                               (the /.#definition)
                                               (text#= (template.text [g!default])))
                                           (|> definition
                                               (the /.#documentation)
                                               md.markdown
                                               (text#= "")
                                               not))

                                      _
                                      false))
                                  (_.coverage [/.documentation:]
                                    (case ..documentation:
                                      (pattern (list documentation:))
                                      (and (|> documentation:
                                               (the /.#definition)
                                               (text#= (template.text [/.documentation:])))
                                           (|> documentation:
                                               (the /.#documentation)
                                               md.markdown
                                               (text.contains? 'definition_description')))

                                      _
                                      false))
                                  ))
                      (_.for [/.Module]
                             (all _.and
                                  (_.coverage [/.module /.documentation]
                                    (let [sub (`` (/.module /._
                                                            (~~ (template.text ['sub_description']))
                                                            []
                                                            []))
                                          super (`` (/.module .._
                                                              (~~ (template.text ['super_description']))
                                                              [..documentation:]
                                                              [sub]))]
                                      (and (text.contains? (template.text ['sub_description'])
                                                           (/.documentation sub))
                                           (text.contains? (/.documentation sub)
                                                           (/.documentation super))
                                           (text.contains? (template.text ['super_description'])
                                                           (/.documentation super))
                                           (case ..documentation:
                                             (pattern (list documentation:))
                                             (text.contains? (md.markdown (the /.#documentation documentation:))
                                                             (/.documentation super))

                                             _
                                             false))))
                                  ))
                      (_.coverage [/.unqualified_symbol]
                        (`` (and (~~ (template [<example>]
                                       [(macro_error <example>)]
                                       
                                       [(/.default g!default)]
                                       [(/.documentation: g!default
                                          (~~ (template.text ['definition_description'])))]
                                       [(/.module g!default
                                                  ""
                                                  [..documentation:]
                                                  [sub])]
                                       )))))
                      )))))
  )