Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3794459pxf; Mon, 29 Mar 2021 11:35:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9uBPZ3FRL8y1AgRto6gI4kY4bozwV6/bjkAsmUP4Z/RbmEusvCbK5WhCGaAERokyUiOZW X-Received: by 2002:a17:907:d15:: with SMTP id gn21mr28900413ejc.337.1617042917806; Mon, 29 Mar 2021 11:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617042917; cv=none; d=google.com; s=arc-20160816; b=i7FbTA+8I3q2bun/s4kp1CkRRT1MTvHKzef+jBr7z98krfKIf5bJcbYiOCPtZj52Xo ch4HU8IRJq9YAezR7r1PIzd3tzK5972CRVqRyCj8RlNdQPtJxMzHuYn78g7UWN36FN+x j88cJTkClF/k3QzQ33ZopYA1vSLRbV4unjcmGwpDwUgQRMrAGzMnK85W1DaFrqcMOsOa Cx9ETpWy9+Q7I/aLoXi27jZSAJyjKyHcBAj/nx1fT89BS+Q0adnwrGyxsKZMeMUNsjxD MeXB7J5L3Egyi32fneU6M2vvwtgwHcCtIOlNIbDmegvJXBpLk+qFJMbX/8KxEMYdCH67 Cqjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=qWPFP062Dl3kdYpflX0czLC4VQJJTmPbyluctMGIE3k=; b=c+C/MXMRJMQQiYMwhXe7r1NZcETIKWoAWdPVkkjmz2YfclJLg90BJB0fLJkNi/K3H7 yo2vYBghapfT0X78Oj2fIxOcjz9YZ+4qP7ViicvUNrJW7SgB4eiDOqisQR2416rPLsoJ hL04HOBGczMfFCAqw3ieFV1YdyTZn3gu+2N1EblFZKzVqUmP1W4aUgCS0bsUYa6hSNzZ iHqXPhu/ZildIh+DOCInhiY5/Wa0I5dbA8ukFnGkycOMY/sm9a+9RNFVQfhay+ivCgug nkSpeup0YPvadYSyD9mLej85PbHsxo9sSQ4g1dQ0TDgeGMLLDNV6ivjOZo8HemuqiV+l pyaQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si13504315ejk.520.2021.03.29.11.34.54; Mon, 29 Mar 2021 11:35:17 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231426AbhC2Sd7 (ORCPT + 99 others); Mon, 29 Mar 2021 14:33:59 -0400 Received: from mga05.intel.com ([192.55.52.43]:15369 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbhC2Sdg (ORCPT ); Mon, 29 Mar 2021 14:33:36 -0400 IronPort-SDR: LSxqw8Yved18eHCFeiCt9yXtnhIq3gYgvIWvg3Vg8eel9KT1TyDjI/8nu2dgOCNquA+xK56CDY bqr9qGn0GGXA== X-IronPort-AV: E=McAfee;i="6000,8403,9938"; a="276770688" X-IronPort-AV: E=Sophos;i="5.81,288,1610438400"; d="scan'208";a="276770688" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 11:33:36 -0700 IronPort-SDR: b6dMCHmsN/szLMRFtlDYijrVu5YTBH2pJDqufuaQmqjltYgrY1AFsxfDObNd2XGb5xzdgX6L0s 8yrIibqi5onA== X-IronPort-AV: E=Sophos;i="5.81,288,1610438400"; d="scan'208";a="417793139" Received: from auchter-mobl.ger.corp.intel.com (HELO localhost) ([10.252.56.199]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 11:33:33 -0700 From: Jani Nikula To: Matthew Wilcox , Jonathan Corbet Cc: Mauro Carvalho Chehab , Linux Doc Mailing List , Rob Herring , linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel-doc: better handle '::' sequences In-Reply-To: <20210329144204.GF351017@casper.infradead.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20210325184615.08526aed@coco.lan> <2cf44cf1fa42588632735d4fbc8e84304bdc235f.1616696051.git.mchehab+huawei@kernel.org> <87tuozyslu.fsf@meer.lwn.net> <20210325191435.GZ1719932@casper.infradead.org> <87a6qrx7wf.fsf@meer.lwn.net> <20210325221437.GA1719932@casper.infradead.org> <87wntux3w7.fsf@meer.lwn.net> <20210329144204.GF351017@casper.infradead.org> Date: Mon, 29 Mar 2021 21:33:30 +0300 Message-ID: <874kgtq079.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 29 Mar 2021, Matthew Wilcox wrote: > On Thu, Mar 25, 2021 at 04:30:32PM -0600, Jonathan Corbet wrote: >> Matthew Wilcox writes: >> >> > The rust code is alredy coming though ... >> > >> > rust/kernel/buffer.rs:/// A pre-allocated buffer that implements [`core::fmt::Write`]. >> > >> > so now we have three formats. Markdown and RST are _very_ similar, but >> > not identical [1]. Oh, and even better we now have three distinct tools -- >> > kerneldoc, rustdoc and sphinx. Have the rust people reached out to you >> > about integrating the various docs? >> >> I have talked with them a bit, yes, but without any clear conclusions at >> this point. The Rust world has its own way of doing things with regard >> to documentation, and I don't want to tell them they can't use it in the >> kernel context. So I think there's going to be a certain amount of >> groping around for the best solution. >> >> We did come to the mutual agreement that teaching kernel-doc to parse >> Rust code as well was not an ideal solution. Probably there will be >> some sort of tool to translate between rustdoc and our sphinx setup. >> Beyond that, we'll see how it goes. > > In the spirit of groping around for the best solution, I did some looking > around at various options, including using rustdoc for .c files (that > uses Markdown, which appears to be strictly worse than rST for our > purposes). > > So here's my "modest proposal": > > - Similar to our ".. kernel-doc::" invocation in .rst files, handle > ".. rustdoc::" (insert weeks of hacking here) > - Now add ".. rst-doc::" which parses .c files like [1] kernel-doc > does, but interprets a different style of comment and actually does > most of the repetitive boring bits for you. As a hobby, I've written a Sphinx extension to use Clang to parse the code and extract pure reStructuredText documentation comments with minimal conversions [1]. No additional syntax. Just use reStructuredText for everything instead of inventing your own. I'm not proposing to use that in kernel, at all. It was more like a diversion from the kernel documentation. But based on my experience with the old and new kernel documentation systems and the hobby one, the one takeaway is to not create new syntaxes, grammars, parsers, or preprocessors to be maintained by the kernel community. Just don't. Take what's working and supported by other projects, and add the minimal glue using Sphinx extensions to put it together, and no more. Of course, we couldn't ditch kernel-doc the script, but we managed to trim it down quite a bit. OTOH, there have been a number of additions outside of Sphinx in Makefiles and custom tools in various languages that I'm really not happy about. It's all too reminiscient of the old DocBook toolchain, while Sphinx was supposed to be the one tool to tie it all together, partially chosen because of the extension support. BR, Jani. [1] https://github.com/jnikula/hawkmoth > > For example, xa_load: > > /** > * xa_load() - Load an entry from an XArray. > * @xa: XArray. > * @index: index into array. > * > * Context: Any context. Takes and releases the RCU lock. > * Return: The entry at @index in @xa. > */ > void *xa_load(struct xarray *xa, unsigned long index) > > //rST > // Load an entry from an XArray. > // > // :Context: Any context. Takes and releases the RCU lock. > // :Return: The entry in `xa` at `index`. > void *xa_load(struct xarray *xa, unsigned long index) > > (more complex example below [2]) > > Things I considered: > > - Explicitly document that this is rST markup instead of Markdown or > whatever. > - Don't repeat the name of the function. The tool can figure it out. > - Don't force documenting each parameter. Often they are obvious > and there's really nothing interesting to say about the parameter. > Witness the number of '@foo: The foo' (of type struct foo) that we > have scattered throughout the tree. It's not that the documenter is > lazy, it's that there's genuinely nothing to say here. > - Use `interpreted text` to refer to parameters instead of *emphasis* or > **strong emphasis**. The tool can turn that into whatever markup > is appropriate. > - Use field lists for Context and Return instead of sections. The markup > is simpler to use, and I think the rendered output is better. > > [1] by which i mean "in a completely different way from, but similar in > concept" > > [2] More complex example: > > /** > * xa_store() - Store this entry in the XArray. > * @xa: XArray. > * @index: Index into array. > * @entry: New entry. > * @gfp: Memory allocation flags. > * > * After this function returns, loads from this index will return @entry. > * Storing into an existing multi-index entry updates the entry of every index. > * The marks associated with @index are unaffected unless @entry is %NULL. > * > * Context: Any context. Takes and releases the xa_lock. > * May sleep if the @gfp flags permit. > * Return: The old entry at this index on success, xa_err(-EINVAL) if @entry > * cannot be stored in an XArray, or xa_err(-ENOMEM) if memory allocation > * failed. > */ > void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) > > //rST > // Store an entry in the XArray. > // > // After this function returns, loads from `index` will return `entry`. > // Storing into an existing multi-index entry updates the entry of every index. > // The marks associated with `index` are unaffected unless `entry` is ``NULL``. > // > // :Context: Any context. Takes and releases the xa_lock. > // May sleep if the `gfp` flags permit. > // :Return: The old entry at this index on success, xa_err(-EINVAL) if `entry` > // cannot be stored in an XArray, or xa_err(-ENOMEM) if memory allocation > // failed. > void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) > -- Jani Nikula, Intel Open Source Graphics Center