[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert README.org to plain text README while installing package

From: Philip Kaludercic
Subject: Re: Convert README.org to plain text README while installing package
Date: Mon, 06 Jun 2022 10:35:25 +0000

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> From what I see this could be fixed if elpa-admin added a "README-elpa"
>> with the rendered text into the tarball.
> I think you're right.

I believe this should do the job:

>From 9d973044a346860d3fc6164fe75ad8cd9721a595 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Mon, 6 Jun 2022 12:34:40 +0200
Subject: [PATCH] Render Org documentation in a plain-text README-elpa file

* elpa-admin.el (elpaa--make-one-tarball-1): Call elpaa--write-plain-readme.
(elpaa--write-plain-readme): Add new function.
 elpa-admin.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/elpa-admin.el b/elpa-admin.el
index ecf4bc90d1..60da684f1f 100644
--- a/elpa-admin.el
+++ b/elpa-admin.el
@@ -621,6 +621,7 @@ auxillary files unless TARBALL-ONLY is non-nil ."
        (elpaa--make pkg-spec dir)
        (elpaa--build-Info pkg-spec dir destdir))
      (elpaa--write-pkg-file dir pkgname metadata revision)
+     (elpaa--write-plain-readme dir pkg-spec)
      ;; FIXME: Allow renaming files or selecting a subset of the files!
      (cl-assert (not (string-match "[][*\\|?]" pkgname)))
      (cl-assert (not (string-match "[][*\\|?]" vers)))
@@ -1162,6 +1163,17 @@ Rename DIR/ to PKG-VERS/, and return the descriptor."
+(defun elpaa--write-plain-readme (pkg-dir pkg-spec)
+  "Render a plain text readme from PKG-SPEC in PKG-DIR.
+This is only done if necessary, that is if the readme contents
+are not already taken to be formatted in plain text."
+  (let* ((readme-content (elpaa--get-README pkg-spec pkg-dir)))
+    (unless (eq (car readme-content ) 'text/plain)
+      (write-region
+       (elpaa--section-to-plain-text readme-content)
+       nil
+       (expand-file-name "README-elpa" pkg-dir)))))
 (defun elpaa-batch-generate-description-file (&rest _)
   "(Re)build the <PKG>-pkg.el file for particular packages."
   (while command-line-args-left

reply via email to

[Prev in Thread] Current Thread [Next in Thread]