github.com/vmware/govmomi@v0.43.0/govc/emacs/test/make.el (about) 1 #!/usr/bin/env emacs --script 2 3 (let ((current-directory (file-name-directory load-file-name))) 4 (setq project-test-path (expand-file-name "." current-directory)) 5 (setq project-root-path (expand-file-name ".." current-directory))) 6 7 (add-to-list 'load-path project-root-path) 8 (add-to-list 'load-path project-test-path) 9 10 (require 'lisp-mnt) 11 (require 'govc) 12 (require 's) 13 14 (defun make-test () 15 (dolist (test-file (or argv (directory-files project-test-path t "-test.el$"))) 16 (load test-file nil t)) 17 (ert-run-tests-batch-and-exit t)) 18 19 (defun govc-help () 20 "Summary of govc modes in markdown format." 21 (interactive) 22 (with-help-window (help-buffer) ; TODO: this turned into a mess, but does the job of generating README.md from govc.el 23 (dolist (kind '(govc-mode govc-urls 24 govc-session-url govc-session-insecure govc-session-datacenter govc-session-datastore govc-session-network 25 tabulated-list host pool datastore datastore-ls vm device object metric)) 26 (let* ((name (if (boundp kind) (symbol-name kind) (format "govc-%s-mode" kind))) 27 (map (if (equal 'govc-mode kind) 'govc-command-map (intern (concat name "-map")))) 28 (doc (lambda (f &optional all) 29 (let* ((txt (if (functionp f) (documentation f t) (documentation-property f 'variable-documentation))) 30 (ix (if all (length txt) (s-index-of "." txt)))) 31 (s-replace (format "\n\n\\\{%s\}" (concat name "-map")) "" 32 (s-replace "'" "`" (substring txt 0 ix))))))) 33 (princ (concat (s-repeat (if (and (boundp kind) (not (fboundp kind))) 3 2) "#") " " name "\n")) 34 (princ (concat "\n" (funcall doc (intern name) t) "\n\n")) 35 (when (boundp map) 36 (princ (concat "### " (symbol-name map) "\n\n")) 37 (princ "Keybinding | Description\n") 38 (princ "---------------|------------------------------------------------------------\n") 39 (dolist (kl (govc-keymap-list (symbol-value map))) 40 (let ((key (govc-key-description (car kl)))) 41 (princ (format "<kbd>%s</kbd>%s| %s\n" key (s-repeat (- 4 (length key)) " ") (funcall doc (nth 2 kl)))))) 42 (princ "\n")))))) 43 44 (defun make-docs () 45 (let ((commentary) 46 (summary)) 47 (with-current-buffer (find-file-noselect (concat project-root-path "/govc.el")) 48 (setq commentary (s-replace ";;; Commentary:" "" (lm-commentary)) 49 summary (lm-summary))) 50 (let ((readme (find-file-noselect (concat project-root-path "/README.md")))) 51 (with-current-buffer readme 52 (erase-buffer) 53 (govc-help) 54 (with-current-buffer (help-buffer) 55 (copy-to-buffer readme (point-min) (point-max))) 56 (goto-char (point-min)) 57 (insert (concat "# govc.el\n\n" summary ".\n")) 58 (insert (s-replace "'" "`" (replace-regexp-in-string ";; ?" "" commentary t t))) 59 (save-buffer 0)))))