Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5142351pxj; Wed, 9 Jun 2021 10:04:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQdQiPBgmgIiXh3FWPDtZAFHZxAg2Bd+hFqEmgNAymeQrcTw6B40maQ4oOMrKjj4OESMrb X-Received: by 2002:aa7:cc97:: with SMTP id p23mr424808edt.372.1623258289009; Wed, 09 Jun 2021 10:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623258289; cv=none; d=google.com; s=arc-20160816; b=aigXWVpU1TiK2F7vE0VQDX/VrSFV0Tv08+SytpMwb8XNOtXw4FsqBJ50wlTjjKD13N HktEXfBmGY5iKZ9ItW2HABWRsipt7sbbf+LQSCKOj3Wuk3MgCvZM2TaN4q6eQdPOXrx4 8wwaioWxvvg1tLFzr7lQeAAd/LvuS6h5ZFzy8hoJXTNeqATLC4l1ch2EAFcLONeNBaF0 Igc9IJWJ50UEEMyIgOqgKvY97wA6UXQBCkTMpsk7I/5ylQF1TjSB/in4oe7iNWz32qZ4 iR/fO7K1ueD28DmUMfrXNALovrP+1mQbDCjK7y3i1m9Cx3FFeBYGLq8cfrzApzpa9j+I CrBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9uCR7hI5P8LyVwfNKUDWjVrhcofvpCmZ4LJ9PVnGBBo=; b=d+8su7wCJWTMUthNSwWrDCe3uBKpK6f/mfJNqrH46Udx5Ht3JiquzACcw3aBPphydp zBgTU7G972mORYrWCBdeA41OruFHHnmvRfcOTzUbANCe+YLQkLJwxCYDmt6B1xIDq9GO tzJdMpGn4VDVFhsEIR9cIwLnyK0k63GV+hsjudel+tboddAPFzYm8MTqP4zbs4r+9CdR N03EUtgrTBLlZuMDlsnBMwV/gvPa83pb70W10qOQru9YTQNADntZG1RXyhx8xINhHrcj 1CbzpFSwLHdivOL5wRRwKiViTjfvP0oZuTBj51Pe8pT9nkVZewy7kDA9UiJGhuEMFIAf Ey+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nfraprado.net header.s=gm1 header.b=Y17CiFpW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e20si272661ejd.727.2021.06.09.10.04.17; Wed, 09 Jun 2021 10:04:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nfraprado.net header.s=gm1 header.b=Y17CiFpW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232454AbhFIBqO (ORCPT + 99 others); Tue, 8 Jun 2021 21:46:14 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:58959 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231344AbhFIBqN (ORCPT ); Tue, 8 Jun 2021 21:46:13 -0400 Received: (Authenticated sender: n@nfraprado.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 4F9B360005; Wed, 9 Jun 2021 01:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nfraprado.net; s=gm1; t=1623203058; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=9uCR7hI5P8LyVwfNKUDWjVrhcofvpCmZ4LJ9PVnGBBo=; b=Y17CiFpWE6c504+7KjhtmBoreLuyq0zSC5b/nqjLQligpJHQa408I9/fGMBhLf9gtHqG+e Vankfu4OcvlZMSL1ChV90l41Y1M/7uyJIhZ01S6qwvvcNT+exWVXvnXuHYrUKrhYK6HAkq F3+QtdNtVXHyJKODu/VuNfC6NynSBo5I741Jm0X/zP2rAIT76R5RwyHSrNFbBOsbbmdiW0 K6VB2aH9gxMk7wjG7mavYX00cT7wBSNOZ4vN8Kz2Gs5T6nnAWv2/ZGzaGADaCD8CcfguPt rR9g2gnoenEjsKej+zabSujtxvsisllMkG6zJB4sHHO4N1eIZThzUyAjKnPVTw== From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= To: linux-doc@vger.kernel.org Cc: Jonathan Corbet , Mauro Carvalho Chehab , Matthew Wilcox , linux-kernel@vger.kernel.org, =?UTF-8?q?Andr=C3=A9=20Almeida?= , ~lkcamp/patches@lists.sr.ht Subject: [RFC PATCH 1/2] docs: automarkup.py: Add literal markup of known constants Date: Tue, 8 Jun 2021 22:43:07 -0300 Message-Id: <20210609014308.234027-2-n@nfraprado.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210609014308.234027-1-n@nfraprado.net> References: <20210609014308.234027-1-n@nfraprado.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are some known constants that are used throughout the documentation, like NULL and error codes, and which are better formatted as literals by Sphinx. Make these words automatically literals. Suggested-by: Matthew Wilcox Signed-off-by: NĂ­colas F. R. A. Prado --- Documentation/sphinx/automarkup.py | 45 ++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/Documentation/sphinx/automarkup.py b/Documentation/sphinx/automarkup.py index acf5473002f3..eb219783d9e3 100644 --- a/Documentation/sphinx/automarkup.py +++ b/Documentation/sphinx/automarkup.py @@ -72,6 +72,40 @@ Skipfuncs = [ 'open', 'close', 'read', 'write', 'fcntl', 'mmap', 'select', 'poll', 'fork', 'execve', 'clone', 'ioctl', 'socket' ] +# +# Words that are automatically converted to literals +# +Literals = [ 'NULL', 'ULONG_MAX', 'LONG_MAX', 'EPERM', 'ENOENT', 'ESRCH', + 'EINTR', 'EIO', 'ENXIO', 'E2BIG', 'ENOEXEC', 'EBADF', 'ECHILD', + 'EAGAIN', 'ENOMEM', 'EACCES', 'EFAULT', 'ENOTBLK', 'EBUSY', + 'EEXIST', 'EXDEV', 'ENODEV', 'ENOTDIR', 'EISDIR', 'EINVAL', + 'ENFILE', 'EMFILE', 'ENOTTY', 'ETXTBSY', 'EFBIG', 'ENOSPC', + 'ESPIPE', 'EROFS', 'EMLINK', 'EPIPE', 'EDOM', 'ERANGE', 'EDEADLK', + 'ENAMETOOLONG', 'ENOLCK', 'ENOSYS', 'ENOTEMPTY', 'ELOOP', + 'EWOULDBLOCK', 'ENOMSG', 'EIDRM', 'ECHRNG', 'EL2NSYNC', 'EL3HLT', + 'EL3RST', 'ELNRNG', 'EUNATCH', 'ENOCSI', 'EL2HLT', 'EBADE', 'EBADR', + 'EXFULL', 'ENOANO', 'EBADRQC', 'EBADSLT', 'EDEADLOCK', 'EBFONT', + 'ENOSTR', 'ENODATA', 'ETIME', 'ENOSR', 'ENONET', 'ENOPKG', + 'EREMOTE', 'ENOLINK', 'EADV', 'ESRMNT', 'ECOMM', 'EPROTO', + 'EMULTIHOP', 'EDOTDOT', 'EBADMSG', 'EOVERFLOW', 'ENOTUNIQ', + 'EBADFD', 'EREMCHG', 'ELIBACC', 'ELIBBAD', 'ELIBSCN', 'ELIBMAX', + 'ELIBEXEC', 'EILSEQ', 'ERESTART', 'ESTRPIPE', 'EUSERS', 'ENOTSOCK', + 'EDESTADDRREQ', 'EMSGSIZE', 'EPROTOTYPE', 'ENOPROTOOPT', + 'EPROTONOSUPPORT', 'ESOCKTNOSUPPORT', 'EOPNOTSUPP', 'EPFNOSUPPORT', + 'EAFNOSUPPORT', 'EADDRINUSE', 'EADDRNOTAVAIL', 'ENETDOWN', + 'ENETUNREACH', 'ENETRESET', 'ECONNABORTED', 'ECONNRESET', 'ENOBUFS', + 'EISCONN', 'ENOTCONN', 'ESHUTDOWN', 'ETOOMANYREFS', 'ETIMEDOUT', + 'ECONNREFUSED', 'EHOSTDOWN', 'EHOSTUNREACH', 'EALREADY', + 'EINPROGRESS', 'ESTALE', 'EUCLEAN', 'ENOTNAM', 'ENAVAIL', 'EISNAM', + 'EREMOTEIO', 'EDQUOT', 'ENOMEDIUM', 'EMEDIUMTYPE', 'ECANCELED', + 'ENOKEY', 'EKEYEXPIRED', 'EKEYREVOKED', 'EKEYREJECTED', + 'EOWNERDEAD', 'ENOTRECOVERABLE', 'ERFKILL', 'EHWPOISON' ] + +# +# Any of the words in Literals, optionally prefixed with a '-' +# +RE_literal = re.compile(r'-?\b(' + str(r'|'.join(Literals)) + r')\b') + c_namespace = '' def markup_refs(docname, app, node): @@ -83,14 +117,18 @@ def markup_refs(docname, app, node): # markup_func_sphinx2 = {RE_doc: markup_doc_ref, RE_function: markup_c_ref, - RE_generic_type: markup_c_ref} + RE_generic_type: markup_c_ref, + RE_literal: markup_literal, + } markup_func_sphinx3 = {RE_doc: markup_doc_ref, RE_function: markup_func_ref_sphinx3, RE_struct: markup_c_ref, RE_union: markup_c_ref, RE_enum: markup_c_ref, - RE_typedef: markup_c_ref} + RE_typedef: markup_c_ref, + RE_literal: markup_literal, + } if sphinx.version_info[0] >= 3: markup_func = markup_func_sphinx3 @@ -225,6 +263,9 @@ def markup_c_ref(docname, app, match): return target_text +def markup_literal(docname, app, match): + return nodes.literal('', match.group(0)) + # # Try to replace a documentation reference of the form Documentation/... with a # cross reference to that page -- 2.32.0