[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#62202] [PATCH 16/21] import: juliahub: Beautify description.
From: |
Nicolas Graves |
Subject: |
[bug#62202] [PATCH 16/21] import: juliahub: Beautify description. |
Date: |
Wed, 15 Mar 2023 13:51:25 +0100 |
---
guix/import/juliahub.scm | 60 +++++++++++++++++++++++++++++++++++++---
1 file changed, 56 insertions(+), 4 deletions(-)
diff --git a/guix/import/juliahub.scm b/guix/import/juliahub.scm
index 3985d8d0be..338f042441 100644
--- a/guix/import/juliahub.scm
+++ b/guix/import/juliahub.scm
@@ -32,8 +32,10 @@ (define-module (guix import juliahub)
#:use-module (guix base32)
#:use-module (guix packages)
#:use-module (guix upstream)
- #:use-module (json)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (json)
+ #:use-module (htmlprag)
+ #:use-module (sxml transform)
#:export (juliahub->guix-package
%juliahub-updater
@@ -164,6 +166,53 @@ (define (parse-test-dependencies directory)
(filter (lambda (x) (not (member x %julia-stdlibs)))
(string-split (string-drop (string-drop-right pure 1) 7) #\,))))
+(define %juliahub-beautify-description-rules
+ `((h1 *preorder* . ,(lambda args #f))
+ (h2 *preorder* . ,(lambda args #f))
+ (h3 *preorder* . ,(lambda args #f))
+ (h4 *preorder* . ,(lambda args #f))
+ (hr *preorder* . ,(lambda args #f))
+ (span *preorder* . ,(lambda args #f))
+ (img *preorder* . ,(lambda args #f))
+ (pre *preorder* . ,(lambda args #f))
+ (div *preorder* . ,(lambda args #f))
+ (table *preorder* . ,(lambda args #f))
+ (imgalt *preorder* . ,(lambda args #f))
+ (@ *preorder* . ,(lambda args #f))
+ (*TOP* . ,(lambda args (cdr args)))
+ (p . ,(lambda args (cdr args)))
+ (em . ,(lambda args (cdr args)))
+ (strong . ,(lambda args (cdr args)))
+ (a . ,(lambda args
+ (match args
+ ((tag link ref)
+ (if ref ref #f))
+ (_ #f))))
+ (ul . ,(lambda args
+ `("@itemize" ,@(cdr args) "\n@end itemize")))
+ (ol . ,(lambda args
+ `("@enumerate" ,@(cdr args) "@end enumerate")))
+ (blockquote . ,(lambda args
+ `("@quotation" ,@(cdr args) "@end quotation")))
+ (li . ,(lambda args
+ `("\n@item" ,@(cdr args))))
+ (code . ,(lambda args
+ (string-append
+ "@code{"
+ (string-join (cdr args) " ")
+ "}")))
+ (*text* . ,(lambda (tag x) x))
+ (*default* . ,(lambda (tag . body)
+ (cons tag body)))))
+
+(define (juliahub-beautify-description description)
+ (string-join
+ (filter (lambda (x) (if (equal? x " ") #f x))
+ (flatten
+ (pre-post-order (html->sxml description)
+ %juliahub-beautify-description-rules)))
+ " "))
+
;; Julia package.
(define-json-mapping <juliahub-package> make-juliahub-package juliahub-package?
json->juliahub-package
@@ -211,8 +260,9 @@ (define (make-julia-sexp name source home-page synopsis
description
,@(if (null? direct-dependencies)
'()
`((propagated-inputs
- (list ,@(map (compose julia-name->guix-name
juliahub-dependency-name)
- direct-dependencies)))))
+ (list
+ ,@(map (compose julia-name->guix-name juliahub-dependency-name)
+ direct-dependencies)))))
,@(if (null? test-dependencies-names)
'()
`((native-inputs
@@ -264,7 +314,9 @@ (define* (juliahub->guix-package package-name
source
(juliahub-package-homepage package)
(juliahub-package-description package)
- (beautify-description (juliahub-package-readme package))
+ ((compose beautify-description
+ juliahub-beautify-description)
+ (juliahub-package-readme package))
direct-dependencies
test-dependencies-names
licenses)
--
2.39.2
- [bug#62202] [PATCH 03/21] import: juliahub: Add support for native-inputs., (continued)
- [bug#62202] [PATCH 03/21] import: juliahub: Add support for native-inputs., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 11/21] import: juliahub: Improve test dependencies parsing., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 09/21] import: juliahub: Improve dependency management., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 06/21] import: juliahub: Add updater and recursive-importer., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 05/21] import: juliahub: Add indirect dependencies., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 08/21] import: juliahub: Simplify juliahub dependency management., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 10/21] import: juliahub: Add functions to parse the git repo for a git tag., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 07/21] import: juliahub: Filter out julia stdlibs., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 12/21] import: juliahub: Handle the case where we have a subdirectory., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 13/21] import: juliahub: Add support for versions for juliahub-fetch., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 16/21] import: juliahub: Beautify description.,
Nicolas Graves <=
- [bug#62202] [PATCH 18/21] import: juliahub: Fix version management., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 14/21] import: juliahub: Filter out stdlibs from test-dependencies., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 15/21] import: juliahub: More robust toml regex parser., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 20/21] import: utils: Rule out texinfo common syntax from @ escape., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 17/21] import: juliahub: Fix license management., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 21/21] import: juliahub: output package names as symbols., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 19/21] import: juliahub: Fix undefined homepages., Nicolas Graves, 2023/03/15