phobos.el: add support for viewing dub package documentation

This commit is contained in:
Jeremy Baxter 2024-07-17 18:14:06 +12:00
parent 98bc3c6095
commit 134d726321

View file

@ -27,6 +27,8 @@
"Web browser to use when opening documentation with `phobos'.")
(defvar phobos-root "https://dlang.org/library"
"Root URL to use when viewing documentation with `phobos'.")
(defvar phobos-dpldocs-domain "dpldocs.info"
"Root domain to use when viewing documentation on dub packages with `dub-doc'.")
(defun phobos (symbol)
"View the documentation on SYMBOL from the Phobos documentation.
@ -42,4 +44,20 @@ information on Phobos and the D programming language, see <https://dlang.org>."
phobos-browser phobos-root
(string-replace "." "/" symbol))))
(defun dub-doc (package &optional symbol)
"View the documentation on SYMBOL from the dub package PACKAGE.
PACKAGE is the name of a package listed on the code.dlang.org registry.
For more information on SYMBOL, see the documentation for `phobos'. If
SYMBOL is not provided, the contents of PACKAGE is displayed instead.
Support for dub package documentation is provided by Adam Ruppe's
site hosted at <https://dpldocs.info>."
(interactive "MPackage name: \nMModule or symbol: ")
(or symbol (setq symbol "index")) ; index.html
(shell-command (format "%s https://%s.%s/%s.html"
phobos-browser package phobos-dpldocs-domain symbol)))
(defalias 'view-dub-documentation 'dub-doc)
(provide 'phobos)