Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2412062rwo; Thu, 3 Aug 2023 09:01:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlFMquSgsSHcoy+d7yuoeCGN/OUlGNkYjrHy8VJF2sMxnu2DjEjXzCW+7FudyQVAacIWay9g X-Received: by 2002:a17:906:1a:b0:98e:1c4b:10bb with SMTP id 26-20020a170906001a00b0098e1c4b10bbmr7868623eja.35.1691078508022; Thu, 03 Aug 2023 09:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691078508; cv=none; d=google.com; s=arc-20160816; b=SITJxjoTn/yGSi03UC28kKVfWdU7kvvI+hFxRGplfdiHmBVmp262y9wOyEMtUq4Ief OYXswxcjFJNGVS5+XE6MktNjzlOTIUSxTuMWWmKZwBGp3a31Ee0MZgdMmZ1OpM+HIL7h HHxhfwaMrAxjjcvrxuXCQtjZYwZoNRZozehTlvEmpIiYVKUnLSguNVunliR6nJr4OLgG 5BMO+1YywXN4GTjzqvSK93aExIotXhUz+srqp/kfXlvEI/yVa/XyoL5T9FemmCk0Xq5Y XzxOZ2QMaSyKDEWs8lMUszyCpjPOlfx2SrIj0GhQxyfEw8LGy6yVpeGKAYHcgW8ckBvu S5xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=+oypXlWJh1usCB/TTGcantnU/B7Uqzl56Nf26cP4N8s=; fh=W4oG57Da1Zx1T3zrXhSUnQRAgw4ALpqPPQCEBZ2AmPk=; b=ODUti1anxXfyk17UwpCtp0NIgnyXwfPa2M/vSb7SjetB2E6udX8cgtp3WY6vqH2t/t 36PusYHretGnZJ/OVB0lJhvzEOPvbeSQUEajmTWTh4v+41E6YUzGa1vLEw6nA1IVFXJv MnMVkK9nlD7GzCFHeObKrO6nAQqTrWfgKjXTKFcQW+uqim94F21yPIq5FqSws1+OTgBt oeG66rbrPwClNYymwi23G2rrj2VZhe2bqb51ucgTX2QUy8J16+jucx3+TmPegTdAP98D g75pI/8JSLEPUwDE0oXa2DPTBLUayWPQCI/LwgHXRfs+d8VAPgOrP+JIG8AM84iS2g3U 9cnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=OK1VuHd3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umich.edu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v7-20020a1709060b4700b00991c8af7ba5si7329ejg.473.2023.08.03.09.01.11; Thu, 03 Aug 2023 09:01:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=OK1VuHd3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umich.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235586AbjHCPfZ (ORCPT + 99 others); Thu, 3 Aug 2023 11:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234779AbjHCPfY (ORCPT ); Thu, 3 Aug 2023 11:35:24 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6AD130FD for ; Thu, 3 Aug 2023 08:35:22 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2b9c907bc68so17408091fa.2 for ; Thu, 03 Aug 2023 08:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=google-2016-06-03; t=1691076921; x=1691681721; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+oypXlWJh1usCB/TTGcantnU/B7Uqzl56Nf26cP4N8s=; b=OK1VuHd3EGGmJr0c72gzI4bUbGLQX/zaO7kzw0oeYvMGZjAYwVTDZxOpXEBAp3cT32 XWXoAtkwgC1kAmdnvuxCfhsPzX+tc+Q0VDXmtMOe1iBbs/l+1u6dlILAMlmQ5NVQX+Yb u3Y+wb1SzLbptfcMbIh49YJkEXOu31DLnuIR+P4FycBrD387mzhqR0hmnVmQfsqaJZJ2 BJV54K2VxJtvjjRuiidNUpUak3vlA5Suz5TytjSj5qoT3F2Ms1KhzvRIHHH72oSbl3G2 pdpxzs4yN8SenTS6HqDMoqkBTZWYKa4cbiEflYsG5AeprWMUX2gOlKFI592WlPeFtuDm qd0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691076921; x=1691681721; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+oypXlWJh1usCB/TTGcantnU/B7Uqzl56Nf26cP4N8s=; b=EZFmSKo8ZM/meSq5NYVDJMwVotd4auPBs8nYYMnyWMclfXgmLOObB2zSMCG8eDc0Rt PgkFrvC494OrYX0T8xj8j0G8UNW3GBoGjOq/gSBELQR1G23U3ynHv0S+XBvlKmIwN8uG 0WsKQmkwSdC5hol8Bm6tcXhR8t/1wYrKnnSEH+KcwMf1lYuBhxBMRPRat5NUD/gZRu8C 9rAl2MZdA3erm6znrnD8qVVpBEBg1rPgEXmb0lDlOh0KtAkkaPT8TL0nxdcm047yYW7E CisSQrS5QXJ/AEflhmjiqpazR/ljrxUhinn0MeEc74WLUrTwyBhwIxf51gU3TVPC9eDz f6IA== X-Gm-Message-State: ABy/qLY3bNJKp2mo1Z980vy7CWNCuKSEHQg42UmAcK2DjTMbHaTplyOp CIXKw8lsVw0cNuMURC4w0UqsgATm0Fd6Fu+qCmR1LA== X-Received: by 2002:a2e:b70e:0:b0:2b6:df71:cff1 with SMTP id j14-20020a2eb70e000000b002b6df71cff1mr7872137ljo.52.1691076920952; Thu, 03 Aug 2023 08:35:20 -0700 (PDT) MIME-Version: 1.0 References: <20230803093418.51872-1-tmgross@umich.edu> In-Reply-To: From: Trevor Gross Date: Thu, 3 Aug 2023 11:35:09 -0400 Message-ID: Subject: Re: [RFC PATCH 0/2] Generate API documentation for 'bindings' crate To: Miguel Ojeda Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 3, 2023 at 10:08=E2=80=AFAM Miguel Ojeda wrote: > I think the first question to answer would be whether we want to > expose `bindings`, i.e. what are the advantages/disadvantages? > > If `kernel` were a "normal library", then I would say we shouldn't, > because users should not need to care; and, in addition, the goal is > that leaf modules do not need to access them directly. > > But, as sometimes happen, it may still be quite useful for some > developers nevertheless (the same way documenting the internal/private > details could be). > > So, it would be nice to have an overview from your point of view on > why it should be done (or not). I do understand that dilemma, but am not sure what the happy medium is between rendering them and hiding them. Where I see value is: 1. For anyone reading/writing abstractions, it's useful to quickly see how exactly bindgen did the C -> Rust mapping 2. Abstractions may want to link to the C side somehow, linking the bindings is an easier first step than linking to sphinx (in the future we may be able to do a bindings -> sphinx link) Maybe a stronger "prefer abstractions over bindings" message would suffice to discourage use outside of reference? In any case, I will put this behind a flag so it is not enabled by default. While I'm at it - is there value in adding a config option to pass `--document-private-items` to the kernel crate, or supporting `RUSTDOCFLAGS` like Cargo does? > > 1. Do we want to make this the default, or a separate target/ > > configuration? I don't think there is much downside to always > > generating. > > One downside of doing it by default would be going against the "avoid > `bindings`" guideline (ideally rule). > > Another one is render time (the C side is trying to reduce it), I > guess, especially if we keep adding headers over time. That makes sense, I will add the flag option. > > 2. The entire '.config' file could be included in the doc output, to > > make it easy to tell what settings the documentation was generated > > with. Would this be desired? Maybe with a '--cfg > > include-dotcfg=3D".config"' flag so published docs would have the > > option (unsure whether it may ever have sensitive information). > > This may be useful orthogonally to rendering `bindings` or not. > I will add this in a separate patch. > > Bindgen is currently invoked with '--no-doc-comments', I think this may > > be because some blocks were mistakenly interpreted as doctests. Once we > > upgrade our bindgen version we might be able to remove this. > > Yes, that is https://github.com/Rust-for-Linux/linux/issues/323 and > https://github.com/rust-lang/rust-bindgen/issues/2057, which led to > the addition of `process_comments` to `bindgen` in v0.63.0. How would switching to the library work? Since that seems like a more involved discussion, would postprocesing `generated_bindings.rs` be acceptable instead? I have been playing around with a python script that extracts the `#[doc ...]` blocks and (1) fixes the escaping and (2) formats parameters and fixes their spacing, I could extract this to a separate patch if it may be a while before we can use the library. > > Side note, 'rust/Makefile' seems to have a mix of tabs and spaces - is > > this intentional? > > Yes, it is intentional. For instance, the command definitions use > spaces like the vast majority of the kernel `Makefile`s. Ah thanks, it just looks a bit weird in the diff. > Cheers, > Miguel Thanks! Trevor