@@ -177,7 +177,9 @@ be used as a prefix for the message."
177177 (or out-file (format " %s .json" in-file)))) " ;" ))
178178
179179(defsubst dbml-mode--parsedb-js (type cred &optional out-file )
180- " Assemble JS converting DBML in IN-FILE to <IN-FILE>.json or OUT-FILE."
180+ " Assemble JS converting DBML in IN-FILE to <IN-FILE>.json or OUT-FILE.
181+ Argument TYPE Database type.
182+ Argument CRED Database connection string or other credentials."
181183 (when (string= (string-trim out-file) " " ) (setq out-file nil ))
182184 (string-join
183185 `(" const conn = require(\" @dbml/connector\" ).connector"
@@ -189,7 +191,9 @@ require(\"fs\").writeFileSync(%S, c.importer.generateDbml(dbJson)))"
189191 " ;" ))
190192
191193(defun dbml-mode--highlight-index-composite (pos word )
192- " Find each column in the composite index and highlight appropriately."
194+ " Find each column in the composite index and highlight appropriately.
195+ Argument POS Beginning of column in composite index.
196+ Argument WORD Trimmed column name to look for."
193197 (let ((left 0 ) (right (length word)))
194198 (while (or (string-prefix-p " " (substring-no-properties word left right))
195199 (string-prefix-p " ," (substring-no-properties word left right)))
@@ -201,7 +205,7 @@ require(\"fs\").writeFileSync(%S, c.importer.generateDbml(dbJson)))"
201205 (+ pos left) (+ pos right) 'font-lock-variable-name-face )))
202206
203207(defun dbml-mode--validate-index-syntax (num &optional highlight )
204- " Validate whether composite index syntax matches DBML spec.
208+ " Validate composite index syntax matching DBML spec.
205209Argument NUM `match-data' group containing composite index
206210columns separated by =,=, ignoring whitespace.
207211Argument HIGHLIGHT propertizes text on top of validation marks, if non-nil."
@@ -353,7 +357,10 @@ Argument NAME-NUM `match-data' group containing table name."
353357 (if dbml-mode-jsonify-dockerized (dbml-mode--jsonify-docker)
354358 (dbml-mode--jsonify-raw)))
355359
356- (defsubst dbml-more--read-string (default &optional func &rest args )
360+ (defsubst dbml-mode--read-string (default &optional func &rest args )
361+ " Read-string with a DEFAULT value.
362+ Optional argument FUNC `read-string' or similar reader.
363+ Optional argument ARGS Arguments for func."
357364 (unless func (setq func 'read-string ))
358365 (let ((input (apply func args)))
359366 (if (string= " " input) default input)))
@@ -373,10 +380,10 @@ Argument NAME-NUM `match-data' group containing table name."
373380 (string= " mysql" type))
374381 (setq cred (format " %s ://%s " cred (read-string " Username: " )))
375382 (setq cred (format " %s :%s " cred (read-passwd " Password: " )))
376- (setq cred (format " %s @%s " cred (dbml-more --read-string
383+ (setq cred (format " %s @%s " cred (dbml-mode --read-string
377384 " localhost" nil " Host: " )))
378385 (setq cred (format " %s :%s " cred
379- (dbml-more --read-string
386+ (dbml-mode --read-string
380387 (if (string= " mysql" type) " 3306" " 5432" )
381388 nil " Port: " )))
382389 (setq cred (format " %s /%s " cred (read-string " Name: " )))
@@ -387,19 +394,19 @@ Argument NAME-NUM `match-data' group containing table name."
387394 ; ; not a typo
388395 (setq type " postgres" )))
389396 ((string= " mssql" type)
390- (setq cred (format " Server=%s " (dbml-more --read-string
397+ (setq cred (format " Server=%s " (dbml-mode --read-string
391398 " localhost" nil " Host: " )))
392- (setq cred (format " %s ,%s " cred (dbml-more --read-string
399+ (setq cred (format " %s ,%s " cred (dbml-mode --read-string
393400 " 1433" nil " Port: " )))
394401 (setq cred (format " %s ;Database=%s " cred (read-string " Name: " )))
395402 (setq cred (format " %s ;User Id=%s " cred (read-string " Username: " )))
396403 (setq cred (format " %s ;Password=%s " cred
397404 (read-passwd " Password: " )))
398405 (setq cred (format " %s ;Encrypt=%s " cred
399- (dbml-more --read-string
406+ (dbml-mode --read-string
400407 " true" nil " Encrypt (true): " )))
401408 (setq cred (format " %s ;TrustServerCertificate=%s " cred
402- (dbml-more --read-string
409+ (dbml-mode --read-string
403410 " true" nil " Trust (true): " )))
404411
405412 (let ((schemas (read-string " Schemas: (schema1,schema2)" : )))
@@ -424,7 +431,8 @@ Argument NAME-NUM `match-data' group containing table name."
424431 (expand-file-name buffer-file-truename)))))
425432
426433(defsubst dbml-mode--parsedb-raw-cb (proc out-file &rest _ )
427- " Handler for `node' (`@dbml/core' ) PROC."
434+ " Handler for `node' (`@dbml/core' ) PROC.
435+ Argument OUT-FILE Generated DBML destination."
428436 (kill-buffer (get-buffer-create (process-name proc)))
429437 (find-file-other-window out-file))
430438
@@ -457,7 +465,10 @@ Argument NAME-NUM `match-data' group containing table name."
457465 (switch-to-buffer-other-window buff))))
458466
459467(defun dbml-mode--parsedb-raw (type cred &optional out-file )
460- " Generate JSON for the current buffer with `node' (`@dbml/core' )."
468+ " Generate JSON for the current buffer with `node' (`@dbml/core' ).
469+ Argument TYPE Database type.
470+ Argument CRED Database connection string or other credentials.
471+ Optional argument OUT-FILE Generated DBML destination."
461472 (interactive )
462473 (let* ((temp-name (make-temp-name " " ))
463474 (proc-name (format " dbml-mode-parsedb-%s " temp-name))
@@ -485,7 +496,8 @@ Argument NAME-NUM `match-data' group containing table name."
485496 (expand-file-name buffer-file-truename)))))
486497
487498(defun dbml-mode--parsedb-docker-run-cb (proc old-file out-file &rest _ )
488- " Handler for `docker run' PROC."
499+ " Handler for `docker run' PROC.
500+ Argument OLD-FILE Generated file to move to OUT-FILE."
489501 (kill-buffer (get-buffer-create (process-name proc)))
490502 (rename-file old-file out-file t )
491503 (find-file-other-window out-file))
@@ -533,7 +545,10 @@ Argument NAME-NUM `match-data' group containing table name."
533545
534546(defun dbml-mode--parsedb-docker-build-cb
535547 (proc type cred &optional out-file &rest _)
536- " Handler for `docker build' PROC."
548+ " Handler for `docker build' PROC.
549+ Argument TYPE Database type.
550+ Argument CRED Database connection string or other credentials.
551+ Optional argument OUT-FILE Generated DBML destination."
537552 (let* ((proc-name (process-name proc))
538553 (buff (get-buffer-create proc-name))
539554 (full-path (expand-file-name buffer-file-truename))
@@ -603,7 +618,10 @@ Argument PROC is a handle from previous process checking for image presence."
603618(defun dbml-mode--parsedb-docker-build
604619 (proc type cred &optional out-file &rest _)
605620 " Build Docker image for `node' (`@dbml/core' ).
606- Argument PROC is a handle from previous process checking for image presence."
621+ Argument PROC is a handle from previous process checking for image presence.
622+ Argument TYPE Database type.
623+ Argument CRED Database connection string or other credentials.
624+ Optional argument OUT-FILE Generated DBML destination."
607625 (let* ((dockerfile
608626 (string-join
609627 '(" FROM node:alpine"
@@ -661,7 +679,10 @@ Argument PROC is a handle from previous process checking for image presence."
661679 nil " dbml-mode-check-image" )))
662680
663681(defun dbml-mode--parsedb-docker (type cred &optional out-file )
664- " Generate JSON for the current buffer with dockerized `@dbml/core' ."
682+ " Generate JSON for the current buffer with dockerized `@dbml/core' .
683+ Argument TYPE Database type.
684+ Argument CRED Database connection string or other credentials.
685+ Optional argument OUT-FILE Generated DBML destination."
665686 (interactive )
666687 (let* ((temp-name (make-temp-name " " ))
667688 (proc-name (format " dbml-mode-parsedb-%s " temp-name))
0 commit comments