Add docstrings for map and positional factory functions
Description
Environment
None
Attachments
1
- 21 Nov 2017, 02:46 PM
Activity
Show:
David Nolen December 8, 2017 at 9:36 PM

Mike Fikes November 21, 2017 at 6:55 PM
After digging deeper into this, the increase in generated code size is exactly attributable to the added tests that are in the patch. (In particular, the use of var
in the tests contributes a decent amount to the code size.)
So, in short, applying the patch would give us the desired docstrings without increasing production artifact size.

Mike Fikes November 21, 2017 at 3:31 PM
As a measure of the effect on code size, builds/out-adv/core-advanced-test.js
increases by 5825 bytes uncompressed, 1028 bytes gzipped.
If this deemed unacceptable, perhaps we could consider a way to have this work only while in the REPL.

Mike Fikes November 21, 2017 at 2:46 PM
With the attached patch:
cljs.user=> (defrecord Foo [x y])
cljs.user/Foo
cljs.user=> (doc map->Foo)
-------------------------
cljs.user/map->Foo
([G__19108])
Factory function for cljs.user/Foo, taking a map of keywords to field values.
nil
cljs.user=> (doc ->Foo)
-------------------------
cljs.user/->Foo
([x y])
Positional factory function for cljs.user/Foo.
nil
cljs.user=> (deftype Bar [x])
cljs.user/Bar
cljs.user=> (doc ->Bar)
-------------------------
cljs.user/->Bar
([x])
Positional factory function for cljs.user/Bar.
nil
Imitate the docstring behavior seen in Clojure for
defrecord
anddeftype
synthetically generated constructor functions:user=> (defrecord Foo [x y]) user.Foo user=> (doc map->Foo) ------------------------- user/map->Foo ([m__7585__auto__]) Factory function for class user.Foo, taking a map of keywords to field values. nil user=> (doc ->Foo) ------------------------- user/->Foo ([x y]) Positional factory function for class user.Foo. nil user=> (deftype Bar [x]) user.Bar user=> (doc ->Bar) ------------------------- user/->Bar ([x]) Positional factory function for class user.Bar. nil