Skip to content

Commit 9253176

Browse files
committed
Fix documentation strings
1 parent be23f30 commit 9253176

File tree

2 files changed

+81
-51
lines changed

2 files changed

+81
-51
lines changed

impostman.el

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,30 @@
4646
:group 'tools)
4747

4848
(defcustom impostman-auth-basic-as-elisp-code t
49-
"Convert Basic authentication header to elisp code so that the username
50-
and password can be easily edited.
49+
"Convert Basic authentication header to elisp code for easy edit.
5150
5251
Example with verb:
53-
Authorization: Basic {{(base64-encode-string (encode-coding-string \"username:password\" 'utf-8) t)}}
52+
Authorization: Basic {{(base64-encode-string
53+
(encode-coding-string \"username:password\" 'utf-8) t)}}
5454
5555
Example with restclient:
56-
:auth := (format \"Basic %s\" (base64-encode-string (encode-coding-string \"username:password\" 'utf-8) t))
56+
:auth := (format \"Basic %s\" (base64-encode-string
57+
(encode-coding-string \"username:password\" 'utf-8) t))
5758
Authorization: :auth
5859
5960
If nil, the username and password are directly encoded in base64:
6061
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ="
6162
:type 'boolean)
6263

6364
(defcustom impostman-use-variables t
64-
"Keep Postman variables in the output and define variables according to the
65-
output.
65+
"Keep Postman variables in the output and define variables.
6666
6767
If nil, no variables are used, they are directly replaced by their values
6868
during the import of collection."
6969
:type 'boolean)
7070

7171
(defconst impostman-version "0.2.0-snapshot"
72-
"Impostman package version")
72+
"Impostman package version.")
7373

7474
(defconst impostman-output-verb-alist
7575
'((init . ignore)
@@ -79,7 +79,7 @@ during the import of collection."
7979
(request . impostman-output-verb-request)
8080
(footer . impostman-output-verb-footer)
8181
(end . impostman-output-verb-end))
82-
"Emacs verb output")
82+
"Emacs verb output.")
8383

8484
(defconst impostman-output-restclient-alist
8585
'((init . ignore)
@@ -89,12 +89,12 @@ during the import of collection."
8989
(request . impostman-output-restclient-request)
9090
(footer . impostman-output-restclient-footer)
9191
(end . impostman-output-restclient-end))
92-
"Emacs restclient output")
92+
"Emacs restclient output.")
9393

9494
(defcustom impostman-outputs-alist
9595
'(("verb" . impostman-output-verb-alist)
9696
("restclient" . impostman-output-restclient-alist))
97-
"Impostman outputs"
97+
"Impostman outputs."
9898
:type '(alist :key-type string :value-type function))
9999

100100
;; functions common to all outputs
@@ -114,8 +114,8 @@ PREFIX is the prefix to add in front of each line (default is \"# \")."
114114
"\n"))))
115115

116116
(defun impostman-get-auth-basic-plain (authorization)
117-
"Get the plain-text \"username:password\" with the value of the
118-
Authorization header, if it is Basic authentication.
117+
"Get the plain-text \"username:password\" given an AUTHORIZATION header.
118+
119119
For example with the value \"Basic dXNlcm5hbWU6cGFzc3dvcmQ=\",
120120
the function returns \"username:password\".
121121
Return nil if the authentication is not Basic or if the base64 is invalid."
@@ -129,7 +129,7 @@ Return nil if the authentication is not Basic or if the base64 is invalid."
129129
"Replace variables in a string, using verb syntax.
130130
131131
STRING any string that can contain variables with format \"{{variable}}\".
132-
VARIABLES is a alist with Postman variables."
132+
VARIABLES is an alist with Postman variables."
133133
(if impostman-use-variables
134134
(replace-regexp-in-string
135135
"{{\\([^}]+\\)}}" "{{(verb-var \\1)}}" (or string ""))
@@ -146,7 +146,7 @@ VARIABLES is a alist with Postman variables."
146146
147147
NAME is the collection name.
148148
DESCRIPTION is the collection description.
149-
VARIABLES is a alist with Postman variables."
149+
VARIABLES is an alist with Postman variables."
150150
(ignore variables)
151151
(concat
152152
"* " name " :verb:" "\n"
@@ -158,7 +158,7 @@ VARIABLES is a alist with Postman variables."
158158
LEVEL is the level.
159159
NAME is the item name.
160160
DESCRIPTION is the item description.
161-
VARIABLES is a alist with Postman variables."
161+
VARIABLES is an alist with Postman variables."
162162
(ignore variables)
163163
(concat
164164
(if (<= level 2) "\n" "")
@@ -173,7 +173,7 @@ METHOD is the HTTP method.
173173
URL is the URL.
174174
HEADERS is an alist with HTTP headers.
175175
BODY is the request body.
176-
VARIABLES is a alist with Postman variables."
176+
VARIABLES is an alist with Postman variables."
177177
(ignore variables)
178178
(let (list-headers)
179179
(dolist (header (nreverse headers))
@@ -201,7 +201,7 @@ VARIABLES is a alist with Postman variables."
201201
"Format the verb footer.
202202
203203
NAME is the collection name.
204-
VARIABLES is a alist with Postman variables."
204+
VARIABLES is an alist with Postman variables."
205205
(let (list-vars)
206206
(when impostman-use-variables
207207
(dolist (var (nreverse variables))
@@ -221,7 +221,7 @@ VARIABLES is a alist with Postman variables."
221221
(defun impostman-output-verb-end (variables)
222222
"Function evaluated at the end.
223223
224-
VARIABLES is a alist with Postman variables."
224+
VARIABLES is an alist with Postman variables."
225225
(when (fboundp 'org-mode)
226226
(org-mode))
227227
(when (fboundp 'verb-mode)
@@ -237,7 +237,7 @@ VARIABLES is a alist with Postman variables."
237237
"Replace variables in a string, using restclient syntax.
238238
239239
STRING any string that can contain variables with format \"{{variable}}\".
240-
VARIABLES is a alist with Postman environment variables."
240+
VARIABLES is an alist with Postman variables."
241241
(if impostman-use-variables
242242
(replace-regexp-in-string
243243
"{{\\([^}]+\\)}}" ":\\1" (or string ""))
@@ -254,7 +254,7 @@ VARIABLES is a alist with Postman environment variables."
254254
255255
NAME is the collection name.
256256
DESCRIPTION is the collection description.
257-
VARIABLES is a alist with Postman environment variables."
257+
VARIABLES is an alist with Postman variables."
258258
(let (list-vars)
259259
(when impostman-use-variables
260260
(dolist (var (nreverse variables))
@@ -273,7 +273,8 @@ VARIABLES is a alist with Postman environment variables."
273273
274274
LEVEL is the level.
275275
NAME is the item name.
276-
DESCRIPTION is the item description."
276+
DESCRIPTION is the item description.
277+
VARIABLES is an alist with Postman variables."
277278
(ignore variables)
278279
(concat
279280
(if (<= level 2) "\n" "")
@@ -287,7 +288,8 @@ DESCRIPTION is the request description.
287288
METHOD is the HTTP method.
288289
URL is the URL.
289290
HEADERS is an alist with HTTP headers.
290-
BODY is the request body."
291+
BODY is the request body.
292+
VARIABLES is an alist with Postman variables."
291293
(ignore variables)
292294
(let (list-variables list-headers)
293295
(dolist (header (nreverse headers))
@@ -318,14 +320,16 @@ BODY is the request body."
318320
"Format the restclient footer.
319321
320322
NAME is the collection name.
321-
VARIABLES is a alist with Postman environment variables."
323+
VARIABLES is an alist with Postman variables."
322324
(ignore variables)
323325
(concat
324326
"\n"
325327
"# End of " name "\n"))
326328

327329
(defun impostman-output-restclient-end (variables)
328-
"Function evaluated at the end."
330+
"Function evaluated at the end.
331+
332+
VARIABLES is an alist with Postman variables."
329333
(ignore variables)
330334
(when (fboundp 'restclient-mode)
331335
(restclient-mode)))
@@ -388,8 +392,9 @@ HEADER is a vector with hash tables."
388392
headers))
389393

390394
(defun impostman--build-auth-query-string (auth)
391-
"Return query string parameter to add for authentication as an alist, for
392-
example: (\"key\" . \"value\"), or nil if there's no query string to add.
395+
"Return query string parameter to add for authentication as an alist.
396+
397+
For example: (\"key\" . \"value\"), or nil if there's no query string to add.
393398
394399
AUTH is a hash table."
395400
(let (query-string-items)
@@ -417,7 +422,7 @@ AUTH is a hash table."
417422
"Return the URL with updated query string parameters.
418423
419424
URL is a string.
420-
QUERY-STRING is nil or an alist with query strings to add."
425+
QUERY-STRING-ITEMS is nil or an alist with query strings to add."
421426
(dolist (query-string query-string-items)
422427
(setq url (concat
423428
url
@@ -428,8 +433,7 @@ QUERY-STRING is nil or an alist with query strings to add."
428433
url)
429434

430435
(defun impostman--build-variables (values)
431-
"Return alist with variables using values from Postman collection and
432-
environment.
436+
"Return alist with variables using Postman collection/environment.
433437
434438
VALUES is the \"variable\" read from collection (vector) or \"values\" read
435439
from environment (vector) (or concatenation of both)."
@@ -449,7 +453,7 @@ from environment (vector) (or concatenation of both)."
449453
450454
ITEMS is the \"item\" read from collection (vector).
451455
LEVEL is the level.
452-
VARIABLES is a alist with Postman variables.
456+
VARIABLES is an alist with Postman variables.
453457
OUTPUT-ALIST is an alist with the output callbacks."
454458
(dotimes (i (length items))
455459
(let* ((item (elt items i))
@@ -491,7 +495,7 @@ OUTPUT-ALIST is an alist with the output callbacks."
491495
description method2 url2 headers body2 variables)))))))))
492496

493497
(defun impostman--parse-json (collection environment output-alist)
494-
: "Parse a Postman collection using an optional Postman environment.
498+
"Parse a Postman collection using an optional Postman environment.
495499
496500
COLLECTION is a hash table with the Postman collection (parsed JSON).
497501
ENVIRONMENT is a hash table with the Postman environment (parsed JSON).
@@ -519,8 +523,7 @@ OUTPUT-ALIST is an alist with the output callbacks."
519523

520524
;;;###autoload
521525
(defun impostman-parse-file (collection environment output-alist)
522-
"Parse a file with a Postman collection, using an optional file with
523-
a Postman environment (for variables).
526+
"Parse a file with a Postman collection.
524527
525528
COLLECTION is a Postman collection filename.
526529
ENVIRONMENT is a Postman environment filename (optional).
@@ -537,8 +540,7 @@ OUTPUT-ALIST is an alist with the output callbacks."
537540

538541
;;;###autoload
539542
(defun impostman-parse-string (collection environment output-alist)
540-
"Parse a string with a Postman collection, using an optional string with
541-
a Postman environment (for variables).
543+
"Parse a string with a Postman collection.
542544
543545
COLLECTION is a string with a Postman collection.
544546
ENVIRONMENT is a string with a Postman environment (optional).
@@ -563,8 +565,9 @@ OUTPUT-ALIST is an alist with the output callbacks."
563565
(read-file-name "Postman environment file (JSON, optional): ")))
564566

565567
(defun impostman-read-output ()
566-
"Read Postman output type, which must be a key from alist
567-
`impostman-outputs-alist'.
568+
"Read Postman output type.
569+
570+
It which must be a key from alist `impostman-outputs-alist'.
568571
569572
If the alist size is 1, the value is immediately returned without asking
570573
anything."
@@ -577,17 +580,17 @@ anything."
577580
prompt impostman-outputs-alist nil t nil nil default))))
578581

579582
(defun impostman--get-output-alist (name)
580-
"Get output alist with a given NAME. A key with this name must exist in
581-
`impostman-outputs-alist'."
583+
"Get output alist with a given NAME.
584+
585+
A key with this name must exist in `impostman-outputs-alist'."
582586
(let ((output-alist (assoc name impostman-outputs-alist)))
583587
(if output-alist
584588
(symbol-value (cdr output-alist))
585589
(error (format "Output \"%s\" is not supported" name)))))
586590

587591
;;;###autoload
588592
(defun impostman-import-file (&optional collection environment output-name)
589-
"Import a file with a Postman collection, using optional file with
590-
a Postman environment (for variables).
593+
"Import a file with a Postman collection.
591594
592595
COLLECTION is a Postman collection filename.
593596
ENVIRONMENT is a Postman environment filename (optional).
@@ -601,8 +604,7 @@ OUTPUT-NAME is a string with the desired output (eg: \"verb\")."
601604

602605
;;;###autoload
603606
(defun impostman-import-string (collection environment &optional output-name)
604-
"Import a string with a Postman collection, using optional file with
605-
a Postman environment (for variables).
607+
"Import a string with a Postman collection.
606608
607609
COLLECTION is a string with a Postman collection.
608610
ENVIRONMENT is a string with a Postman environment (optional).

tests/impostman-test.el

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
(require 'impostman)
3737

3838
(defun impostman-test--get-file-contents (filename)
39-
"Get contents of filename."
39+
"Get contents of a file.
40+
41+
FILENAME is a complete path to a file."
4042
(with-temp-buffer
4143
(insert-file-contents filename)
4244
(buffer-string)))
@@ -891,11 +893,16 @@
891893
(kill-this-buffer))))
892894

893895
(defun impostman-test-output-custom-init (variables)
894-
"Initialize custom output."
896+
"Initialize custom output.
897+
898+
VARIABLES is an alist with Postman variables."
895899
(ignore variables))
896900

897901
(defun impostman-test-output-custom-replace-vars (string variables)
898-
"Format variables for custom output."
902+
"Format variables for custom output.
903+
904+
STRING is any string.
905+
VARIABLES is an alist with Postman variables."
899906
(if impostman-use-variables
900907
(replace-regexp-in-string
901908
"{{\\([^}]+\\)}}" "$(\\1)" (or string ""))
@@ -908,7 +915,11 @@
908915
(or string ""))))
909916

910917
(defun impostman-test-output-custom-header (name description variables)
911-
"Format header for custom output."
918+
"Format header for custom output.
919+
920+
NAME is the collection name.
921+
DESCRIPTION is the collection description.
922+
VARIABLES is an alist with Postman variables."
912923
(let (list-vars)
913924
(when impostman-use-variables
914925
(dolist (var (nreverse variables))
@@ -920,15 +931,27 @@
920931
(concat "\n" (string-join (nreverse list-vars) "\n") "\n")))))
921932

922933
(defun impostman-test-output-custom-item (level name description variables)
923-
"Format item for custom output."
934+
"Format item for custom output.
935+
936+
LEVEL is the level.
937+
NAME is the item name.
938+
DESCRIPTION is the item description.
939+
VARIABLES is an alist with Postman variables."
924940
(ignore variables)
925941
(concat
926942
(if (<= level 2) "\n" "")
927943
(make-string (max level 1) ?*) " " name "\n"
928944
(impostman-format-comment description)))
929945

930946
(defun impostman-test-output-custom-request (description method url headers body variables)
931-
"Format request for custom output."
947+
"Format request for custom output.
948+
949+
DESCRIPTION is the request description.
950+
METHOD is the HTTP method.
951+
URL is the URL.
952+
HEADERS is an alist with HTTP headers.
953+
BODY is the request body.
954+
VARIABLES is an alist with Postman variables."
932955
(ignore variables)
933956
(let (list-headers)
934957
(dolist (header (nreverse headers))
@@ -941,12 +964,17 @@
941964
(if (string-empty-p body) "" (concat body "\n")))))
942965

943966
(defun impostman-test-output-custom-footer (name variables)
944-
"Format footer for custom output."
967+
"Format footer for custom output.
968+
969+
NAME is the collection name.
970+
VARIABLES is an alist with Postman variables."
945971
(ignore variables)
946972
(concat "\n" "* End of " name "\n"))
947973

948974
(defun impostman-test-output-custom-end (variables)
949-
"End of custom output."
975+
"End of custom output.
976+
977+
VARIABLES is an alist with Postman variables."
950978
(ignore variables))
951979

952980
(ert-deftest impostman-test-import-file ()

0 commit comments

Comments
 (0)