From 134d726321478b93d0b76d757fc83a958f31e2fd Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 17 Jul 2024 18:14:06 +1200 Subject: [PATCH] phobos.el: add support for viewing dub package documentation --- phobos.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/phobos.el b/phobos.el index 6268609..6b8fd45 100644 --- a/phobos.el +++ b/phobos.el @@ -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 ." 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 ." + (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)