From: Akira Yokosawa <akiyks@gmail.com>
To: Miguel Ojeda <ojeda@kernel.org>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH v4 15/20] docs: add Rust documentation
Date: Wed, 16 Feb 2022 22:37:26 +0900 [thread overview]
Message-ID: <5d8e8c09-64ca-38cd-591d-c193d1c01c7e@gmail.com> (raw)
In-Reply-To: <8baf7006-90ed-25b8-3005-69b5475215cf@gmail.com>
[Dropped most CCs]
Hi Miguel.
I have a follow-up hint on cross referencing for you. See below.
On Mon, 14 Feb 2022 19:47:36 +0900,
Akira Yokosawa wrote:
> Hi,
>
> Please find inline comments WRT ReST-in-kereneldoc.
>
> Jon, if I'm missing something, please enlighten me.
>
> On Sat, 12 Feb 2022 14:03:41 +0100,
> Miguel Ojeda <ojeda@kernel.org> wrote:
[...]
>> diff --git a/Documentation/rust/general-information.rst b/Documentation/rust/general-information.rst
>> new file mode 100644
>> index 000000000000..9ee4c6994d08
>> --- /dev/null
>> +++ b/Documentation/rust/general-information.rst
>> @@ -0,0 +1,80 @@
>> +.. _rust_general_information:
> Unnecessary tag.
>
>> +
>> +General Information
>> +===================
>> +
>> +This document contains useful information to know when working with
>> +the Rust support in the kernel.
>> +
>> +
>> +Code documentation
>> +------------------
>> +
>> +Rust kernel code is documented using ``rustdoc``, its built-in documentation
>> +generator.
>> +
>> +The generated HTML docs include integrated search, linked items (e.g. types,
>> +functions, constants), source code, etc. They may be read at (TODO: link when
>> +in mainline and generated alongside the rest of the documentation):
>> +
>> + http://kernel.org/
>> +
>> +The docs can also be easily generated and read locally. This is quite fast
>> +(same order as compiling the code itself) and no special tools or environment
>> +are needed. This has the added advantage that they will be tailored to
>> +the particular kernel configuration used. To generate them, use the ``rustdoc``
>> +target with the same invocation used for compilation, e.g.::
>> +
>> + make LLVM=1 rustdoc
>> +
>> +To read the docs locally in your web browser, run e.g.::
>> +
>> + xdg-open rust/doc/kernel/index.html
>> +
>> +To learn about how to write the documentation, please see the coding guidelines
>> +at :ref:`Documentation/rust/coding-guidelines.rst <rust_coding_guidelines>`.
> at Documentation/rust/coding-guidelines.rst.
Here, the cross reference is internal to Documentation/rust/.
In this case, a relative path works for both top and subdirectory level build.
So you can say:
at coding-guidelines.rst.
>
>> +
>> +
>> +Extra lints
>> +-----------
>> +
>> +While ``rustc`` is a very helpful compiler, some extra lints and analyses are
>> +available via ``clippy``, a Rust linter. To enable it, pass ``CLIPPY=1`` to
>> +the same invocation used for compilation, e.g.::
>> +
>> + make LLVM=1 CLIPPY=1
>> +
>> +Please note that Clippy may change code generation, thus it should not be
>> +enabled while building a production kernel.
>> +
>> +
>> +Abstractions vs. bindings
>> +-------------------------
>> +
>> +Abstractions are Rust code wrapping kernel functionality from the C side.
>> +
>> +In order to use functions and types from the C side, bindings are created.
>> +Bindings are the declarations for Rust of those functions and types from
>> +the C side.
>> +
>> +For instance, one may write a ``Mutex`` abstraction in Rust which wraps
>> +a ``struct mutex`` from the C side and calls its functions through the bindings.
>> +
>> +Abstractions are not available for all the kernel internal APIs and concepts,
>> +but it is intended that coverage is expanded as time goes on. "Leaf" modules
>> +(e.g. drivers) should not use the C bindings directly. Instead, subsystems
>> +should provide as-safe-as-possible abstractions as needed.
>> +
>> +
>> +Conditional compilation
>> +-----------------------
>> +
>> +Rust code has access to conditional compilation based on the kernel
>> +configuration:
>> +
>> +.. code-block:: rust
>> +
>> + #[cfg(CONFIG_X)] // Enabled (`y` or `m`)
>> + #[cfg(CONFIG_X="y")] // Enabled as a built-in (`y`)
>> + #[cfg(CONFIG_X="m")] // Enabled as a module (`m`)
>> + #[cfg(not(CONFIG_X))] // Disabled
>> diff --git a/Documentation/rust/index.rst b/Documentation/rust/index.rst
>> new file mode 100644
>> index 000000000000..6e20af5b723a
>> --- /dev/null
>> +++ b/Documentation/rust/index.rst
>> @@ -0,0 +1,21 @@
>> +Rust
>> +====
>> +
>> +Documentation related to Rust within the kernel. To start using Rust
>> +in the kernel, please read the
>> +:ref:`Documentation/rust/quick-start.rst <rust_quick_start>` guide.
> in the kernel, please read the guide in Documentation/rust/quick-start.rst.
in the kernel, please read the guide in quick-start.rst.
, and so on.
Thanks, Akira
[...]
>
>
> Notes:
>
> Those cross-references of plain path such as
>
> Documentation/rust/general-information.rst
>
> are recognized when you build by the top level "make htmldocs".
> If you specify a subdirectory by "make SPHINXDIRS=rust htmldocs",
> current build script can't recognize them. This is one of (not
> widely recognized) issues in subdirectory handling of automarkup.py.
> Hopefully, they can be resolved soon.
>
> Tags at the top of .rst files are redundant and should be avoided.
> Existing ones can be removed after referencing sites are updated.
>
> Thanks, Akira
next prev parent reply other threads:[~2022-02-16 13:37 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-12 13:03 [PATCH v4 00/20] Rust support Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 01/20] kallsyms: support "big" kernel symbols Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 02/20] kallsyms: increase maximum kernel symbol length to 512 Miguel Ojeda
2022-02-22 8:19 ` Petr Mladek
2022-02-22 12:45 ` Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 03/20] kallsyms: use the correct buffer size for symbols Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 04/20] rust: add C helpers Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 05/20] rust: add `compiler_builtins` crate Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 06/20] rust: add `alloc` crate Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 07/20] rust: add `build_error` crate Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 08/20] rust: add `macros` crate Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 09/20] rust: add `kernel` crate's `sync` module Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 10/20] rust: add `kernel` crate Miguel Ojeda
2022-02-14 5:27 ` Sergey Senozhatsky
2022-02-14 13:36 ` Miguel Ojeda
2022-02-22 9:06 ` Petr Mladek
2022-02-22 12:48 ` Miguel Ojeda
2022-02-24 12:39 ` Petr Mladek
2022-02-12 13:03 ` [PATCH v4 11/20] rust: export generated symbols Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 12/20] vsprintf: add new `%pA` format specifier Miguel Ojeda
2022-02-14 10:18 ` Andy Shevchenko
2022-02-14 10:52 ` Rasmus Villemoes
2022-02-14 11:36 ` David Laight
2022-02-14 14:04 ` Miguel Ojeda
2022-02-14 12:12 ` Miguel Ojeda
2022-02-22 9:29 ` Petr Mladek
2022-02-22 10:35 ` Rasmus Villemoes
2022-02-24 9:55 ` Petr Mladek
2022-02-14 12:27 ` Miguel Ojeda
2022-02-14 13:54 ` Andy Shevchenko
2022-02-14 14:56 ` Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 13/20] scripts: add `generate_rust_analyzer.py` Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 14/20] scripts: decode_stacktrace: demangle Rust symbols Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 15/20] docs: add Rust documentation Miguel Ojeda
2022-02-14 10:47 ` Akira Yokosawa
2022-02-14 12:44 ` Miguel Ojeda
2022-02-16 13:37 ` Akira Yokosawa [this message]
2022-02-16 14:02 ` Miguel Ojeda
2022-03-17 8:19 ` Miguel Ojeda
2022-03-17 14:50 ` Akira Yokosawa
2022-03-18 13:12 ` Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 16/20] Kbuild: add Rust support Miguel Ojeda
2022-02-12 14:16 ` Russell King (Oracle)
2022-02-12 15:47 ` Miguel Ojeda
2022-02-12 16:18 ` Russell King (Oracle)
2022-02-12 18:32 ` Miguel Ojeda
2022-02-12 18:27 ` John Paul Adrian Glaubitz
2022-02-12 18:57 ` Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 17/20] samples: add Rust examples Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 18/20] MAINTAINERS: Rust Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 19/20] [RFC] drivers: gpio: PrimeCell PL061 in Rust Miguel Ojeda
2022-02-12 13:03 ` [PATCH v4 20/20] [RFC] drivers: android: Binder IPC " Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d8e8c09-64ca-38cd-591d-c193d1c01c7e@gmail.com \
--to=akiyks@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).