mirror of
https://github.com/Oxalide/vsphere-influxdb-go.git
synced 2023-10-10 11:36:51 +00:00
add vendoring with go dep
This commit is contained in:
3
vendor/github.com/vmware/govmomi/govc/emacs/.gitignore
generated
vendored
Normal file
3
vendor/github.com/vmware/govmomi/govc/emacs/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.cask
|
||||
elpa
|
||||
*.elc
|
||||
10
vendor/github.com/vmware/govmomi/govc/emacs/Cask
generated
vendored
Normal file
10
vendor/github.com/vmware/govmomi/govc/emacs/Cask
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
(source gnu)
|
||||
(source melpa)
|
||||
|
||||
(package-file "govc.el")
|
||||
|
||||
(development
|
||||
(depends-on "dash")
|
||||
(depends-on "json-mode")
|
||||
(depends-on "magit")
|
||||
(depends-on "s"))
|
||||
27
vendor/github.com/vmware/govmomi/govc/emacs/Makefile
generated
vendored
Normal file
27
vendor/github.com/vmware/govmomi/govc/emacs/Makefile
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
CASK = cask
|
||||
EMACS_BIN ?= emacs
|
||||
EMACS_FLAGS =
|
||||
EMACS_EXEC = $(CASK) exec $(EMACS_BIN) --no-site-file --no-site-lisp --batch $(EMACS_FLAGS)
|
||||
|
||||
OBJECTS = govc.elc
|
||||
|
||||
elpa:
|
||||
$(CASK) install
|
||||
$(CASK) update
|
||||
touch $@
|
||||
|
||||
.PHONY: build test docs clean
|
||||
|
||||
build: elpa $(OBJECTS)
|
||||
|
||||
test: build docs
|
||||
$(EMACS_EXEC) -l test/make.el -f make-test
|
||||
|
||||
docs: build
|
||||
$(EMACS_EXEC) -l test/make.el -f make-docs
|
||||
clean:
|
||||
rm -f $(OBJECTS) elpa
|
||||
rm -rf .cask
|
||||
|
||||
%.elc: %.el
|
||||
$(EMACS_EXEC) -f batch-byte-compile $<
|
||||
290
vendor/github.com/vmware/govmomi/govc/emacs/README.md
generated
vendored
Normal file
290
vendor/github.com/vmware/govmomi/govc/emacs/README.md
generated
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
# govc.el
|
||||
|
||||
Interface to govc for managing VMware ESXi and vCenter.
|
||||
|
||||
|
||||
The goal of this package is to provide a simple interface for commonly used
|
||||
govc commands within Emacs. This includes table based inventory/state modes
|
||||
for vms, hosts, datastores and pools. The keymap for each mode provides
|
||||
shortcuts for easily feeding the data in view to other govc commands.
|
||||
|
||||
Within the various govc modes, press `?` to see a popup menu of options.
|
||||
A menu bar is enabled for certain modes, such as `govc-vm-mode` and `govc-host-mode`.
|
||||
There is also a `govc` menu at all times under the `Tools` menu.
|
||||
|
||||
The recommended way to install govc.el is via MELPA (http://melpa.org/).
|
||||
|
||||
## govc-mode
|
||||
|
||||
Running `govc-global-mode` creates key bindings to the various govc modes.
|
||||
The default prefix is `C-c ;` and can be changed by setting `govc-keymap-prefix`.
|
||||
|
||||
### govc-command-map
|
||||
|
||||
Keybinding | Description
|
||||
---------------|------------------------------------------------------------
|
||||
<kbd>h</kbd> | Host info via govc
|
||||
<kbd>p</kbd> | Pool info via govc
|
||||
<kbd>v</kbd> | VM info via govc
|
||||
<kbd>s</kbd> | Datastore info via govc
|
||||
|
||||
### govc-urls
|
||||
|
||||
List of URLs for use with `govc-session`.
|
||||
The `govc-session-name` displayed by `govc-mode-line` uses `url-target` (anchor)
|
||||
if set, otherwise `url-host` is used.
|
||||
|
||||
Example:
|
||||
```
|
||||
(setq govc-urls `("root:vagrant@localhost:18443#Vagrant-ESXi"
|
||||
"root:password@192.168.1.192#Intel-NUC"
|
||||
"Administrator@vsphere.local:password!@vcva-clovervm"))
|
||||
```
|
||||
To enter a URL that is not in the list, prefix `universal-argument`, for example:
|
||||
|
||||
`C-u M-x govc-vm`
|
||||
|
||||
To avoid putting your credentials in a variable, you can use the
|
||||
auth-source search integration.
|
||||
|
||||
```
|
||||
(setq govc-urls `("myserver-vmware-2"))
|
||||
```
|
||||
|
||||
And then put this line in your `auth-sources` (e.g. `~/.authinfo.gpg`):
|
||||
```
|
||||
machine myserver-vmware-2 login tzz password mypass url "myserver-vmware-2.some.domain.here:443?insecure=true"
|
||||
```
|
||||
|
||||
Which will result in the URL "tzz:mypass@myserver-vmware-2.some.domain.here:443?insecure=true".
|
||||
For more details on `auth-sources`, see Info node `(auth) Help for users`.
|
||||
|
||||
When in `govc-vm` or `govc-host` mode, a default URL is composed with the
|
||||
current session credentials and the IP address of the current vm/host and
|
||||
the vm/host name as the session name. This makes it easier to connect to
|
||||
nested ESX/vCenter VMs or directly to an ESX host.
|
||||
|
||||
### govc-session-url
|
||||
|
||||
ESX or vCenter URL set by `govc-session` via `govc-urls` selection.
|
||||
|
||||
### govc-session-insecure
|
||||
|
||||
Skip verification of server certificate when true.
|
||||
This variable is set to the value of the `GOVC_INSECURE` env var by default.
|
||||
It can also be set per-url via the query string (insecure=true). For example:
|
||||
```
|
||||
(setq govc-urls `("root:password@hostname?insecure=true"))
|
||||
```
|
||||
|
||||
### govc-session-datacenter
|
||||
|
||||
Datacenter to use for the current `govc-session`.
|
||||
If the endpoint has a single Datacenter it will be used by default, otherwise
|
||||
`govc-session` will prompt for selection. It can also be set per-url via the
|
||||
query string. For example:
|
||||
```
|
||||
(setq govc-urls `("root:password@hostname?datacenter=dc1"))
|
||||
```
|
||||
|
||||
### govc-session-datastore
|
||||
|
||||
Datastore to use for the current `govc-session`.
|
||||
If the endpoint has a single Datastore it will be used by default, otherwise
|
||||
`govc-session` will prompt for selection. It can also be set per-url via the
|
||||
query string. For example:
|
||||
```
|
||||
(setq govc-urls `("root:password@hostname?datastore=vsanDatastore"))
|
||||
```
|
||||
|
||||
### govc-session-network
|
||||
|
||||
Network to use for the current `govc-session`.
|
||||
|
||||
## govc-tabulated-list-mode
|
||||
|
||||
Generic table bindings to mark/unmark rows.
|
||||
|
||||
In addition to any hooks its parent mode `tabulated-list-mode` might have run,
|
||||
this mode runs the hook `govc-tabulated-list-mode-hook`, as the final step
|
||||
during initialization.
|
||||
|
||||
### govc-tabulated-list-mode-map
|
||||
|
||||
Keybinding | Description
|
||||
---------------|------------------------------------------------------------
|
||||
<kbd>m</kbd> | Mark and move to the next line
|
||||
<kbd>u</kbd> | Unmark and move to the next line
|
||||
<kbd>t</kbd> | Toggle mark
|
||||
<kbd>U</kbd> | Unmark all
|
||||
<kbd>M-&</kbd> | Shell CMD with current `govc-session` exported as GOVC_ env vars
|
||||
<kbd>M-w</kbd> | Copy current selection or region to the kill ring
|
||||
<kbd>M-E</kbd> | Export session to `process-environment` and `kill-ring`
|
||||
|
||||
## govc-host-mode
|
||||
|
||||
Major mode for handling a list of govc hosts.
|
||||
|
||||
In addition to any hooks its parent mode `govc-tabulated-list-mode` might have run,
|
||||
this mode runs the hook `govc-host-mode-hook`, as the final step
|
||||
during initialization.
|
||||
|
||||
### govc-host-mode-map
|
||||
|
||||
Keybinding | Description
|
||||
---------------|------------------------------------------------------------
|
||||
<kbd>E</kbd> | Events via govc events -n `govc-max-events`
|
||||
<kbd>L</kbd> | Logs via govc logs -n `govc-max-events`
|
||||
<kbd>J</kbd> | JSON via govc host
|
||||
<kbd>M</kbd> | Metrics info
|
||||
<kbd>N</kbd> | Netstat via `govc-esxcli-netstat-info` with current host id
|
||||
<kbd>O</kbd> | Object browser via govc object
|
||||
<kbd>c</kbd> | Connect new session for the current govc mode
|
||||
<kbd>p</kbd> | Pool-mode with current session
|
||||
<kbd>s</kbd> | Datastore-mode with current session
|
||||
<kbd>v</kbd> | VM-mode with current session
|
||||
|
||||
## govc-pool-mode
|
||||
|
||||
Major mode for handling a list of govc pools.
|
||||
|
||||
In addition to any hooks its parent mode `govc-tabulated-list-mode` might have run,
|
||||
this mode runs the hook `govc-pool-mode-hook`, as the final step
|
||||
during initialization.
|
||||
|
||||
### govc-pool-mode-map
|
||||
|
||||
Keybinding | Description
|
||||
---------------|------------------------------------------------------------
|
||||
<kbd>D</kbd> | Destroy via `govc-pool-destroy` on the pool selection
|
||||
<kbd>E</kbd> | Events via govc events -n `govc-max-events`
|
||||
<kbd>J</kbd> | JSON via govc pool
|
||||
<kbd>M</kbd> | Metrics info
|
||||
<kbd>O</kbd> | Object browser via govc object
|
||||
<kbd>c</kbd> | Connect new session for the current govc mode
|
||||
<kbd>h</kbd> | Host-mode with current session
|
||||
<kbd>s</kbd> | Datastore-mode with current session
|
||||
<kbd>v</kbd> | VM-mode with current session
|
||||
|
||||
## govc-datastore-mode
|
||||
|
||||
Major mode for govc datastore.info.
|
||||
|
||||
In addition to any hooks its parent mode `tabulated-list-mode` might have run,
|
||||
this mode runs the hook `govc-datastore-mode-hook`, as the final step
|
||||
during initialization.
|
||||
|
||||
### govc-datastore-mode-map
|
||||
|
||||
Keybinding | Description
|
||||
---------------|------------------------------------------------------------
|
||||
<kbd>J</kbd> | JSON via govc datastore
|
||||
<kbd>M</kbd> | Metrics info
|
||||
<kbd>O</kbd> | Object browser via govc object
|
||||
<kbd>RET</kbd> | Browse datastore
|
||||
<kbd>c</kbd> | Connect new session for the current govc mode
|
||||
<kbd>h</kbd> | Host-mode with current session
|
||||
<kbd>p</kbd> | Pool-mode with current session
|
||||
<kbd>v</kbd> | VM-mode with current session
|
||||
|
||||
## govc-datastore-ls-mode
|
||||
|
||||
Major mode govc datastore.ls.
|
||||
|
||||
In addition to any hooks its parent mode `govc-tabulated-list-mode` might have run,
|
||||
this mode runs the hook `govc-datastore-ls-mode-hook`, as the final step
|
||||
during initialization.
|
||||
|
||||
### govc-datastore-ls-mode-map
|
||||
|
||||
Keybinding | Description
|
||||
---------------|------------------------------------------------------------
|
||||
<kbd>J</kbd> | JSON via govc datastore
|
||||
<kbd>S</kbd> | Search via govc datastore
|
||||
<kbd>D</kbd> | Delete selected datastore paths
|
||||
<kbd>T</kbd> | Tail datastore file
|
||||
<kbd>+</kbd> | Mkdir via govc datastore
|
||||
<kbd>DEL</kbd> | Up to parent folder
|
||||
<kbd>RET</kbd> | Open datastore folder or file
|
||||
|
||||
## govc-vm-mode
|
||||
|
||||
Major mode for handling a list of govc vms.
|
||||
|
||||
In addition to any hooks its parent mode `govc-tabulated-list-mode` might have run,
|
||||
this mode runs the hook `govc-vm-mode-hook`, as the final step
|
||||
during initialization.
|
||||
|
||||
### govc-vm-mode-map
|
||||
|
||||
Keybinding | Description
|
||||
---------------|------------------------------------------------------------
|
||||
<kbd>E</kbd> | Events via govc events -n `govc-max-events`
|
||||
<kbd>J</kbd> | JSON via govc vm
|
||||
<kbd>O</kbd> | Object browser via govc object
|
||||
<kbd>X</kbd> | ExtraConfig via `govc-vm-extra-config` on the current selection
|
||||
<kbd>RET</kbd> | Devices via `govc-device` on the current selection
|
||||
<kbd>C</kbd> | Console screenshot via `govc-vm-screen` on the current selection
|
||||
<kbd>V</kbd> | VNC via `govc-vm-vnc` on the current selection
|
||||
<kbd>D</kbd> | Destroy via `govc-vm-destroy` on the current selection
|
||||
<kbd>^</kbd> | Start via `govc-vm-start` on the current selection
|
||||
<kbd>!</kbd> | Shutdown via `govc-vm-shutdown` on the current selection
|
||||
<kbd>@</kbd> | Reboot via `govc-vm-reboot` on the current selection
|
||||
<kbd>&</kbd> | Suspend via `govc-vm-suspend` on the current selection
|
||||
<kbd>H</kbd> | Host info via `govc-host` with host(s) of current selection
|
||||
<kbd>M</kbd> | Metrics info
|
||||
<kbd>P</kbd> | Ping VM
|
||||
<kbd>S</kbd> | Datastore via `govc-datastore-ls` with datastore of current selection
|
||||
<kbd>c</kbd> | Connect new session for the current govc mode
|
||||
<kbd>h</kbd> | Host-mode with current session
|
||||
<kbd>p</kbd> | Pool-mode with current session
|
||||
<kbd>s</kbd> | Datastore-mode with current session
|
||||
|
||||
## govc-device-mode
|
||||
|
||||
Major mode for handling a govc device.
|
||||
|
||||
In addition to any hooks its parent mode `govc-tabulated-list-mode` might have run,
|
||||
this mode runs the hook `govc-device-mode-hook`, as the final step
|
||||
during initialization.
|
||||
|
||||
### govc-device-mode-map
|
||||
|
||||
Keybinding | Description
|
||||
---------------|------------------------------------------------------------
|
||||
<kbd>J</kbd> | JSON via govc device
|
||||
<kbd>RET</kbd> | Tabulated govc device
|
||||
|
||||
## govc-object-mode
|
||||
|
||||
Major mode for handling a govc object.
|
||||
|
||||
In addition to any hooks its parent mode `govc-tabulated-list-mode` might have run,
|
||||
this mode runs the hook `govc-object-mode-hook`, as the final step
|
||||
during initialization.
|
||||
|
||||
### govc-object-mode-map
|
||||
|
||||
Keybinding | Description
|
||||
---------------|------------------------------------------------------------
|
||||
<kbd>J</kbd> | JSON object selection via govc object
|
||||
<kbd>N</kbd> | Next managed object reference
|
||||
<kbd>O</kbd> | Object browser via govc object
|
||||
<kbd>DEL</kbd> | Parent object selection if reachable, otherwise prompt with `govc-object-history`
|
||||
<kbd>RET</kbd> | Expand object selection via govc object
|
||||
|
||||
## govc-metric-mode
|
||||
|
||||
Major mode for handling a govc metric.
|
||||
|
||||
In addition to any hooks its parent mode `govc-tabulated-list-mode` might have run,
|
||||
this mode runs the hook `govc-metric-mode-hook`, as the final step
|
||||
during initialization.
|
||||
|
||||
### govc-metric-mode-map
|
||||
|
||||
Keybinding | Description
|
||||
---------------|------------------------------------------------------------
|
||||
<kbd>RET</kbd> | Sample metrics
|
||||
<kbd>P</kbd> | Plot metric sample
|
||||
<kbd>s</kbd> | Select metric names
|
||||
1567
vendor/github.com/vmware/govmomi/govc/emacs/govc.el
generated
vendored
Normal file
1567
vendor/github.com/vmware/govmomi/govc/emacs/govc.el
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
138
vendor/github.com/vmware/govmomi/govc/emacs/test/govc-test.el
generated
vendored
Normal file
138
vendor/github.com/vmware/govmomi/govc/emacs/test/govc-test.el
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
(defconst testsuite-dir
|
||||
(if load-file-name
|
||||
(file-name-directory load-file-name)
|
||||
;; Fall back to default directory (in case of M-x eval-buffer)
|
||||
default-directory)
|
||||
"Directory of the test suite.")
|
||||
|
||||
(defconst govc-test-helper-path
|
||||
(concat (expand-file-name (concat testsuite-dir "/../../test/test_helper.bash"))))
|
||||
|
||||
(load (expand-file-name "../govc" testsuite-dir) nil :no-message)
|
||||
|
||||
(ert-deftest test-govc-url-parse ()
|
||||
(dolist (u '("root:vagrant@localhost:18443"
|
||||
"Administrator@vsphere.local:vagrant@localhost"
|
||||
"https://root:vagrant@localhost:18443/sdk"
|
||||
"https://Administrator@vsphere.local:vagrant@localhost/sdk"))
|
||||
(should (equal u (url-recreate-url (govc-url-parse u))))))
|
||||
|
||||
(ert-deftest test-govc-session-set-url ()
|
||||
(should (equal govc-session-insecure nil))
|
||||
(should (equal govc-session-datacenter nil))
|
||||
(with-temp-buffer
|
||||
(govc-session-set-url "vc.example.com?insecure=true&datacenter=foo&ignored=true")
|
||||
(should (equal govc-session-insecure "true"))
|
||||
(should (equal govc-session-datacenter "foo"))
|
||||
(should (equal govc-session-datastore nil))))
|
||||
|
||||
(ert-deftest test-govc-copy-environment ()
|
||||
(let ((process-environment)
|
||||
(govc-session-url "vc.example.com")
|
||||
(govc-session-insecure "false")
|
||||
(govc-session-datacenter "dc1")
|
||||
(govc-session-datastore "ds1")
|
||||
(govc-session-network "net1"))
|
||||
(govc-export-environment '-)
|
||||
(dolist (e govc-environment-map)
|
||||
(should (equal nil (getenv (car e)))))
|
||||
(govc-export-environment (universal-argument))
|
||||
(dolist (e govc-environment-map)
|
||||
(should (not (equal nil (getenv (car e))))))))
|
||||
|
||||
(defun govc-test-env ()
|
||||
(let ((url (getenv "GOVC_TEST_URL")))
|
||||
(unless url
|
||||
(ert-skip "env GOVC_TEST_URL not set"))
|
||||
(setq govc-session-url url
|
||||
govc-session-insecure "true")))
|
||||
|
||||
(defun govc-test-helper (arg)
|
||||
(shell-command-to-string (format "bash -c \"source %s; %s\"" govc-test-helper-path arg)))
|
||||
|
||||
(defun govc-test-new-vm ()
|
||||
(s-trim-right (govc-test-helper "new_empty_vm")))
|
||||
|
||||
(defun govc-test-new-id ()
|
||||
(s-trim-right (govc-test-helper "new_id")))
|
||||
|
||||
(defun govc-test-teardown ()
|
||||
(ignore-errors
|
||||
(govc-test-helper "teardown")))
|
||||
|
||||
(ert-deftest test-govc-vm-info ()
|
||||
(govc-test-env)
|
||||
(unwind-protect
|
||||
(let ((id (govc-test-new-vm)))
|
||||
(govc-json-info "vm.info" (list id))
|
||||
(with-current-buffer "*govc-json*"
|
||||
(goto-char (point-min))
|
||||
(let ((data (json-read)))
|
||||
(should (= (length data) 1))
|
||||
(should (cdr (assq 'VirtualMachines data)))))
|
||||
|
||||
(govc-json-info "vm.info" (list "ENOENT"))
|
||||
(with-current-buffer "*govc-json*"
|
||||
(goto-char (point-min))
|
||||
(let ((data (json-read)))
|
||||
(should (= (length data) 1))
|
||||
(should (not (cdr (assq 'VirtualMachines data))))))
|
||||
|
||||
(let ((govc-args (list id))
|
||||
(len1)
|
||||
(len2))
|
||||
(setq len1 (length (govc-vm-extra-config)))
|
||||
(should (>= len1 1))
|
||||
(govc "vm.change" "-vm" id
|
||||
"-e" "govc-test-one=1"
|
||||
"-e" "govc-test-two:2.2=2"
|
||||
;; test that we don't choke on \n
|
||||
"-e" "foo=bar
|
||||
baz")
|
||||
(setq len2 (length (govc-vm-extra-config)))
|
||||
|
||||
(should (= (- len2 len1) 3)))
|
||||
|
||||
(let ((govc-filter "*"))
|
||||
(should (>= (length (govc-vm-info)) 1)))
|
||||
|
||||
(let ((govc-filter "ENOENT"))
|
||||
(should (= (length (govc-vm-info)) 0)))
|
||||
|
||||
(govc-vm-screen id))
|
||||
(govc-test-teardown)))
|
||||
|
||||
(ert-deftest test-govc-datastore-ls-entries ()
|
||||
(govc-test-env)
|
||||
(unwind-protect
|
||||
(let ((id (govc-test-new-id)))
|
||||
(should (>= (length (govc-datastore-ls-entries)) 1))
|
||||
|
||||
(let ((govc-filter (concat id "/")))
|
||||
(should-error (govc-datastore-ls-entries))
|
||||
(govc "datastore.mkdir" id)
|
||||
(should (= (length (govc-datastore-ls-entries)) 0))
|
||||
(dotimes (i 3)
|
||||
(govc "datastore.mkdir" (format "%s/dir %d" id i)))
|
||||
(let ((entries (govc-datastore-ls-entries)))
|
||||
(should (= (length entries) 3))
|
||||
(should (s-starts-with? (concat id "/dir ") (caar entries))))))
|
||||
(govc-test-teardown)))
|
||||
|
||||
(ert-deftest test-govc-pool-ls ()
|
||||
(govc-test-env)
|
||||
(unwind-protect
|
||||
(let* ((pools (govc-ls-pool))
|
||||
(num (length pools))
|
||||
(path (concat (car pools) "/" (govc-test-new-id))))
|
||||
(should (>= num 1))
|
||||
(message "%d existing pools [%S]" num pools)
|
||||
(govc "pool.create" path)
|
||||
(setq pools (govc-ls-pool))
|
||||
(govc-pool-destroy path)
|
||||
(should (= (- (length pools) num) 1)))
|
||||
(govc-test-teardown)))
|
||||
|
||||
(ert-deftest test-govc-about ()
|
||||
(govc-test-env)
|
||||
(govc "about"))
|
||||
59
vendor/github.com/vmware/govmomi/govc/emacs/test/make.el
generated
vendored
Executable file
59
vendor/github.com/vmware/govmomi/govc/emacs/test/make.el
generated
vendored
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env emacs --script
|
||||
|
||||
(let ((current-directory (file-name-directory load-file-name)))
|
||||
(setq project-test-path (expand-file-name "." current-directory))
|
||||
(setq project-root-path (expand-file-name ".." current-directory)))
|
||||
|
||||
(add-to-list 'load-path project-root-path)
|
||||
(add-to-list 'load-path project-test-path)
|
||||
|
||||
(require 'lisp-mnt)
|
||||
(require 'govc)
|
||||
(require 's)
|
||||
|
||||
(defun make-test ()
|
||||
(dolist (test-file (or argv (directory-files project-test-path t "-test.el$")))
|
||||
(load test-file nil t))
|
||||
(ert-run-tests-batch-and-exit t))
|
||||
|
||||
(defun govc-help ()
|
||||
"Summary of govc modes in markdown format."
|
||||
(interactive)
|
||||
(with-help-window (help-buffer) ; TODO: this turned into a mess, but does the job of generating README.md from govc.el
|
||||
(dolist (kind '(govc-mode govc-urls
|
||||
govc-session-url govc-session-insecure govc-session-datacenter govc-session-datastore govc-session-network
|
||||
tabulated-list host pool datastore datastore-ls vm device object metric))
|
||||
(let* ((name (if (boundp kind) (symbol-name kind) (format "govc-%s-mode" kind)))
|
||||
(map (if (equal 'govc-mode kind) 'govc-command-map (intern (concat name "-map"))))
|
||||
(doc (lambda (f &optional all)
|
||||
(let* ((txt (if (functionp f) (documentation f t) (documentation-property f 'variable-documentation)))
|
||||
(ix (if all (length txt) (s-index-of "." txt))))
|
||||
(s-replace (format "\n\n\\\{%s\}" (concat name "-map")) ""
|
||||
(s-replace "'" "`" (substring txt 0 ix)))))))
|
||||
(princ (concat (s-repeat (if (and (boundp kind) (not (fboundp kind))) 3 2) "#") " " name "\n"))
|
||||
(princ (concat "\n" (funcall doc (intern name) t) "\n\n"))
|
||||
(when (boundp map)
|
||||
(princ (concat "### " (symbol-name map) "\n\n"))
|
||||
(princ "Keybinding | Description\n")
|
||||
(princ "---------------|------------------------------------------------------------\n")
|
||||
(dolist (kl (govc-keymap-list (symbol-value map)))
|
||||
(let ((key (govc-key-description (car kl))))
|
||||
(princ (format "<kbd>%s</kbd>%s| %s\n" key (s-repeat (- 4 (length key)) " ") (funcall doc (nth 2 kl))))))
|
||||
(princ "\n"))))))
|
||||
|
||||
(defun make-docs ()
|
||||
(let ((commentary)
|
||||
(summary))
|
||||
(with-current-buffer (find-file-noselect (concat project-root-path "/govc.el"))
|
||||
(setq commentary (s-replace ";;; Commentary:" "" (lm-commentary))
|
||||
summary (lm-summary)))
|
||||
(let ((readme (find-file-noselect (concat project-root-path "/README.md"))))
|
||||
(with-current-buffer readme
|
||||
(erase-buffer)
|
||||
(govc-help)
|
||||
(with-current-buffer (help-buffer)
|
||||
(copy-to-buffer readme (point-min) (point-max)))
|
||||
(goto-char (point-min))
|
||||
(insert (concat "# govc.el\n\n" summary ".\n"))
|
||||
(insert (s-replace "'" "`" (replace-regexp-in-string ";; ?" "" commentary t t)))
|
||||
(save-buffer 0)))))
|
||||
Reference in New Issue
Block a user