From d10485449038a3cb5238225b5d333d744d305f28 Mon Sep 17 00:00:00 2001 From: Bill Burdick Date: Tue, 15 Nov 2016 10:36:38 +0200 Subject: [PATCH] if function has doc string, set function's "wispDocument" property to it --- src/expander.wisp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/expander.wisp b/src/expander.wisp index ac842f31..5f74b85e 100644 --- a/src/expander.wisp +++ b/src/expander.wisp @@ -2,7 +2,7 @@ "wisp syntax and macro expander module" (:require [wisp.ast :refer [meta with-meta symbol? keyword? quote? symbol namespace name - unquote? unquote-splicing?]] + unquote? unquote-splicing? gensym]] [wisp.sequence :refer [list? list conj partition seq empty? map vec every? concat first second third rest last @@ -288,7 +288,10 @@ id (with-meta name (conj (or (meta name) {}) metadata)) fn (with-meta `(fn ~id ~@body) (meta &form))] - `(def ~id ~fn))) + (if doc + (let [FN (gensym)] + `(def ~id (let [~FN ~fn] (set! ~(str FN ".wispDocument") ~doc) ~FN))) + `(def ~id ~fn)))) (install-macro! :defn (with-meta expand-defn {:implicit [:&form]}))