From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id CLp3DKcob2dj0wAA62LTzQ:P1 (envelope-from ) for ; Fri, 27 Dec 2024 22:22:31 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id CLp3DKcob2dj0wAA62LTzQ (envelope-from ) for ; Fri, 27 Dec 2024 23:22:31 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=dJjMMu4t; dkim=fail ("headers rsa verify failed") header.d=outlook.com header.s=selector1 header.b=fjHWdLQh; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=outlook.com (policy=none) ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1735338150; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=nicY3ca3R92qUN1jbPcdKmXD0ZXhq/pTwlChXf8ikP8=; b=dBCBJVfqFZQWskqHbKyz5ydpl0M0xAX5jB441l2OHwCJWDJjsy7oj4HAjUcYtHuwyMj9QG xih6Ne4zJ/CTxOjI39HJFE8w5sRl0tP41OPji8tXWkVFVNjnrpj9g4o0efHY5ehOKZ8VxQ 7KnSQ6dmOqkqlVq4Fe9KhMrywiCH74D9hH69RqxzCBLld5hncqmDbcL6aVYrrttigQCPSs 5Wgf54jb97b2KF4/hIqZDu05yNZNralb6cx9G87ZK3pd2AwnkLKwt+0mAwHp9mWO9/YYnz 0Uo0+b7XsCinNuPECdWeanRZMusyXgnJMZRPDYfwSDn7djPQ4XCGPRaB7nr/QA== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=dJjMMu4t; dkim=fail ("headers rsa verify failed") header.d=outlook.com header.s=selector1 header.b=fjHWdLQh; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=outlook.com (policy=none) ARC-Seal: i=2; s=key1; d=yhetil.org; t=1735338150; a=rsa-sha256; cv=fail; b=niOB4RUxSiQWNNo93m9Eq5jakvGHjwuXLJtjhNafO5bevRikBOyIf2RrSmM0x4Mu57gJmP xAgqen1O/YO2xeahKGeawDojpT4+G09JO2VLWEDRK+nQ4n2uFyirCH+Ft+I681t3N9bYO8 De6fky5cvWoS3ZpyTSneaCcvT93RbD5cYqUkbK5HECYxud84P9YAEQj8mZDxJOth0PwZbX A6YEgnyfIWymttkGjyYb8hs0d+atYTIcmft/s5wuHRgZ8N+9kUBnxCsl+iBRmp/9bOTlQ8 ZLK6yaEMwBXp+MfrCb6y211DQDY8+LmohC2hNWzTJBDOC9BhEfadZs7s8xqdLg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 88D3796398 for ; Fri, 27 Dec 2024 23:22:29 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tRIic-0000TJ-8f; Fri, 27 Dec 2024 17:22:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tRIiZ-0000Su-M4 for guix-patches@gnu.org; Fri, 27 Dec 2024 17:22:03 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tRIiZ-0001dI-Dk for guix-patches@gnu.org; Fri, 27 Dec 2024 17:22:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=nicY3ca3R92qUN1jbPcdKmXD0ZXhq/pTwlChXf8ikP8=; b=dJjMMu4ttJD2qaC7qsAkXJ35iDCQAicv9TkDjttC3D9wVJ4Lt55Qs8gMvWCqeYnFbArcWGT+TfgpP3Jwdx8WVK3sZQ7bi6O9snvgdKYoTlHpPxEVnh6hynRlzQqFGtMslhuj3hlydXe202qKTSYcikLu6sbEvSFN3fqHZX1YUg1stG7kSOFuNV5L4xT1PhQmITQkLNBGy7C37g/5oF2ffwain/E8DI2e4QN2nU9LFmfX7tHpZYJCAE3VBkebmSzq0NUUvbiNzErcCEAi89Ifo0GB+INjsv1XPJybJD6cY+js8+pA5KnhuDeoBCc2AJFCFSobxZQfVSEnO3MQilEZkA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tRIiY-0003Ia-Rf for guix-patches@gnu.org; Fri, 27 Dec 2024 17:22:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75151] [PATCH] import/utils: beautify-description: Validate argument Resent-From: Morgan Smith Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 27 Dec 2024 22:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 75151 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75151@debbugs.gnu.org Cc: Morgan Smith X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.173533810612647 (code B ref -1); Fri, 27 Dec 2024 22:22:02 +0000 Received: (at submit) by debbugs.gnu.org; 27 Dec 2024 22:21:46 +0000 Received: from localhost ([127.0.0.1]:47883 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tRIiH-0003Hv-7P for submit@debbugs.gnu.org; Fri, 27 Dec 2024 17:21:45 -0500 Received: from lists.gnu.org ([209.51.188.17]:59734) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tRIiE-0003Hj-LK for submit@debbugs.gnu.org; Fri, 27 Dec 2024 17:21:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tRIiE-0000S3-91 for guix-patches@gnu.org; Fri, 27 Dec 2024 17:21:42 -0500 Received: from mail-dm6nam10olkn2032.outbound.protection.outlook.com ([40.92.41.32] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tRIiC-0001b0-6R for guix-patches@gnu.org; Fri, 27 Dec 2024 17:21:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UiKtE5/p7cKZVpYQn4s8x4MpATJ8PoSdHV26Duy/m8lGpEJy5yr3F0bfOqgQ6qbNeCPYUHuKiLTvD+7IfoOp/Kyqp0Z0p8fZkUbugs/li1xoLDdOAIGb9m6EkHXroK7jMF+6D8vp/xLMgAIika12tpwi0xCZWwyyqxvyB9FyNLEadNtp+XKBkbb9MxI1yRvYBxKRD0lbQyRNFt/3/EGZcPlfZ8mjEA6PrAEC2ifNDXgulG6sIf1tMcnLjrViaxdmcOsBhdCAjiYQKjq64o9biUVf3B40zjGgtHlP4uFEvQg+IyToYivJiWAEYo4cqsWCKCNm2r6swZ9RQAHFUyL6+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nicY3ca3R92qUN1jbPcdKmXD0ZXhq/pTwlChXf8ikP8=; b=P7n3aQrH3KAaE3WAk73E+xk/UDQ0e7z2o91M0twEkKAnCuriVdeAFuZpSpslf+QKzsABgBCQRat1rg6WUYfDWWncvw9ku0IkUgkWbc6scfjgMboaYv3PhnDPr4nUtGVHL9NPBVqzlrFWe4peT41ywjrT46utuXKhmA9KOreC6M2kPIUmkeR0opEx7pdHrNGcUokPDzmX/RZu37a2xWZH8P18Q7fVhavL1i7zJ9nXBLyq9/HBjCxFiSZtT5DxCQCzUAfTkR1e8I4/F7tYFT/2Xn5+WMIMdlacY/kpODmOmOWyY8ke+c8Y3S98J4as/Y3PD/foHSAqxRqmcmieafCcTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nicY3ca3R92qUN1jbPcdKmXD0ZXhq/pTwlChXf8ikP8=; b=fjHWdLQh4mirJD/5rvWncVgBIRxqTP2SL5n+sf/BCT+SWr2hstsg5G2my2qFaAGNWcv5MaOJ+c0WM1Tygy9BvRlYmjw7VdxkBI5j+qRD+24sEeyNdZqhhIumxpAC6meUzMsAD7wsfLy2U/HcmvZqaBHmkXXIlgLG07d1ImbEmuzztQvpUIqB2FJA/UpDrrPejAp5UEodArbaRmRP3kCisZ81uYT0U8paQY2Kqa7CJ5rV0pI1yuSA/GDhy3Mq4+HF9lPYZ4cc6ENTCAK6BWQz5AfUHtC6FTygpX4kZmGWcGyfr+qWRWLkXYe7t1vEqC1v4fg3eJIdeUkXznQegKStIg== Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) by PH0PR84MB2025.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:510:160::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.14; Fri, 27 Dec 2024 22:21:36 +0000 Received: from CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM ([fe80::5c77:7a58:48ed:9aef]) by CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM ([fe80::5c77:7a58:48ed:9aef%4]) with mapi id 15.20.8293.000; Fri, 27 Dec 2024 22:21:36 +0000 From: Morgan Smith Date: Fri, 27 Dec 2024 17:18:38 -0500 Message-ID: X-Mailer: git-send-email 2.47.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: YT4PR01CA0411.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10b::28) To CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:610:1c4::17) X-Microsoft-Original-Message-ID: <75e7d7862811d04bc08e32e92804d370173100d0.1735337917.git.Morgan.J.Smith@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR84MB3424:EE_|PH0PR84MB2025:EE_ X-MS-Office365-Filtering-Correlation-Id: d6804579-53ab-4d2f-039b-08dd26c4d3b4 X-Microsoft-Antispam: BCL:0; ARA:14566002|7092599003|8060799006|19110799003|461199028|5072599009|15080799006|3412199025|440099028|1710799026; X-Microsoft-Antispam-Message-Info: tMo+bC/IgxCIWLdezVGOa6Qa9QpMSULTZt8dMFZisyYurg8Pp7P5K4J2nPgXadukt2zEJE1j0QFwqhx0NnmRgj7MBLRj+iBkUScBxkJpe1VjbpytvoC7qjni96pRn/jOAAyCGJf7Sojv/tnl+mAIlEMvB/2xvcJvir4iC+/Vygxx+U36qvj0Ko5fUpsuob6bROT/+0WKa11NacDIUAU94Puoju7IO6Yaaut93m1kmCVCQ70qHnJbM+noMYvs7vuI9YOVoJYGXjqOkjXiHO6hVC1CfR8puBnwSqextAuy/VP4j+hmdTkJ6Yn+kgXHxHCYYX7tXLt25iAgh+AH0LO4vmB5blmV8v7v1n9QNjaZGyH7ImthdtfuW0I8SntWy4A53pJiZJxqERzkZUDlk3Z3HZ+JSNdpluPDltzrHNYOP4uDeL5M7SADxNgxAt4FgH25/Fie1EJ5HU3/xwp6BH4RGbCeBlVkWP3NoEsGORKBxVuv8NiW2Y8fDi29du2anFGZ16xDiHdgfUP7Gyw9JJoU7dk0WaXwTif9/leT0joQ9zKTnYKWDZpZEWPG9qbE5losZ9oy7I7YSkfk549Ba2cRc/gRo2wAtBff/59kdXhZjl58uu/iK9GtLhYQTPIRC29Q6AVg913zqXwp3sywKg3E8+HcMqDQKHvSmUhR8Y+sgZpHQDHdYDPxYlaxqDc0hxBL3PAG3lqq+QxXk4rvbpQdahOEK7f3+JwWtgK9e7SmTcYnOqydt0FO7DQ/yrbfsd7jAzMhA3rgkPVb7QKmugCMVCtkDe0dsFPdyohL1MwTvw06maIPPxbwiiiB3BjVpAjDLk4CGZHL560dp4kV6FzF0gAvX9DGA6MqSY2lTeaH5IHMsJvIbzj9wM+yo3cy2W5pJymPADA0m/NP0mOQYRpGUEoreYDjbpf6TVSDT2wvNfGc1mQWtShmqQVgG+EUYVRBNH8 sqyutmQTgfMiimCay+P1LpFo+NpUYQ8f8AbzB0ddLzWiuWAow8ppTAU8DJsFFGwpnui7wO9MrC7CAW8IK1I+Q3kVYpAhbts2LyFRp2TBTTc7V0sPqqnmDBgdBVc4XCb07ibZuaq6sQ9ohynFTn2o7zhlRBLvpgDMxD+nsd80= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i5wS+yY8TGUUw7Ne/YZzCJORkT0BNOYY2FveAzBQsLQtxHn2a4trSqCLqsPUy357v+UKA1GBlE3edmKxRc5JNqKdtuo5AKEdZTqouPZLrHdZwNIWBK3REVNiP3R5LGMIwvQpeWOSHcbDSKgql/igEKVmBVzy9PiSlHQI2b3tW5WI4MReNDba8l7t3e/iEG4rFIjMLGqr7A1jKddB3pJqnrXdfcQarh9l4EIr68sxX+tg2DGytI+40DaMK6aQ+UVlqdcKoX7kkcOK+QyNZe20YiLDtGYWLLWU+L3voJ9X42wYiJvuuMNMPY8xGMGYenPOXBogfPqMneA6KN0xNAqXIJWEXhcXOGDSNVweoOK8fwYqtn4QKVKr1+09n0ttsntrDzPM9yfsE6YJUYhCQY1PIRYFR0Fb/62b19C08BvT0K+GXC0aMK9+7Osg2eqkwo8EihKnTL4bxkXGnPVBrkuZJ0WYlVZBtCFjAnJJEo5YG37+Gg9gCNwReN1T0RjCgmBGg3y3U3OqOMTZ0vMSlR6y95/1kS2msOL35NTtDGBKqXYe5wRO6g0zCndzYbFtnO2LnU3Y/WE5XJp36QbIM2iTQotPpMgVYl+exRPO8mWnKI7+7ibDvAojCoKFutAxReeMgy8Onz1yqT1P4LxiiJWosm4/F5LHmS7ZTUda1KWJnJB5NmVZ3d9HWtabhJ0N2Uwvm80BWzJ3VipC8qCJYyREZa1PPAqQjXrnMA5t6aFV5jY5A40r83h3zT/Og4G6Sntt+/FF/27jaAK/1hTvPUEIzzK0krFb9Ls+3hTUd2AaMdrOd5sCz+qEsSbvVqqXRSIWxD8TpunabuU7KxXpT2glfwWCHPb7Airs9sutii9dXoajAThN83a50CdPs6WcEZ5Mh6j65H7rPznjTZSMR5rzyZMEN7yg+AqOWmv4s78xOO6KImmM7AB4erWzm0/aTDdc MSo4Y41GU3gWvpnoagNXWA8fAOj6lz6A2Hm5XbGR8vcZM/Qfo2cR4uOWw02JD/KSRnU3o6wIqR4dKA4XOd49JminESTw8z0+oYwemhNatm7vMEJxk/GYFOdNVRzP7omlPFqgvZnGdtmvM4DpThidE64dxMDteahhWBxJYz5hxou+2ceaxLaaqlew4vTrl/fXt+ek2qDLAGjuogOHwCQEvyibYoA2QK/HWH0/mWTBLf3M3Ign5gwl0t0Dl/UCeZ9Mr6POtqBE7rFUGw95yD/87K9bLyn9owJz0gELZIlLY8O/C+34EjsIgEe9cuM3EbsP X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6804579-53ab-4d2f-039b-08dd26c4d3b4 X-MS-Exchange-CrossTenant-AuthSource: CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2024 22:21:36.6320 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR84MB2025 Received-SPF: pass client-ip=40.92.41.32; envelope-from=Morgan.J.Smith@outlook.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.36 X-Spam-Score: -3.36 X-Migadu-Queue-Id: 88D3796398 X-Migadu-Scanner: mx10.migadu.com X-TUID: W28lqalQTufs * guix/import/utils.scm (beautify-description): Fix broken check for non-strings. Add a check for empty strings. * tests/import-utils.scm: Add two tests. Change-Id: Idf86df02aeb850fcc8808b7c9251082c1f816656 --- Hello! I was trying to run "guix import hackage orgstat" to no avail. It turns out it was because 'beautify-description' errors when given the empty string. It already had a check for arguments that where not a string but that check was actually broken. So I fixed the existing check and added a new one for an empty string. guix/import/utils.scm | 160 +++++++++++++++++++++-------------------- tests/import-utils.scm | 10 +++ 2 files changed, 91 insertions(+), 79 deletions(-) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index e45c8dfb20..bb268ebe4b 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -328,85 +328,87 @@ (define* (beautify-description description #:optional (length 80)) "Improve the package DESCRIPTION by turning a beginning sentence fragment into a proper sentence and by using two spaces between sentences, and wrap lines at LENGTH characters." - (unless (string? description) - (G_ "This package lacks a description. Run \ -\"info '(guix) Synopses and Descriptions'\" for more information.")) - - (let* ((fix-word - (lambda (word) - (fold (lambda (proc acc) (proc acc)) word - (list - ;; Remove wrapping in single quotes, common in R packages. - (cut string-trim-both <> #\') - ;; Escape single @ to prevent it from being understood as - ;; invalid Texinfo syntax. - (cut regexp-substitute/global #f "@" <> 'pre "@@" 'post) - ;; Wrap camelCase or PascalCase words or text followed - ;; immediately by "()" in @code{...}. - (lambda (word) - (let ((pattern - (make-regexp - "([A-Z][a-z]+[A-Z]|[a-z]+[A-Z]|.+\\(\\))"))) - (match (list-matches pattern word) - (() word) - ((m . rest) - ;; Do not include leading or trailing punctuation, - ;; unless its "()". - (let* ((last-text (if (string-suffix? "()" (match:substring m 1)) - (string-length (match:substring m 1)) - (or (and=> (string-skip-right word char-set:punctuation) 1+) - (string-length word)))) - (inner (substring word (match:start m) last-text)) - (pre (string-take word (match:start m))) - (post (substring word last-text (string-length word)))) - (string-append pre "@code{" inner "}" post)))))))))) - (words - (string-tokenize (string-trim-both description) - (char-set-complement - (char-set #\space #\newline)))) - (new-words - (match words - (((and (or "A" "Classes" "Functions" "Methods" "Tools") - first) . rest) - (cons* "This" "package" "provides" - (string-downcase first) rest)) - (((and (or "Contains" - "Creates" - "Performs" - "Provides" - "Produces" - "Implements" - "Infers") first) . rest) - (cons* "This" "package" - (string-downcase first) rest)) - (_ words))) - (new-words - (match new-words - ((rest ... last) - (reverse (cons (if (or (string-suffix? "." last) - (string-suffix? "!" last) - (string-suffix? "?" last)) - last - (string-append last ".")) - (reverse rest)))))) - (cleaned - (string-join (map fix-word new-words)))) - ;; Use double spacing between sentences - (fill-paragraph (regexp-substitute/global #f "\\. \\b" - cleaned 'pre - (lambda (m) - (let ((pre (match:prefix m)) - (abbrevs '("Dr" "Mr" "Mrs" - "Ms" "Prof" "vs" - "e.g"))) - (if (and (> (string-length pre) 0) - (or (any (cut string-suffix? <> pre) abbrevs) - (char-upper-case? - (string-ref pre (1- (string-length pre)))))) - ". " - ". "))) - 'post) - length))) + (if (or (not (string? description)) (string=? (string-trim-both description) "")) + (G_ "This package lacks a description. Run \ +\"info '(guix) Synopses and Descriptions'\" for more information.") + + (let* ((fix-word + (lambda (word) + (fold (lambda (proc acc) (proc acc)) word + (list + ;; Remove wrapping in single quotes, common in R packages. + (cut string-trim-both <> #\') + ;; Escape single @ to prevent it from being understood as + ;; invalid Texinfo syntax. + (cut regexp-substitute/global #f "@" <> 'pre "@@" 'post) + ;; Wrap camelCase or PascalCase words or text followed + ;; immediately by "()" in @code{...}. + (lambda (word) + (let ((pattern + (make-regexp + "([A-Z][a-z]+[A-Z]|[a-z]+[A-Z]|.+\\(\\))"))) + (match (list-matches pattern word) + (() word) + ((m . rest) + ;; Do not include leading or trailing punctuation, + ;; unless its "()". + (let* ((last-text + (if (string-suffix? "()" (match:substring m 1)) + (string-length (match:substring m 1)) + (or (and=> (string-skip-right word char-set:punctuation) 1+) + (string-length word)))) + (inner (substring word (match:start m) last-text)) + (pre (string-take word (match:start m))) + (post (substring word last-text (string-length word)))) + (string-append pre "@code{" inner "}" post)))))))))) + (words + (string-tokenize (string-trim-both description) + (char-set-complement + (char-set #\space #\newline)))) + (new-words + (match words + (((and (or "A" "Classes" "Functions" "Methods" "Tools") + first) . rest) + (cons* "This" "package" "provides" + (string-downcase first) rest)) + (((and (or "Contains" + "Creates" + "Performs" + "Provides" + "Produces" + "Implements" + "Infers") first) . rest) + (cons* "This" "package" + (string-downcase first) rest)) + (_ words))) + (new-words + (match new-words + ((rest ... last) + (reverse (cons (if (or (string-suffix? "." last) + (string-suffix? "!" last) + (string-suffix? "?" last)) + last + (string-append last ".")) + (reverse rest)))))) + (cleaned + (string-join (map fix-word new-words)))) + ;; Use double spacing between sentences + (fill-paragraph + (regexp-substitute/global #f "\\. \\b" + cleaned 'pre + (lambda (m) + (let ((pre (match:prefix m)) + (abbrevs '("Dr" "Mr" "Mrs" + "Ms" "Prof" "vs" + "e.g"))) + (if (and (> (string-length pre) 0) + (or (any (cut string-suffix? <> pre) abbrevs) + (char-upper-case? + (string-ref pre (1- (string-length pre)))))) + ". " + ". "))) + 'post) + length)))) (define (beautify-synopsis synopsis) "Improve the package SYNOPSIS." diff --git a/tests/import-utils.scm b/tests/import-utils.scm index 607349203c..27bd87940a 100644 --- a/tests/import-utils.scm +++ b/tests/import-utils.scm @@ -31,6 +31,16 @@ (define-module (test-import-utils) (test-begin "import-utils") +(test-equal "beautify-description: empty string" + "This package lacks a description. Run \ +\"info '(guix) Synopses and Descriptions'\" for more information." + (beautify-description "")) + +(test-equal "beautify-description: not a string" + "This package lacks a description. Run \ +\"info '(guix) Synopses and Descriptions'\" for more information." + (beautify-description '())) + (test-equal "beautify-description: use double spacing" "\ Trust me Mr. Hendrix, M. Night Shyamalan et al. \ base-commit: 3a8c20408f0078a580d27f74bc69b5a1069a003b -- 2.47.1