Created
June 9, 2019 00:38
-
-
Save mikeananev/755584c02757700916e0b73aed5a40c6 to your computer and use it in GitHub Desktop.
Example of doc string templates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn doc-template | |
"Description: | |
Generates doc string template for given `args` argument list. | |
Arguments: | |
**`desc`** - _String_ with description what function do. | |
**`args`** - _vector_ of symbols (argument names). | |
**`return`** - _String_ with description what function return. | |
Returns: | |
_String_ as doc string template." | |
[desc args return] | |
(let [max-len (apply max (mapv count (mapv str args))) | |
arg-str (apply str (for [a args] | |
(format " **`%s`** %s- \n" (str a) (apply str (repeat (- max-len (count (str a))) " ")))))] | |
(format "Description:\n\n %s\n\n Arguments:\n\n%s\n Returns:\n\n %s" desc arg-str return))) | |
(println (doc-template "Generate doc string template for given `args` argument list." | |
'[desc args return] | |
"_String_ as doc string template.")) | |
(defn doc-template | |
"# Generate doc string template for given `args` argument list. | |
* Params: | |
**`desc`** - _String_ with description what function do. | |
**`args`** - _vector_ of symbols (argument names). | |
**`return`** - _String_ with description what function return. | |
* Returns: | |
_String_ as doc string template." | |
[desc args return] | |
(let [max-len (apply max (mapv count (mapv str args))) | |
arg-str (apply str (for [a args] | |
(format " \t **`%s`** %s- \n" (str a) (apply str (repeat (- max-len (count (str a))) " ")))))] | |
(format "# %s\n\n * Params:\n%s\n * Returns:\n \t %s" desc arg-str return))) | |
(println (doc-template "Generate doc string template for given `args` argument list." | |
'[desc args return] | |
"_String_ as doc string template.")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment