(.require
 [library
  [lux (.except)
   ["$" documentation]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]
    [collection
     ["[0]" list (.use "[1]#[0]" monoid)]]]]]
 ["[0]" /
  ["[1][0]" check]
  ["[1][0]" declaration]
  ["[1][0]" definition]
  ["[1][0]" export]
  ["[1][0]" input]
  ["[1][0]" type
   ["[1]/[0]" variable]]]
 [\\library
  ["[0]" /]])

(def .public documentation
  (List $.Documentation)
  (list.partial ($.module /._
                          "")

                ($.definition /.syntax
                  (format \n "A more advanced way to define macros than 'macro'."
                          \n "The inputs to the macro can be parsed in complex ways through the use of syntax parsers."
                          \n "The macro body is also (implicitly) run in the Meta monad, to save some typing."
                          \n "Also, the compiler state can be accessed through a special binding.")
                  [(def .public object
                     (syntax (_ lux_state [.let [imports (class_imports lux_state)]
                                           .let [class_vars (list)]
                                           super (opt (super_class_decl^ imports class_vars))
                                           interfaces (tuple (some (super_class_decl^ imports class_vars)))
                                           constructor_args (constructor_args^ imports class_vars)
                                           methods (some (overriden_method_def^ imports))])
                       (let [def_code (all text#composite "anon-class:"
                                           (spaced (list (super_class_decl$ (maybe.else object_super_class super))
                                                         (with_brackets (spaced (list#each super_class_decl$ interfaces)))
                                                         (with_brackets (spaced (list#each constructor_arg$ constructor_args)))
                                                         (with_brackets (spaced (list#each (method_def$ id) methods))))))]
                         (in (list (` ((, (code.text def_code)))))))))])

                (all list#composite
                     /check.documentation
                     /declaration.documentation
                     /definition.documentation
                     /export.documentation
                     /input.documentation
                     /type/variable.documentation
                     )
                ))
