Skip to content

Commit 65b4b62

Browse files
committed
Merge pull request bbatsov#103 from llasram/docstring-after-fn-name
Docstring placement.
2 parents 40b8525 + 85c1bda commit 65b4b62

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,27 @@ when there are no arguments on the same line as the function name.
165165
[x] (bar x))
166166
```
167167

168+
* <a name="docstring-after-fn-name">
169+
When adding a docstring – especially to a function using the above form – take
170+
care to correctly place the docstring after the function name, not after the
171+
argument vector. The latter is not invalid syntax and won’t cause an error,
172+
but includes the string as a form in the function body without attaching it to
173+
the var as documentation.
174+
<sup>[[link](#docstring-after-fn-name)]</sup>
175+
176+
```Clojure
177+
;; good
178+
(defn foo
179+
"docstring"
180+
[x]
181+
(bar x))
182+
183+
;; bad
184+
(defn foo [x]
185+
"docstring"
186+
(bar x))
187+
```
188+
168189
* <a name="oneline-short-fn"></a>
169190
Optionally omit the new line between the argument vector and a short
170191
function body.

0 commit comments

Comments
 (0)