Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4571387pxk; Wed, 30 Sep 2020 06:31:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr1O0gvIuvihIZJ85ZQiKJsSJTDzi/fky4C5Ua7eQTjLD8mHtmo6XUdtQn/jummjUj5UyP X-Received: by 2002:a17:906:3495:: with SMTP id g21mr2691814ejb.121.1601472719037; Wed, 30 Sep 2020 06:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601472719; cv=none; d=google.com; s=arc-20160816; b=W+PcAXF+SkE8vFa1r0cvWHcd6plJ9oDkVafn86ggzpmiZAemMRRDgmP16baxH8Vp6h P/NyYuPTJaV1K8f+malFLpH5+k9W7DuEs/IX5DYzvvzWvlnORKaoJoRFEY3fMg05eEna nnUw24nA6MrTK/SEJZuCDvhQrDS112cXw6hDJsJhRp4wmUzzdRPiHUtoxffTpYFa3ilm D48RlS3pvvITtkhLl94OlHkf9IG6BQz1VVAmFzA1z/pYUAt6kq6oaeJMdRZhbSthhl84 Btiih2z11mVEx7ys5p2d8eJmv9uXMH3avDutYLfwnuqJaofiP+zTg8UtUWmhu8FCPXtE Essg== 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=UoSD7jAtehggNfL74anLcRlCtYzeJAgKI3BbAPsSIDOfEErJuialZ7i22VDXTw9MF8 0oRzDcuCRvxQuE125+DsZ3wu8K1rY3kdVZj0zz5VOwIhaDO+IB+mVxDB0zXXHnODdGWD aA51cgPfqbRvojI98xQaItkiGLQYP28kL+1Cse9zc5G+pH5/YyAYjgNcpBVgpnSNRLb1 a58AungC4veSbaoyH36r2eX4X2YMUntd33oZLkyAi0nJ+9WmvzlmyiqP2yAASJZ7b4D9 ENl9j2O0mOTKCGcvY41CCuQLTvbwR4Z2APMoU51y8wAeg5SFj8gdAly1heCDu8kPCmc2 hUnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BCanuSxc; 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 x26si975706edi.79.2020.09.30.06.31.34; Wed, 30 Sep 2020 06:31:59 -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=BCanuSxc; 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 S1730833AbgI3N2z (ORCPT + 99 others); Wed, 30 Sep 2020 09:28:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:38556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgI3NZU (ORCPT ); Wed, 30 Sep 2020 09:25:20 -0400 Received: from mail.kernel.org (unknown [95.90.213.196]) (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 9F11820754; Wed, 30 Sep 2020 13:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601472319; bh=8Wg4J7Lyd/Va8b7XV8z9jXdPVZ/IrSKHVEYF1TFbuSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BCanuSxcc/ikhDINlc/qIR5yo//gtqQ9HzjwgCwXQL6qh0AfRSxsvigycZJjze5Lr GXpGNcfSscthQWopSwJhjAe6Dny3BuMInbntwdE2b0usTgae7mv8zbDdzvVvWpAaI7 gyrITZNcOYca1eBLAPYjXR1LRoiz71bSPWz1UFqI= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1kNc6f-001XIu-KS; Wed, 30 Sep 2020 15:25:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v4 02/52] docs: cdomain.py: extend it to handle new Sphinx 3.x tags Date: Wed, 30 Sep 2020 15:24:25 +0200 Message-Id: <9c56ddb12976ec0f5a04cb3ce5e1e28ed22ff88c.1601467849.git.mchehab+huawei@kernel.org> 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