Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp318247pxu; Tue, 6 Oct 2020 07:12:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxk0Gbcm66g3KnkZ0MVsXxPMHdLrI3afyocIK7q365PU3VIYgSPvjH2pCpqtkH888eU19j X-Received: by 2002:a17:906:a988:: with SMTP id jr8mr2308096ejb.508.1601993546937; Tue, 06 Oct 2020 07:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601993546; cv=none; d=google.com; s=arc-20160816; b=f6U2U2jGIeEXEpW+vBCwSK7OGXEZ7qaIzlcGT91dYjHZI1tX4eFhIljaM4teYAA8qf iiHOyaYM/hHZCxzVo2MD4J3iwJ3xicD7TUu+PhBA4lg3sxb55ucf2Y4GP8anf1vWmJxG bE3eYYqahJ3lSAy7seCZ/kI8q7RDJReo2BTIP7BI8DvK8MhfbpT7LXtUhYPmEaIXR9HY iny0JdWQFro+1tQLdyMim13L996pDrgFt/mkUH6WIyUYomDhNYDfgYxbO3nBPmLMua/b wr4yeMSzFg9neZKxgdaAo/1f15QaArfWjFxkkmueaXjKbPHU/Yokzldqu925sWUsUL/K 1sJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S8FI1G0Gbvrx8SqJCHpOw1J4uc7s33h1R2s0VDpFE2k=; b=mESqusWtqsZwMTBqUeN0+ieaWeCIRoh1K6paoG5gIB7dAVcRYSwW9VUZaaVK5sz1xu cEK8qVJ9y8TTcfy+PtQ2wSUBKlN8fhvbXlfsx6wceuCwmsL7jgKU14si2r9UP/i5DaWb KsT9OBMPs4W+PkXGjNLXrBX7sdeQbyDeXrN4ee8DeIHVh96sz8cnel+SvbAO7b6eRP0D uxHwfY31Fg81ZBwsiTKFJVpfrUpIAhbqRQq+WkrYJ0JZs+VGRqDmUGyDgPhsGiXg/0qw l6xCv715yULbGspZ+o/OQ1alrT+6Ve3vrBhtCe4542aF76DIBHuJ8Febch40chvpSkgT PuWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RYHQ7En3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i24si2121807ejb.44.2020.10.06.07.12.01; Tue, 06 Oct 2020 07:12:26 -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=@kernel.org header.s=default header.b=RYHQ7En3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726583AbgJFOHi (ORCPT + 99 others); Tue, 6 Oct 2020 10:07:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:33144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726214AbgJFODy (ORCPT ); Tue, 6 Oct 2020 10:03:54 -0400 Received: from mail.kernel.org (ip5f5ad5bd.dynamic.kabel-deutschland.de [95.90.213.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 69D2E2083B; Tue, 6 Oct 2020 14:03:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601993033; bh=8Wg4J7Lyd/Va8b7XV8z9jXdPVZ/IrSKHVEYF1TFbuSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RYHQ7En3Ne/fphOiy+cchyN4h4mSWBgSxqgaRhgcnyF7Ukd6GKSO9Xj/StyeXXWMB +ZhjAbIdShSe//ARODaSgryqWpgJkozTyXZkJINiAhFDaoEnUmC7ZgUZeQAGtNiJlP XNSXmhvTkLVlrrULlX6mAz5lKTBDxedUi6Xsmbls= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1kPnZH-0019Ea-2W; Tue, 06 Oct 2020 16:03:51 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v5 02/52] docs: cdomain.py: extend it to handle new Sphinx 3.x tags Date: Tue, 6 Oct 2020 16:02:59 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While most of the C domain parsing is done via kernel-doc, some RST files use C domain tags directly. While several of them can be removed for Sphinx < 3.0, due to automarkup.py, and several others that could be converted into kernel-doc markups, changes like that are time-consuming, and may not fit all cases. As we already have the cdomain.py for handing backward compatibility with Sphinx versions below 3.0, let's make it more complete, in order to cover any usage of the newer tags outside kernel-doc. This way, it should be feasible to use the new tags inside the Kernel tree, without losing backward compatibility. This should allow fixing the remaining warnings with the Kernel tags. Signed-off-by: Mauro Carvalho Chehab --- Documentation/sphinx/cdomain.py | 40 ++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Documentation/sphinx/cdomain.py b/Documentation/sphinx/cdomain.py index 35805c44a4fc..014a5229e57a 100644 --- a/Documentation/sphinx/cdomain.py +++ b/Documentation/sphinx/cdomain.py @@ -54,7 +54,7 @@ namespace = None # # Handle trivial newer c domain tags that are part of Sphinx 3.1 c domain tags # - Store the namespace if ".. c:namespace::" tag is found - +# RE_namespace = re.compile(r'^\s*..\s*c:namespace::\s*(\S+)\s*$') def markup_namespace(match): @@ -64,10 +64,48 @@ def markup_namespace(match): return "" +# +# Handle c:macro for function-style declaration +# +RE_macro = re.compile(r'^\s*..\s*c:macro::\s*(\S+)\s+(\S.*)\s*$') +def markup_macro(match): + return ".. c:function:: " + match.group(1) + ' ' + match.group(2) + +# +# Handle newer c domain tags that are evaluated as .. c:type: for +# backward-compatibility with Sphinx < 3.0 +# +RE_ctype = re.compile(r'^\s*..\s*c:(struct|union|enum|enumerator|alias)::\s*(.*)$') + +def markup_ctype(match): + return ".. c:type:: " + match.group(2) + +# +# Handle newer c domain tags that are evaluated as :c:type: for +# backward-compatibility with Sphinx < 3.0 +# +RE_ctype_refs = re.compile(r':c:(var|struct|union|enum|enumerator)::`([^\`]+)`') +def markup_ctype_refs(match): + return ":c:type:`" + match.group(2) + '`' + +# +# Simply convert :c:expr: and :c:texpr: into a literal block. +# +RE_expr = re.compile(r':c:(expr|texpr):`([^\`]+)`') +def markup_c_expr(match): + return '\ ``' + match.group(2) + '``\ ' + +# +# Parse Sphinx 3.x C markups, replacing them by backward-compatible ones +# def c_markups(app, docname, source): result = "" markup_func = { RE_namespace: markup_namespace, + RE_expr: markup_c_expr, + RE_macro: markup_macro, + RE_ctype: markup_ctype, + RE_ctype_refs: markup_ctype_refs, } lines = iter(source[0].splitlines(True)) -- 2.26.2