diff options
Diffstat (limited to 'stdlib/source/test/lux/documentation.lux')
-rw-r--r-- | stdlib/source/test/lux/documentation.lux | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/documentation.lux b/stdlib/source/test/lux/documentation.lux new file mode 100644 index 000000000..b8a34a752 --- /dev/null +++ b/stdlib/source/test/lux/documentation.lux @@ -0,0 +1,93 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [control + ["." try] + ["." exception] + [parser + ["<.>" code]]] + [data + ["." text ("#\." equivalence)] + [format + ["md" markdown]]] + ["." macro + [syntax (#+ syntax:)] + ["." template] + ["." code]]]] + [\\library + ["." /]]) + +(syntax: (macro_error [macro <code>.any]) + (function (_ compiler) + (case ((macro.expansion macro) compiler) + (#try.Failure error) + (#try.Success [compiler (list (code.text error))]) + + (#try.Success _) + (#try.Failure "OOPS!")))) + +(template.with_locals [g!default + g!description] + (as_is (def: g!default + Nat + 123) + + (`` (/.documentation: /.documentation: + (~~ (template.text [g!description])))) + + (def: .public test + Test + (<| (_.covering /._) + ($_ _.and + (_.for [/.Definition] + ($_ _.and + (_.cover [/.default] + (let [definition (`` (/.default (~~ (template.identifier [.._] [g!default]))))] + (and (|> definition + (get@ #/.definition) + (text\= (template.text [g!default]))) + (|> definition + (get@ #/.documentation) + md.markdown + (text\= "") + not)))) + (_.cover [/.documentation:] + (and (|> ..documentation: + (get@ #/.definition) + (text\= (template.text [/.documentation:]))) + (|> ..documentation: + (get@ #/.documentation) + md.markdown + (text.contains? (template.text [g!description])) + not))) + )) + (_.for [/.Module] + ($_ _.and + (_.cover [/.module /.documentation] + (let [sub (/.module /._ + [] + []) + super (/.module .._ + [..documentation:] + [sub])] + (and (text.contains? (/.documentation sub) + (/.documentation super)) + (text.contains? (md.markdown (get@ #/.documentation ..documentation:)) + (/.documentation super))))) + )) + (_.cover [/.unqualified_identifier] + (`` (and (~~ (template [<example>] + [(<| (text.contains? (get@ #exception.label /.unqualified_identifier)) + macro_error + <example>)] + + [(/.default g!default)] + [(/.documentation: g!default + (~~ (template.text [g!description])))] + [(/.module g!default + [..documentation:] + [sub])] + ))))) + )))) + ) |