(.require
 [library
  [lux (.except)
   ["$" documentation]
   [data
    ["[0]" text (.only \n)
     ["%" \\format (.only format)]]
    [collection
     ["[0]" list (.use "[1]#[0]" monoid)]]]
   [meta
    ["[0]" code (.only)
     ["<[1]>" \\parser]]
    [macro
     [syntax (.only syntax)]
     ["[0]" template]]]]]
 [\\library
  ["[0]" /]]
 ["[0]" /
  ["[1][0]" named]])

(def palette_documentation
  (syntax (_ [[_ name] <code>.symbol])
    (in (list (code.text (format "A " (text.replaced "_" "-" name) " palette."))))))

(`` (def .public documentation
      (List $.Documentation)
      (let [encoding (list ($.definition /.RGB
                             "Red-Green-Blue color format.")

                           ($.definition /.of_rgb)
                           ($.definition /.rgb)

                           ($.definition /.HSL
                             "Hue-Saturation-Lightness color format.")

                           ($.definition /.hsl)
                           ($.definition /.of_hsl)

                           ($.definition /.CMYK
                             "Cyan-Magenta-Yellow-Key color format.")

                           ($.definition /.hsb)
                           ($.definition /.of_hsb)

                           ($.definition /.HSB
                             "Hue-Saturation-Brightness color format.")

                           ($.definition /.cmyk)
                           ($.definition /.of_cmyk))
            transformation (list ($.definition /.gray_scale)
                                 ($.definition /.darker)
                                 ($.definition /.brighter)
                                 ($.definition /.saturated)
                                 ($.definition /.un_saturated)

                                 ($.definition /.complement
                                   "The opposite color."
                                   [(complement color)])

                                 ($.definition /.interpolated
                                   ""
                                   [(interpolated ratio end start)]))
            alpha (list ($.definition /.Alpha
                          "The degree of transparency of a pigment.")

                        ($.definition /.transparent
                          "The maximum degree of transparency.")

                        ($.definition /.translucent
                          "The medium degree of transparency.")

                        ($.definition /.opaque
                          "The minimum degree of transparency."))
            scheme (list ($.definition /.Spread)
                         ($.definition /.Palette)
                         
                         ($.definition /.analogous
                           (palette_documentation /.analogous)
                           [(analogous spread variations color)])

                         ($.definition /.monochromatic
                           (palette_documentation /.monochromatic)
                           [(monochromatic spread variations color)])

                         (,, (with_template [<name>]
                               [(`` ($.definition <name>
                                      (format "A "
                                              (text.replaced "_" "-" (,, (template.text [<name>])))
                                              " color scheme.")))]

                               [/.triad]
                               [/.clash]
                               [/.split_complement]
                               [/.square]
                               [/.tetradic]
                               )))]
        (list.partial ($.module /._
                                "")

                      ($.definition /.Color
                        "A color value, independent of color format.")

                      ($.definition /.equivalence)
                      ($.definition /.hash)
                      ($.definition /.black)
                      ($.definition /.white)
                      ($.definition /.addition)
                      ($.definition /.subtraction)
                      
                      ($.definition /.Pigment
                        "A color with some degree of transparency.")

                      (all list#composite
                           encoding
                           transformation
                           alpha
                           scheme

                           /named.documentation
                           )
                      ))))
