[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <08b3f964-a66e-483d-81dd-4f6f8f61bdbd@gmail.com>
Date: Sat, 16 Dec 2023 10:56:25 -0300
From: Martin Rodriguez Reboredo <yakoyoku@...il.com>
To: Miguel Ojeda <ojeda@...nel.org>, Wedson Almeida Filho
<wedsonaf@...il.com>, Alex Gaynor <alex.gaynor@...il.com>
Cc: Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...sung.com>, Alice Ryhl
<aliceryhl@...gle.com>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org, patches@...ts.linux.dev,
FUJITA Tomonori <fujita.tomonori@...il.com>
Subject: Re: [PATCH] rust: support `srctree`-relative links
On 12/15/23 20:54, Miguel Ojeda wrote:
> Some of our links use relative paths in order to point to files in the
> source tree, e.g.:
>
> //! C header: [`include/linux/printk.h`](../../../../include/linux/printk.h)
> /// [`struct mutex`]: ../../../../include/linux/mutex.h
>
> These are problematic because they are hard to maintain and do not support
> `O=` builds.
>
> Instead, provide support for `srctree`-relative links, e.g.:
>
> //! C header: [`include/linux/printk.h`](srctree/include/linux/printk.h)
> /// [`struct mutex`]: srctree/include/linux/mutex.h
>
> The links are fixed after `rustdoc` generation to be based on the absolute
> path to the source tree.
>
> Essentially, this is the automatic version of Tomonori's fix [1],
> suggested by Gary [2].
>
> Suggested-by: Gary Guo <gary@...yguo.net>
> Reported-by: FUJITA Tomonori <fujita.tomonori@...il.com>
> Closes: https://lore.kernel.org/r/20231026.204058.2167744626131849993.fujita.tomonori@gmail.com [1]
> Fixes: 48fadf440075 ("docs: Move rustdoc output, cross-reference it")
> Link: https://lore.kernel.org/rust-for-linux/20231026154525.6d14b495@eugeo/ [2]
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>
> ---
> Documentation/rust/coding-guidelines.rst | 13 +++++++++++++
> rust/Makefile | 3 ++-
> rust/kernel/error.rs | 2 +-
> rust/kernel/ioctl.rs | 2 +-
> rust/kernel/kunit.rs | 2 +-
> rust/kernel/print.rs | 8 ++++----
> rust/kernel/sync/condvar.rs | 2 +-
> rust/kernel/sync/lock/mutex.rs | 2 +-
> rust/kernel/sync/lock/spinlock.rs | 2 +-
> rust/kernel/task.rs | 2 +-
> rust/kernel/workqueue.rs | 2 +-
> rust/macros/lib.rs | 2 +-
> 12 files changed, 28 insertions(+), 14 deletions(-)
>
> diff --git a/Documentation/rust/coding-guidelines.rst b/Documentation/rust/coding-guidelines.rst
> index aa8ed082613e..05542840b16c 100644
> [...]
> diff --git a/rust/Makefile b/rust/Makefile
> index 543b37f6c77f..73ea24117f07 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -98,7 +98,8 @@ rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
> $(Q)find $(rustdoc_output) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
> -e 's:rust-logo-[0-9a-f]+\.svg:logo.svg:g' \
> -e 's:favicon-[0-9a-f]+\.svg:logo.svg:g' \
> - -e 's:<link rel="alternate icon" type="image/png" href="[/.]+/static\.files/favicon-(16x16|32x32)-[0-9a-f]+\.png">::g'
> + -e 's:<link rel="alternate icon" type="image/png" href="[/.]+/static\.files/favicon-(16x16|32x32)-[0-9a-f]+\.png">::g' \
> + -e 's:<a href="srctree/([^"]+)">:<a href="$(abs_srctree)/\1">:g'
Another way would be to not put `srctree` in the link and add
`abs_srctree` here to directories that are in `srctree`. But that might
be too wonky to rely on so this will be the way to go.
> $(Q)for f in $(rustdoc_output)/static.files/rustdoc-*.css; do \
> echo ".logo-container > img { object-fit: contain; }" >> $$f; done
>
> [...]
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@...il.com>
Powered by blists - more mailing lists