Skip to content

Commit ab7db12

Browse files
anmonteirodnolen
authored andcommitted
CLJS-1814: Move docstrings for require, etc. from cljs.repl to their new definitions in cljs.core
1 parent a86a0ba commit ab7db12

File tree

2 files changed

+85
-93
lines changed

2 files changed

+85
-93
lines changed

src/main/clojure/cljs/core.cljc

Lines changed: 85 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,28 +2729,101 @@
27292729
`(do ~@forms))
27302730

27312731
(core/defmacro require
2732-
[& specs]
2733-
`(~'ns* ~(cons :require specs)))
2732+
"Loads libs, skipping any that are already loaded. Each argument is
2733+
either a libspec that identifies a lib or a flag that modifies how all the identified
2734+
libs are loaded. Use :require in the ns macro in preference to calling this
2735+
directly.
2736+
2737+
Libs
2738+
2739+
A 'lib' is a named set of resources in classpath whose contents define a
2740+
library of ClojureScript code. Lib names are symbols and each lib is associated
2741+
with a ClojureScript namespace. A lib's name also locates its root directory
2742+
within classpath using Java's package name to classpath-relative path mapping.
2743+
All resources in a lib should be contained in the directory structure under its
2744+
root directory. All definitions a lib makes should be in its associated namespace.
2745+
2746+
'require loads a lib by loading its root resource. The root resource path
2747+
is derived from the lib name in the following manner:
2748+
Consider a lib named by the symbol 'x.y.z; it has the root directory
2749+
<classpath>/x/y/, and its root resource is <classpath>/x/y/z.clj. The root
2750+
resource should contain code to create the lib's namespace (usually by using
2751+
the ns macro) and load any additional lib resources.
2752+
2753+
Libspecs
2754+
2755+
A libspec is a lib name or a vector containing a lib name followed by
2756+
options expressed as sequential keywords and arguments.
2757+
2758+
Recognized options:
2759+
:as takes a symbol as its argument and makes that symbol an alias to the
2760+
lib's namespace in the current namespace.
2761+
:refer takes a list of symbols to refer from the namespace..
2762+
:refer-macros takes a list of macro symbols to refer from the namespace.
2763+
:include-macros true causes macros from the namespace to be required.
2764+
2765+
Flags
2766+
2767+
A flag is a keyword.
2768+
Recognized flags: :reload, :reload-all, :verbose
2769+
:reload forces loading of all the identified libs even if they are
2770+
already loaded
2771+
:reload-all implies :reload and also forces loading of all libs that the
2772+
identified libs directly or indirectly load via require or use
2773+
:verbose triggers printing information about each load, alias, and refer
2774+
2775+
Example:
2776+
2777+
The following would load the library clojure.string :as string.
2778+
2779+
(require '[clojure/string :as string])"
2780+
[& args]
2781+
`(~'ns* ~(cons :require args)))
27342782

27352783
(core/defmacro require-macros
2736-
[& specs]
2737-
`(~'ns* ~(cons :require-macros specs)))
2784+
"Similar to require but only for macros."
2785+
[& args]
2786+
`(~'ns* ~(cons :require-macros args)))
27382787

27392788
(core/defmacro use
2740-
[& specs]
2741-
`(~'ns* ~(cons :use specs)))
2789+
"Like require, but referring vars specified by the mandatory
2790+
:only option.
2791+
2792+
Example:
2793+
2794+
The following would load the library clojure.set while referring
2795+
the intersection var.
2796+
2797+
(use '[clojure.set :only [intersection]])"
2798+
[& args]
2799+
`(~'ns* ~(cons :use args)))
27422800

27432801
(core/defmacro use-macros
2744-
[& specs]
2745-
`(~'ns* ~(cons :use-macros specs)))
2802+
"Similar to use but only for macros."
2803+
[& args]
2804+
`(~'ns* ~(cons :use-macros args)))
27462805

27472806
(core/defmacro import
2748-
[& specs]
2749-
`(~'ns* ~(cons :import specs)))
2807+
"import-list => (closure-namespace constructor-name-symbols*)
2808+
2809+
For each name in constructor-name-symbols, adds a mapping from name to the
2810+
constructor named by closure-namespace to the current namespace. Use :import in the ns
2811+
macro in preference to calling this directly."
2812+
[& import-symbols-or-lists]
2813+
`(~'ns* ~(cons :import import-symbols-or-lists)))
27502814

27512815
(core/defmacro refer-clojure
2752-
[& specs]
2753-
`(~'ns* ~(cons :refer-clojure specs)))
2816+
"Refers to all the public vars of `cljs.core`, subject to
2817+
filters.
2818+
Filters can include at most one each of:
2819+
2820+
:exclude list-of-symbols
2821+
:rename map-of-fromsymbol-tosymbol
2822+
2823+
Filters can be used to select a subset, via exclusion, or to provide a mapping
2824+
to a symbol different from the var's name, in order to prevent clashes."
2825+
[& args]
2826+
`(~'ns* ~(cons :refer-clojure args)))
27542827

27552828
;; INTERNAL - do not use, only for Node.js
27562829
(core/defmacro load-file* [f]

src/main/clojure/cljs/repl.cljc

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,87 +1054,6 @@ itself (not its value) is returned. The reader macro #'x expands to (var x)."}})
10541054
(def repl-special-doc-map
10551055
'{in-ns {:arglists ([name])
10561056
:doc "Sets *cljs-ns* to the namespace named by the symbol, creating it if needed."}
1057-
require {:arglists ([& args])
1058-
:doc " Loads libs, skipping any that are already loaded. Each argument is
1059-
either a libspec that identifies a lib or a flag that modifies how all the identified
1060-
libs are loaded. Use :require in the ns macro in preference to calling this
1061-
directly.
1062-
1063-
Libs
1064-
1065-
A 'lib' is a named set of resources in classpath whose contents define a
1066-
library of ClojureScript code. Lib names are symbols and each lib is associated
1067-
with a ClojureScript namespace. A lib's name also locates its root directory
1068-
within classpath using Java's package name to classpath-relative path mapping.
1069-
All resources in a lib should be contained in the directory structure under its
1070-
root directory. All definitions a lib makes should be in its associated namespace.
1071-
1072-
'require loads a lib by loading its root resource. The root resource path
1073-
is derived from the lib name in the following manner:
1074-
Consider a lib named by the symbol 'x.y.z; it has the root directory
1075-
<classpath>/x/y/, and its root resource is <classpath>/x/y/z.clj. The root
1076-
resource should contain code to create the lib's namespace (usually by using
1077-
the ns macro) and load any additional lib resources.
1078-
1079-
Libspecs
1080-
1081-
A libspec is a lib name or a vector containing a lib name followed by
1082-
options expressed as sequential keywords and arguments.
1083-
1084-
Recognized options:
1085-
:as takes a symbol as its argument and makes that symbol an alias to the
1086-
lib's namespace in the current namespace.
1087-
:refer takes a list of symbols to refer from the namespace..
1088-
:refer-macros takes a list of macro symbols to refer from the namespace.
1089-
:include-macros true causes macros from the namespace to be required.
1090-
1091-
Flags
1092-
1093-
A flag is a keyword.
1094-
Recognized flags: :reload, :reload-all, :verbose
1095-
:reload forces loading of all the identified libs even if they are
1096-
already loaded
1097-
:reload-all implies :reload and also forces loading of all libs that the
1098-
identified libs directly or indirectly load via require or use
1099-
:verbose triggers printing information about each load, alias, and refer
1100-
1101-
Example:
1102-
1103-
The following would load the library clojure.string :as string.
1104-
1105-
(require '[clojure/string :as string])"}
1106-
require-macros {:arglists ([& args])
1107-
:doc "Similar to the require REPL special function but
1108-
only for macros."}
1109-
use {:arglists ([& args])
1110-
:doc "Like require, but referring vars specified by the mandatory
1111-
:only option.
1112-
1113-
Example:
1114-
1115-
The following would load the library clojure.set while referring
1116-
the intersection var.
1117-
1118-
(use '[clojure.set :only [intersection]])"}
1119-
use-macros {:arglists ([& args])
1120-
:doc "Similar to the use REPL special function but
1121-
only for macros."}
1122-
refer-clojure {:arglists ([& args])
1123-
:doc "Refers to all the public vars of `cljs.core`, subject to
1124-
filters.
1125-
Filters can include at most one each of:
1126-
1127-
:exclude list-of-symbols
1128-
:rename map-of-fromsymbol-tosymbol
1129-
1130-
Filters can be used to select a subset, via exclusion, or to provide a mapping
1131-
to a symbol different from the var's name, in order to prevent clashes."}
1132-
import {:arglists ([& import-symbols-or-lists])
1133-
:doc "import-list => (closure-namespace constructor-name-symbols*)
1134-
1135-
For each name in constructor-name-symbols, adds a mapping from name to the
1136-
constructor named by closure-namespace to the current namespace. Use :import in the ns
1137-
macro in preference to calling this directly."}
11381057
load-file {:arglists ([name])
11391058
:doc "Sequentially read and evaluate the set of forms contained in the file."}})
11401059

0 commit comments

Comments
 (0)