Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2503993ybd; Mon, 24 Jun 2019 07:34:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKKCAXx6fg662L4jmC+O0BIUYItAoAyyFYBEsbjQlyJgjGpYYGDyLRefhvdcDdF1SIbL7g X-Received: by 2002:a17:902:848b:: with SMTP id c11mr125662680plo.217.1561386840950; Mon, 24 Jun 2019 07:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561386840; cv=none; d=google.com; s=arc-20160816; b=NzkHmHhB/sDnnAR6+IxkJ2lYf8wmw3j/nGsMasg+h1FSKsLbQtxK51/PKfefMyEo68 UZb+AKuIvI0zpzNZJi5DUVlD40NQyhLKlHe3ISM5yl4wU0zspLsMlswqFFPAF1xPiNyp 2vUcAzuzHirPffjoQ7equ0/izmS9vMtaSbH2YhVx4aeqoPiSfo0Pw8oRNUm65m4AHP+e LRATUWdZLJV9VzCTdb/PcXGKEY3p5nelvJyE8fCxVf2fSrtYQj24BksMSLq0pFIoDH1s rcDHpMQlmsqHaAIP5P0fJOX2FgMI9cG3D+WHz/h5TKg/DLJyY7hIXJD18Y3SW++3m3ET AnZA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=qE2lqMzh3viAMQxRMc1hVhGvkqdZ1ubE+UZXmqf7dQ0=; b=pnDVS7FoDali3Wf3cwyqy7A8Wkn/5c70/WUcBBATFCST2QTW131jPEitGyElDp55kD fOVyz0ByKLJowKqhoyNuwZNZ2W5ERorogXiIJh2nCqU25CKLKJlHZ2okwjuYlZecPzb2 gVZ16BQl6nYF38+vQHT/mV9mTAvGKKsQ0dDWkdkttGRx29N8mu2tDgYwDgtVnvOw84Ue 6jM7ZdIN13XGmC/5m8rTVg3DijsKckxMG7xe8aq8I8wMcWUWpHE0StPJXJogJEVyvOHg XTm5FruEzx2EzSae/T9tLfHokX5NewQsBX9GfNRctiBx5LZyb6vy/9DBa9A6bAHkRjxW gtMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j100si11193754pje.52.2019.06.24.07.33.45; Mon, 24 Jun 2019 07:34:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728130AbfFXO0A (ORCPT + 99 others); Mon, 24 Jun 2019 10:26:00 -0400 Received: from ms.lwn.net ([45.79.88.28]:43870 "EHLO ms.lwn.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726263AbfFXO0A (ORCPT ); Mon, 24 Jun 2019 10:26:00 -0400 Received: from lwn.net (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ms.lwn.net (Postfix) with ESMTPSA id A686D35A; Mon, 24 Jun 2019 14:25:59 +0000 (UTC) Date: Mon, 24 Jun 2019 08:25:58 -0600 From: Jonathan Corbet To: Jani Nikula Cc: linux-doc@vger.kernel.org, Matthew Wilcox , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] Docs: An initial automarkup extension for sphinx Message-ID: <20190624082558.62e6c0d2@lwn.net> In-Reply-To: <87k1dbrziw.fsf@intel.com> References: <20190621235159.6992-1-corbet@lwn.net> <20190621235159.6992-2-corbet@lwn.net> <87k1dbrziw.fsf@intel.com> Organization: LWN.net MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 Jun 2019 14:30:47 +0300 Jani Nikula wrote: > > +def auto_markup(app, doctree, name): > > + for para in doctree.traverse(nodes.paragraph): > > + for node in para.traverse(nodes.Text): > > + if not isinstance(node.parent, nodes.literal): > > + node.parent.replace(node, markup_funcs(name, app, node)) > > I think overall this is a better approach than preprocessing. Thanks for > doing this! > > I toyed with something like this before, and the key difference here > seems to be ignoring literal blocks. The problem seemed to be that > replacing blocks with syntax highlighting also removed the syntax > highlighting, with no way that I could find to bring it back. That test could use a comment, really. What it is actually doing is skipping text chunks in ``inline literal`` sections, and what that is *actually* doing is avoiding marking up functions that have an explicit :c:func: markup on them already. Someday I don't doubt that this loop will be replaced by a proper tree walk that knows where to prune things and how to replace various other types of nodes, but this is easy and does the right thing pretty much everywhere as far as I can tell. Thanks, jon