From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Y. E. via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#53205: 28.0.90; [PATCH] GNU ELPA: Provide more control over linked documentation Date: Wed, 12 Jan 2022 13:47:30 +0200 Message-ID: Reply-To: "Y. E." Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36184"; mail-complaints-to="usenet@ciao.gmane.io" To: 53205@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 12 13:07:17 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7cPM-0009AU-3l for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Jan 2022 13:07:16 +0100 Original-Received: from localhost ([::1]:59090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7cPK-0001NK-KH for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Jan 2022 07:07:14 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7c6l-0006D9-FF for bug-gnu-emacs@gnu.org; Wed, 12 Jan 2022 06:48:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35215) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7c6j-0006Nb-Sw for bug-gnu-emacs@gnu.org; Wed, 12 Jan 2022 06:48:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n7c6j-00012t-RX for bug-gnu-emacs@gnu.org; Wed, 12 Jan 2022 06:48:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Y. E. Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 Jan 2022 11:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 53205 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16419880623887 (code B ref -1); Wed, 12 Jan 2022 11:48:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Jan 2022 11:47:42 +0000 Original-Received: from localhost ([127.0.0.1]:56351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n7c6P-00010Y-L1 for submit@debbugs.gnu.org; Wed, 12 Jan 2022 06:47:42 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:47276) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n7c6O-00010M-9g for submit@debbugs.gnu.org; Wed, 12 Jan 2022 06:47:40 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7c6N-0005XU-GT for bug-gnu-emacs@gnu.org; Wed, 12 Jan 2022 06:47:40 -0500 Original-Received: from out0.migadu.com ([94.23.1.103]:21287) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7c6J-0006Lx-Q4 for bug-gnu-emacs@gnu.org; Wed, 12 Jan 2022 06:47:39 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ego.team; s=key1; t=1641988051; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type; bh=W+WP6yLr0zEaSaa0Pnzi11f8mdd+nttsEezER6yN05o=; b=bY7p7FDRoQbkJyDijEPJX1x59gmeFvFA188hFc9jU2L3q0aMvGSQ6Nov0iEPCa8wJArcSw vlBCPm1YaMZ+z8fSKr2jAvnNAgUX1daKED/WXFLKNoRNL38slT7UgVwUgzr5sZYxR+J+fT AuLwvHk4J/wxtCuXGWZwnvYdeRGm5uI= X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: ego.team Received-SPF: pass client-ip=94.23.1.103; envelope-from=yet@ego.team; helo=out0.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" X-ACL-Warn: , Y. E. Xref: news.gmane.io gmane.emacs.bugs:223992 Archived-At: --=-=-= Content-Type: text/plain The introductory text is longish, so if no additional context is needed, please see the following attached patches: - 0001-Provide-more-control-over-linked-documentation.patch - 0001-README-doc-html-resources-Document-new-properties.patch --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Provide-more-control-over-linked-documentation.patch Content-Description: Provide more control over linked documentation >From 834f01f267f2f8ab677d0de33e12034c06dbabd6 Mon Sep 17 00:00:00 2001 From: YugaEgo Date: Wed, 12 Jan 2022 12:24:09 +0200 Subject: [PATCH] Provide more control over linked documentation * README: (:doc-html, :resources): Document new properties. * elpa-admin.el (elpaa--html-insert-resources): New function. (elpaa--html-make-pkg): Use new function. (elpaa--build-Info-1): Do not generate HTML doc if :doc-html is 'ignore'. --- README | 13 +++++++++++++ elpa-admin.el | 12 +++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README b/README index a0e34ff78c..b83e8dfd1a 100644 --- a/README +++ b/README @@ -146,6 +146,19 @@ Name of the documentation file for the package. It can be either an Info file, a Texinfo file, or an Org file. FILE can also be a list of those. +** =:doc-html= +By default, if =:doc= specification contains a Texinfo file, then HTML +documentation is generated from it; the link to the generated HTML +file is added to the package page. To disable this behavior, set +=:doc-html= to ~ignore~. + +** =:resoures LINKS= +Enables 'Additional Resources' section on the package page. This must +be an association list of the titles and URLs of online resources. +For example: + + (("User Manual" . "https://example.tld/manual.html")) + ** =:make TARGET= Indicates that we should run ~make TARGET~ in order to build some files. This is run before processing =:doc=, so it can be used to generate diff --git a/elpa-admin.el b/elpa-admin.el index d570c3c6aa..c09e22241d 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -1469,6 +1469,13 @@ arbitrary code." )) (insert "\n")))) +(defun elpaa--html-insert-resources (pkg-spec) + (when-let ((links (elpaa--spec-get pkg-spec :resources))) + (insert "
Additional Resources
\n") + (dolist (link links) + (insert "" (car link) "\n")) + (insert "
\n"))) + (defun elpaa--html-make-pkg (pkg pkg-spec files srcdir) (let* ((name (symbol-name (car pkg))) (latest (package-version-join (aref (cdr pkg) 0))) @@ -1517,6 +1524,7 @@ arbitrary code." (elpaa--get-prop "URL" name srcdir mainsrcfile))) (insert (format "
Badge
\n" (elpaa--html-quote name))) (elpaa--html-insert-docs pkg-spec) + (elpaa--html-insert-resources pkg-spec) (insert "") (insert (format "

To install this package, run in Emacs:

M-x package-install RET %s RET
" @@ -2106,7 +2114,9 @@ relative to elpa root." t "makeinfo" "--no-split" docfile "-o" info-file) (message "%s" (buffer-string))) - (when html-dir (elpaa--html-build-doc pkg-spec docfile html-dir)) + (let ((doc-html (elpaa--spec-get pkg-spec :doc-html))) + (when (and html-dir (not (equal doc-html 'ignore))) + (elpaa--html-build-doc pkg-spec docfile html-dir))) (setq docfile info-file))) -- 2.34.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-README-doc-html-resources-Document-new-properties.patch Content-Description: README file changes for the 'main' branch >From ab2394e3c3816deb85aaa241d0b341b2fc7a5fea Mon Sep 17 00:00:00 2001 From: YugaEgo Date: Wed, 12 Jan 2022 12:31:30 +0200 Subject: [PATCH] * README (:doc-html, :resources): Document new properties --- README | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README b/README index f05e9e58ac..eafe517fac 100644 --- a/README +++ b/README @@ -184,6 +184,19 @@ Name of the documentation file for the package. It can be either an Info file, a Texinfo file, or an Org file. FILE can also be a list of those. +** =:doc-html= +By default, if =:doc= specification contains a Texinfo file, then HTML +documentation is generated from it; the link to the generated HTML +file is added to the package page. To disable this behavior, set +=:doc-html= to ~ignore~. + +** =:resoures LINKS= +Enables 'Additional Resources' section on the package page. This must +be an association list of the titles and URLs of online resources. +For example: + + (("User Manual" . "https://example.tld/manual.html")) + ** =:make TARGET= Indicates that we should run ~make TARGET~ in order to build some files. This is run before processing =:doc=, so it can be used to generate -- 2.34.1 --=-=-= Content-Type: text/plain I've been locally testing configuration for Company documentation (to add it to GNU ELPA) and noticed that an HTML version of the manual is automatically generated from the '.texi' file. The generated HTML file is linked under the label 'Manual' on the package page and served from the 'archive-devel/doc/company/' directory. I was pleased to see that automatic generation but there were two issues (namely, images and styles). The user manual for Company is shipped with the images; and it is currently impossible to configure the addition of them to the 'elpaa--doc-subdirectory'. My initial idea for fixing this issue was to add a property ':doc-asset', which could be configured to '(FROM . TO)' directories names, then used for moving images to the 'archive-devel/doc/company/' folder, as shown below: #+BEGIN_SRC diff diff --git a/elpa-admin.el b/elpa-admin.el index d94cc7fd73..23bb582ceb 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -1999,7 +1999,11 @@ directory; one of archive, archive-devel." (expand-file-name elpaa--doc-subdirectory tarball-dir))))) (when html-dir (when (not (file-readable-p html-dir)) ;FIXME: Why bother testing? - (make-directory html-dir t))) + (make-directory html-dir t)) + (when-let ((assets (elpaa--spec-get pkg-spec :doc-assets))) + (cl-loop for (from . to) in assets + do (rename-file (expand-file-name from dir) + (expand-file-name to html-dir) t)))) (plist-put (cdr pkg-spec) :internal--html-docs nil) (dolist (f docfiles) -- 2.34.1 #+END_SRC That worked fine during my tests but thinking about how to apply CSS styles to the manual (including to control the size of the shown images), I've got the second idea: Company already has an online version of the user manual with all the proper styles and images in place, so why not link directly to it? So, the suggested patch provides a way to do that. It introduces and uses two new properties: ':doc-html' and ':resources'. With it, for example, Company setup could be configured this way: #+BEGIN_SRC lisp ("company" :url "https://github.com/company-mode/company-mode.git" :shell-command "mkdir images; mv doc/images/small images/" :doc "doc/company.texi" :doc-html ignore :resources (("User Manual" . "https://company-mode.github.io/manual/index.html")) :auto-sync t) #+END_SRC I also attach a version with a bit different (IMO less robust/clear) approach. It introduces/uses one new property instead: ':doc-links'. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-doc-links-property-to-specifications.patch Content-Description: Add :doc-links property to specifications >From c470c6a669c395d82247d79fa3be0084727bb8e3 Mon Sep 17 00:00:00 2001 From: YugaEgo Date: Tue, 11 Jan 2022 03:05:37 +0200 Subject: [PATCH] Add ':doc-links' property to specifications Provide control over documentation linked from package page. * elpa-admin.el (elpaa--html-insert-docs, elpaa--build-Info-1): Utilize new property. * README (:doc-links): Usage instructions. --- README | 10 ++++++++++ elpa-admin.el | 51 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/README b/README index a0e34ff78c..dd5d9aef41 100644 --- a/README +++ b/README @@ -146,6 +146,16 @@ Name of the documentation file for the package. It can be either an Info file, a Texinfo file, or an Org file. FILE can also be a list of those. +** =:doc-links LINKS= +Allows configuring documentation links for the package page. By +default, if =:doc= specification contains a Texinfo file, then HTML +documentation is generated from it; the link to the generated HTML +file is added to the package page. To disable this behavior, set +=:doc-links= to ~ignore~ or to an association list of the titles and +URLs of an existing documentation. For example: + + (("User Manual" . "https://example.tld/manual.html")) + ** =:make TARGET= Indicates that we should run ~make TARGET~ in order to build some files. This is run before processing =:doc=, so it can be used to generate diff --git a/elpa-admin.el b/elpa-admin.el index 363919d9ab..6c25be5483 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -1449,25 +1449,35 @@ arbitrary code." (concat (file-name-base docfile) ".html")) (defun elpaa--html-insert-docs (pkg-spec) - (let ((docfiles (reverse (plist-get (cdr pkg-spec) :internal--html-docs))) - ;; `html-dir' is relative to the tarball directory, so html - ;; references on mirrors work. It does not include the - ;; package name, so cross references among package docs work. - (html-dir (when elpaa--doc-subdirectory - (file-name-as-directory elpaa--doc-subdirectory)))) - (when (and docfiles html-dir - ;; FIXME: This dir is shared, so it will always exist. - ;; Should we use (expand-file-name pkg html-dir) instead? - (file-readable-p html-dir)) ;; html doc files were built - (insert "
Manual
\n") - (dolist (doc docfiles) - (let ((html-file (concat html-dir (cdr doc)))) - (insert "" - (car doc) - "\n") - ;; FIXME: get link text from info direntry? - )) - (insert "
\n")))) + (let ((doc-links (elpaa--spec-get pkg-spec :doc-links))) + (unless (equal doc-links 'ignore) + (let ((docfiles (or doc-links + (reverse (elpaa--spec-get + pkg-spec :internal--html-docs)))) + ;; `html-dir' is relative to the tarball directory, so + ;; html references on mirrors work. It does not include + ;; the package name, so cross references among package + ;; docs work. + (html-dir (when (and (not doc-links) elpaa--doc-subdirectory) + (file-name-as-directory elpaa--doc-subdirectory)))) + (when (and docfiles + (or doc-links + ;; FIXME: This dir is shared, so it will always + ;; exist. Should we use (expand-file-name pkg + ;; html-dir) instead? + (and html-dir + ;; html doc files were built + (file-readable-p html-dir)))) + (insert "
Documentation
\n") + (dolist (doc docfiles) + (let ((html-file (if doc-links (cdr doc) + (concat html-dir (cdr doc))))) + (insert "" + (car doc) + "\n") + ;; FIXME: get link text from info direntry? + )) + (insert "
\n")))))) (defun elpaa--html-make-pkg (pkg pkg-spec files srcdir) (let* ((name (symbol-name (car pkg))) @@ -2106,7 +2116,8 @@ relative to elpa root." t "makeinfo" "--no-split" docfile "-o" info-file) (message "%s" (buffer-string))) - (when html-dir (elpaa--html-build-doc pkg-spec docfile html-dir)) + (when (and html-dir (not (elpaa--spec-get pkg-spec :doc-links))) + (elpaa--html-build-doc pkg-spec docfile html-dir)) (setq docfile info-file))) -- 2.34.1 --=-=-=--