From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: Convert README.org to plain text README while installing package Date: Fri, 24 Jun 2022 15:42:35 +0000 Message-ID: <87o7yink44.fsf@posteo.net> References: <87leuca7v7.fsf@disroot.org> <87czfopmsd.fsf@gnu.org> <87h74ztshe.fsf@gmx.de> <871qw31ois.fsf@yahoo.com> <8735gj4ceo.fsf@gnu.org> <87sfojz63r.fsf@yahoo.com> <87h74z5nio.fsf@localhost> <87ilpf45mo.fsf@disroot.org> <87pmjnumzg.fsf@posteo.net> <877d5ut6z6.fsf@posteo.net> 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="23228"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Akib Azmain Turja , Ihor Radchenko , Po Lu , Tassilo Horn , Michael Albinus , Alan Mackenzie , Stefan Kangas , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 24 17:51:40 2022 Return-path: Envelope-to: ged-emacs-devel@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 1o4lau-0005oz-GG for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Jun 2022 17:51:40 +0200 Original-Received: from localhost ([::1]:37138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4lat-0000gG-2k for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Jun 2022 11:51:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4lSE-0001CW-RS for emacs-devel@gnu.org; Fri, 24 Jun 2022 11:42:42 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:44697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4lSC-00011c-Gq for emacs-devel@gnu.org; Fri, 24 Jun 2022 11:42:42 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 663CB24002A for ; Fri, 24 Jun 2022 17:42:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1656085357; bh=QallSzgS97hoJwulGvU18X9DUMIExGN6sCsDQlB2fZw=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=j86N/O8cZM4p8TwxUcpXdIfYkEmzMdIW4OksGlI2lLNi7XqbpRqI+4HgNg78b/aDW rgVfc6IGqe+6kRWpGDgzN2u453rLUL1d3Q9CbvbyXqiWlV0f5cusdHE5EpymJiJO7+ sk7R5MFte9Wnez8IDCpr6K9lMYVIUdt8ThAetDoWRLio4EuSvxA4z2WApZW0pHF6r0 mlMp9FbjE7hSrczzbJOBCLHT/A5IlcMusKk+vJvnPo2ICLiMGkfbyESEdO4lN7Amue 08H8A3myUPFFEIpUXev8ObpKWGIymLh3HU3ZUay+Imy7Zy7qCTqdI988JKjEZUp5os 5BobVD/mF1apg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4LV1bJ069Lz6tmS; Fri, 24 Jun 2022 17:42:35 +0200 (CEST) X-Hashcash: 1:20:220624:monnier@iro.umontreal.ca::aOsvLsvCDWXg+HAS:000000000000000000000000000000000000005aL X-Hashcash: 1:20:220624:tsdh@gnu.org::5PX0yN1mD47J/fL8:000000trE X-Hashcash: 1:20:220624:acm@muc.de::O28dfdyF/otHDHYJ:00000001/Ip X-Hashcash: 1:20:220624:yantar92@gmail.com::TSEBtCgXjDZeFZdz:000000000000000000000000000000000000000000034XF X-Hashcash: 1:20:220624:stefan@marxist.se::2Uhe0oKMPRAf5Q2j:000000000000000000000000000000000000000000002a2M X-Hashcash: 1:20:220624:emacs-devel@gnu.org::X5nOzPX+wdiOHwsG:0000000000000000000000000000000000000000003ruo X-Hashcash: 1:20:220624:michael.albinus@gmx.de::TL7r62rg5NvCt1vn:0000000000000000000000000000000000000004NL6 X-Hashcash: 1:20:220624:luangruo@yahoo.com::RYcEvJxs9aE8a9uq:00000000000000000000000000000000000000000009sWW X-Hashcash: 1:20:220624:akib@disroot.org::lh2pK2sI8W1IkZXZ:0844B Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB In-Reply-To: (Stefan Monnier's message of "Tue, 07 Jun 2022 13:55:04 -0400") Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:291566 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> From 9d973044a346860d3fc6164fe75ad8cd9721a595 Mon Sep 17 00:00:00 2001 >> From: Philip Kaludercic >> 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. > > That looks OK, feel free to push that to `elpa-admin`. > Comments: The following should address most of your points, just one question, --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Render-Org-documentation-in-a-plain-text-README-elpa.patch >From c60903f5e916b22678c43c0fba0aa73a9e0bf471 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic 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. (elpaa--html-make-pkg): Reuse the rendered plaintext from `elpaa--write-plain-readme'. --- elpa-admin.el | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/elpa-admin.el b/elpa-admin.el index 58c0ec2e0a..173d247e87 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -610,7 +610,8 @@ auxillary files unless TARBALL-ONLY is non-nil ." (lambda (file) (string-match re file) (cons (match-string 1 file) file)) - (directory-files destdir nil re))))) + (directory-files destdir nil re)))) + rendered) (when ldir (cl-pushnew (list (file-name-as-directory ldir) "") renames :test #'equal)) @@ -621,6 +622,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) + (setq rendered (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))) @@ -677,7 +679,7 @@ auxillary files unless TARBALL-ONLY is non-nil ." (elpaa--html-make-pkg pkgdesc pkg-spec `((,vers . ,(file-name-nondirectory tarball)) . ,oldtarballs) - dir)))) + dir rendered)))) 'new))) (defun elpaa--makeenv (version revision) @@ -1162,6 +1164,22 @@ Rename DIR/ to PKG-VERS/, and return the descriptor." nil pkg-file))) +(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 or when the +readme file has an unconventional name" + (let ((readme-file (elpaa--spec-get pkg-spec :readme)) + (known-readme-names ;see `package--get-description' + '("README-elpa" "README-elpa.md" "README" "README.rst" "README.org")) + (readme-content (elpaa--get-README pkg-spec pkg-dir))) + (if (or (not (eq (car readme-content) 'text/plain)) + (not (member readme-file known-readme-names))) + (let ((rendered (elpaa--section-to-plain-text readme-content))) + (write-region rendered nil (expand-file-name "README-elpa" pkg-dir)) + rendered) + readme-content))) + (defun elpaa-batch-generate-description-file (&rest _) "(Re)build the -pkg.el file for particular packages." (while command-line-args-left @@ -1489,7 +1507,7 @@ arbitrary code." )) (insert "\n")))) -(defun elpaa--html-make-pkg (pkg pkg-spec files srcdir) +(defun elpaa--html-make-pkg (pkg pkg-spec files srcdir plain-readme) (let* ((name (symbol-name (car pkg))) (latest (package-version-join (aref (cdr pkg) 0))) (mainsrcfile (expand-file-name (elpaa--main-file pkg-spec) srcdir)) @@ -1542,7 +1560,7 @@ arbitrary code."
M-x package-install RET %s RET
" name)) (let* ((readme-content (elpaa--get-README pkg-spec srcdir)) - (readme-text (elpaa--section-to-plain-text readme-content)) + (readme-text plain-readme) (readme-html (elpaa--section-to-html readme-content)) (readme-output-filename (concat name "-readme.txt"))) (write-region readme-text nil readme-output-filename) -- 2.36.1 --=-=-= Content-Type: text/plain > - you'd get more bonus points by arranging for the code > to (re)use the existing plain text (which is currently produced later > when (re)generating the HTML page, so it would take a fair bit of > code reorg to get that. In the mean time, a FIXME comment seems > in order). > - Your code may end up "rendering" a Markdown file for no obvious benefit > since the rendering is a no-op (tho I think this is very hypothetical > and likely can't happen because of other constraints). Why should this be? Both this and the previous iteration of the patch check (eq (car readme-content) 'text/plain), and currently there is only text/plain (which includes markdown) and text/org? > - We might also add a `README-elpa` file when the readme file has a name > not recognized by `package--get-description`. --=-=-=--