2022-11-30 22:29:24

by Bilbao, Carlos

[permalink] [raw]
Subject: [PATCH] docs: Integrate rustdoc into Rust documentation

Include HTML output generated with rustdoc into the Linux kernel
documentation on Rust. Change target `make htmldocs` to combine RST Sphinx
and the generation of Rust documentation, when support is available.

Signed-off-by: Carlos Bilbao <[email protected]>
---
Documentation/Makefile | 4 ++++
Documentation/rust/index.rst | 1 +
Documentation/rust/rustdoc.rst | 7 +++++++
rust/Makefile | 15 +++++++++------
4 files changed, 21 insertions(+), 6 deletions(-)
create mode 100644 Documentation/rust/rustdoc.rst

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 64d44c1ecad3..5e9435198cfb 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -92,6 +92,10 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
fi

htmldocs:
+# If Rust support is available, add rustdoc generated contents
+ifdef CONFIG_RUST
+ @make LLVM=1 rustdoc
+endif
@$(srctree)/scripts/sphinx-pre-install --version-check
@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))

diff --git a/Documentation/rust/index.rst b/Documentation/rust/index.rst
index 4ae8c66b94fa..5e7a9d39af90 100644
--- a/Documentation/rust/index.rst
+++ b/Documentation/rust/index.rst
@@ -13,6 +13,7 @@ in the kernel, please read the quick-start.rst guide.
general-information
coding-guidelines
arch-support
+ rustdoc

.. only:: subproject and html

diff --git a/Documentation/rust/rustdoc.rst b/Documentation/rust/rustdoc.rst
new file mode 100644
index 000000000000..aa63a550b34c
--- /dev/null
+++ b/Documentation/rust/rustdoc.rst
@@ -0,0 +1,7 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Rustdoc output
+==============
+
+If this documentation includes rustdoc-generated HTML, the entry point
+can be found `here. <rustdoc/kernel/index.html>`_
diff --git a/rust/Makefile b/rust/Makefile
index f32df0e49815..eb2ff9260a6c 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -1,5 +1,8 @@
# SPDX-License-Identifier: GPL-2.0

+# Where to place rustdoc generated documentation
+RUSTDOC_OUTPUT=$(objtree)/Documentation/output/rust/rustdoc
+
always-$(CONFIG_RUST) += target.json
no-clean-files += target.json

@@ -67,7 +70,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
OBJTREE=$(abspath $(objtree)) \
$(RUSTDOC) $(if $(rustdoc_host),$(rust_common_flags),$(rust_flags)) \
$(rustc_target_flags) -L$(objtree)/$(obj) \
- --output $(objtree)/$(obj)/doc \
+ --output $(RUSTDOC_OUTPUT) \
--crate-name $(subst rustdoc-,,$@) \
@$(objtree)/include/generated/rustc_cfg $<

@@ -84,15 +87,15 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
# and then retouch the generated files.
rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
rustdoc-alloc rustdoc-kernel
- $(Q)cp $(srctree)/Documentation/images/logo.svg $(objtree)/$(obj)/doc
- $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(objtree)/$(obj)/doc
- $(Q)find $(objtree)/$(obj)/doc -name '*.html' -type f -print0 | xargs -0 sed -Ei \
+ $(Q)cp $(srctree)/Documentation/images/logo.svg $(RUSTDOC_OUTPUT)
+ $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(RUSTDOC_OUTPUT)
+ $(Q)find $(RUSTDOC_OUTPUT) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
-e 's:rust-logo\.svg:logo.svg:g' \
-e 's:rust-logo\.png:logo.svg:g' \
-e 's:favicon\.svg:logo.svg:g' \
-e 's:<link rel="alternate icon" type="image/png" href="[./]*favicon-(16x16|32x32)\.png">::g'
$(Q)echo '.logo-container > img { object-fit: contain; }' \
- >> $(objtree)/$(obj)/doc/rustdoc.css
+ >> $(RUSTDOC_OUTPUT)/rustdoc.css

rustdoc-macros: private rustdoc_host = yes
rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
@@ -153,7 +156,7 @@ quiet_cmd_rustdoc_test = RUSTDOC T $<
@$(objtree)/include/generated/rustc_cfg \
$(rustc_target_flags) $(rustdoc_test_target_flags) \
--sysroot $(objtree)/$(obj)/test/sysroot $(rustdoc_test_quiet) \
- -L$(objtree)/$(obj)/test --output $(objtree)/$(obj)/doc \
+ -L$(objtree)/$(obj)/test --output $(RUSTDOC_OUTPUT) \
--crate-name $(subst rusttest-,,$@) $<

quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
--
2.34.1


2022-12-01 12:50:51

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH] docs: Integrate rustdoc into Rust documentation

On Wed, Nov 30, 2022 at 11:08 PM Carlos Bilbao <[email protected]> wrote:
>
> Include HTML output generated with rustdoc into the Linux kernel
> documentation on Rust. Change target `make htmldocs` to combine RST Sphinx
> and the generation of Rust documentation, when support is available.

Looks better, thanks for this v2! A few comments below...

> +ifdef CONFIG_RUST
> + @make LLVM=1 rustdoc
> +endif

The Rust docs should probably be built with the build
system/config/... as given, whether it is GCC, LLVM, etc. This should
probably use `$(MAKE)` too; and if you intended to remove the command
line definitions, `MAKEOVERRIDES` too.

Ideally `htmldocs` would depend on `rustdoc`, though that would
require shuffling quite a few things since to build the Rust docs we
need a subset of the Rust dependencies built. Given we may be changing
things soon anyway on the Rust `Makefile`, we can leave that for the
future.

By the way, while checking this, I noticed we use some `CONFIG_`s in
this `Makefile`, but we do not perform a config sync for the `*docs`
targets, so one needs to do so manually, i.e. it can be a pitfall for
e.g. `CONFIG_WARN_MISSING_DOCUMENTS` and ` as well as a potential
`CONFIG_RUST`. Should this be fixed orthogonally, or is it intended?
(some targets do not need the sync, and the ones that need are
probably less used, so I guess that could be the reason?).

> +Rustdoc output
> +==============
> +
> +If this documentation includes rustdoc-generated HTML, the entry point
> +can be found `here. <rustdoc/kernel/index.html>`_

Perhaps this sentence could be moved to the top of the index file, so
that users do not need two clicks when visiting "Rust"? That way we
avoid one more file too.

> +RUSTDOC_OUTPUT=$(objtree)/Documentation/output/rust/rustdoc

Please add a space around the equal sign to be consistent with (most)
of the rest of the file.

Cheers,
Miguel

2022-12-01 20:56:05

by Bilbao, Carlos

[permalink] [raw]
Subject: [PATCH v2] docs: Integrate rustdoc into Rust documentation

Include HTML output generated with rustdoc into the Linux kernel
documentation on Rust. Change target `make htmldocs` to combine RST Sphinx
and the generation of Rust documentation, when support is available.

Signed-off-by: Carlos Bilbao <[email protected]>
---

Changes since V1:
- Work on top of v6.1-rc1.
- Don't use rustdoc.rst, instead add link to Documentation/rust/index.rst.
- In Documentation/Makefile, replace @make rustdoc for $(Q)$(MAKE) rustdoc.
- Don't do LLVM=1 for all rustdoc generation within `make htmldocs`.
- Add spaces on definition of RUSTDOC_OUTPUT, for consistency.

---
Documentation/Makefile | 4 ++++
Documentation/rust/index.rst | 3 +++
rust/Makefile | 15 +++++++++------
3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 64d44c1ecad3..f537cf558af6 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -92,6 +92,10 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
fi

htmldocs:
+# If Rust support is available, add rustdoc generated contents
+ifdef CONFIG_RUST
+ $(Q)$(MAKE) rustdoc
+endif
@$(srctree)/scripts/sphinx-pre-install --version-check
@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))

diff --git a/Documentation/rust/index.rst b/Documentation/rust/index.rst
index 4ae8c66b94fa..4005326c3ba9 100644
--- a/Documentation/rust/index.rst
+++ b/Documentation/rust/index.rst
@@ -6,6 +6,9 @@ Rust
Documentation related to Rust within the kernel. To start using Rust
in the kernel, please read the quick-start.rst guide.

+If this documentation includes rustdoc-generated HTML, the entry point can
+be found `here. <rustdoc/kernel/index.html>`_
+
.. toctree::
:maxdepth: 1

diff --git a/rust/Makefile b/rust/Makefile
index 7700d3853404..080c07048065 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -1,5 +1,8 @@
# SPDX-License-Identifier: GPL-2.0

+# Where to place rustdoc generated documentation
+RUSTDOC_OUTPUT = $(objtree)/Documentation/output/rust/rustdoc
+
always-$(CONFIG_RUST) += target.json
no-clean-files += target.json

@@ -58,7 +61,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
OBJTREE=$(abspath $(objtree)) \
$(RUSTDOC) $(if $(rustdoc_host),$(rust_common_flags),$(rust_flags)) \
$(rustc_target_flags) -L$(objtree)/$(obj) \
- --output $(objtree)/$(obj)/doc \
+ --output $(RUSTDOC_OUTPUT) \
--crate-name $(subst rustdoc-,,$@) \
@$(objtree)/include/generated/rustc_cfg $<

@@ -75,15 +78,15 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
# and then retouch the generated files.
rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
rustdoc-alloc rustdoc-kernel
- $(Q)cp $(srctree)/Documentation/images/logo.svg $(objtree)/$(obj)/doc
- $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(objtree)/$(obj)/doc
- $(Q)find $(objtree)/$(obj)/doc -name '*.html' -type f -print0 | xargs -0 sed -Ei \
+ $(Q)cp $(srctree)/Documentation/images/logo.svg $(RUSTDOC_OUTPUT)
+ $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(RUSTDOC_OUTPUT)
+ $(Q)find $(RUSTDOC_OUTPUT) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
-e 's:rust-logo\.svg:logo.svg:g' \
-e 's:rust-logo\.png:logo.svg:g' \
-e 's:favicon\.svg:logo.svg:g' \
-e 's:<link rel="alternate icon" type="image/png" href="[./]*favicon-(16x16|32x32)\.png">::g'
$(Q)echo '.logo-container > img { object-fit: contain; }' \
- >> $(objtree)/$(obj)/doc/rustdoc.css
+ >> $(RUSTDOC_OUTPUT)/rustdoc.css

rustdoc-macros: private rustdoc_host = yes
rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
@@ -141,7 +144,7 @@ quiet_cmd_rustdoc_test = RUSTDOC T $<
@$(objtree)/include/generated/rustc_cfg \
$(rustc_target_flags) $(rustdoc_test_target_flags) \
--sysroot $(objtree)/$(obj)/test/sysroot $(rustdoc_test_quiet) \
- -L$(objtree)/$(obj)/test --output $(objtree)/$(obj)/doc \
+ -L$(objtree)/$(obj)/test --output $(RUSTDOC_OUTPUT) \
--crate-name $(subst rusttest-,,$@) $<

# We cannot use `-Zpanic-abort-tests` because some tests are dynamic,

base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
--
2.34.1

2022-12-01 21:14:20

by Bilbao, Carlos

[permalink] [raw]
Subject: Re: [PATCH] docs: Integrate rustdoc into Rust documentation

On 12/1/22 06:42, Miguel Ojeda wrote:

> On Wed, Nov 30, 2022 at 11:08 PM Carlos Bilbao <[email protected]> wrote:
>
>> +ifdef CONFIG_RUST
>> + @make LLVM=1 rustdoc
>> +endif
> The Rust docs should probably be built with the build
> system/config/... as given, whether it is GCC, LLVM, etc. This should
> probably use `$(MAKE)` too; and if you intended to remove the command
> line definitions, `MAKEOVERRIDES` too.


Sounds good.


> By the way, while checking this, I noticed we use some `CONFIG_`s in
> this `Makefile`, but we do not perform a config sync for the `*docs`
> targets, so one needs to do so manually, i.e. it can be a pitfall for
> e.g. `CONFIG_WARN_MISSING_DOCUMENTS` and ` as well as a potential
> `CONFIG_RUST`. Should this be fixed orthogonally, or is it intended?
> (some targets do not need the sync, and the ones that need are
> probably less used, so I guess that could be the reason?).


I don't understand config sync. Perhaps that, e.g. Documentation/Makefile
checks for broken docs, for CONFIG_WARN_MISSING_DOCUMENTS, but we don't
do that for rust/Makefile? I'm not sure, but it does sound orthogonal, yes.


>
>> +Rustdoc output
>> +==============
>> +
>> +If this documentation includes rustdoc-generated HTML, the entry point
>> +can be found `here. <rustdoc/kernel/index.html>`_
> Perhaps this sentence could be moved to the top of the index file, so
> that users do not need two clicks when visiting "Rust"? That way we
> avoid one more file too.


Yes, that will be better :)


>
>> +RUSTDOC_OUTPUT=$(objtree)/Documentation/output/rust/rustdoc
> Please add a space around the equal sign to be consistent with (most)
> of the rest of the file.


Ack


>
> Cheers,
> Miguel


Thanks,
Carlos

2022-12-02 16:43:12

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH] docs: Integrate rustdoc into Rust documentation

On Thu, Dec 1, 2022 at 9:40 PM Carlos Bilbao <[email protected]> wrote:
>
> I don't understand config sync. Perhaps that, e.g. Documentation/Makefile
> checks for broken docs, for CONFIG_WARN_MISSING_DOCUMENTS, but we don't
> do that for rust/Makefile? I'm not sure, but it does sound orthogonal, yes.

Config sync is what needs to happen to make a bunch of files in
`include/` up to date with respect to the `.config`. It runs
automatically for some targets, but not always. For instance, the
`*docs` targets do not trigger it. So if you enable e.g.
`CONFIG_WARN_MISSING_DOCUMENTS`, and immediately afterwards run
`htmldocs`, it will not take it into account.

But don't worry about it: that part of my comment was directed at
others (e.g. Jon, Akira...) that may know the historical context or
the reason behind it -- no need to fix it here. I mentioned it here
since it affects `CONFIG_RUST` if we use it there (in the same way as
the other `CONFIG_*` used there).

Cheers,
Miguel

2022-12-02 16:48:20

by Bilbao, Carlos

[permalink] [raw]
Subject: Re: [PATCH] docs: Integrate rustdoc into Rust documentation

On 12/2/22 10:27, Miguel Ojeda wrote:

> On Thu, Dec 1, 2022 at 9:40 PM Carlos Bilbao <[email protected]> wrote:
>> I don't understand config sync. Perhaps that, e.g. Documentation/Makefile
>> checks for broken docs, for CONFIG_WARN_MISSING_DOCUMENTS, but we don't
>> do that for rust/Makefile? I'm not sure, but it does sound orthogonal, yes.
> Config sync is what needs to happen to make a bunch of files in
> `include/` up to date with respect to the `.config`. It runs
> automatically for some targets, but not always. For instance, the
> `*docs` targets do not trigger it. So if you enable e.g.
> `CONFIG_WARN_MISSING_DOCUMENTS`, and immediately afterwards run
> `htmldocs`, it will not take it into account.
>
> But don't worry about it: that part of my comment was directed at
> others (e.g. Jon, Akira...) that may know the historical context or
> the reason behind it -- no need to fix it here. I mentioned it here
> since it affects `CONFIG_RUST` if we use it there (in the same way as
> the other `CONFIG_*` used there).


Ah, that makes sense. I appreciate the clarification!


>
> Cheers,
> Miguel


Thanks,
Carlos

2022-12-05 01:46:55

by Akira Yokosawa

[permalink] [raw]
Subject: Re: [PATCH v2] docs: Integrate rustdoc into Rust documentation

Hi,

On Thu, 1 Dec 2022 14:48:14 -0600, Carlos Bilbao wrote:
> Include HTML output generated with rustdoc into the Linux kernel
> documentation on Rust. Change target `make htmldocs` to combine RST Sphinx
> and the generation of Rust documentation, when support is available.
>
> Signed-off-by: Carlos Bilbao <[email protected]>
> ---
>
> Changes since V1:
> - Work on top of v6.1-rc1.

Thank you for the rebase.

> - Don't use rustdoc.rst, instead add link to Documentation/rust/index.rst.
> - In Documentation/Makefile, replace @make rustdoc for $(Q)$(MAKE) rustdoc.
> - Don't do LLVM=1 for all rustdoc generation within `make htmldocs`.
> - Add spaces on definition of RUSTDOC_OUTPUT, for consistency.
>
> ---
> Documentation/Makefile | 4 ++++
> Documentation/rust/index.rst | 3 +++
> rust/Makefile | 15 +++++++++------
> 3 files changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index 64d44c1ecad3..f537cf558af6 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -92,6 +92,10 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
> fi
>
> htmldocs:
> +# If Rust support is available, add rustdoc generated contents
> +ifdef CONFIG_RUST
> + $(Q)$(MAKE) rustdoc
> +endif
> @$(srctree)/scripts/sphinx-pre-install --version-check
> @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))

So, this means "make htmldocs" will require kernel .config if CONFIG_RUST=y.
I'm not sure this new requirement is acceptable for kernel documentation
testers who just want to build kernel documentation.

You are doing three things in this patch.

1) Change the destination of rustdoc to under Documentation/output/
2) Add a cross reference to the generated rustdoc in
Documentation/rust/index.rst.
3) Integrate rustdoc generation into htmldocs.

I'm OK with 1) and 2).
Can you separate 3) into another patch and respin?

By the way, is rustdoc's requirement of .config only for CONFIG_RUST?
In other words, are contents of rustdoc affected by other config settings?

If not, I think rustdoc can be generated regardless of config settings as
far as necessary tools (rustc, bindgen, etc.) are available.

>
> diff --git a/Documentation/rust/index.rst b/Documentation/rust/index.rst
> index 4ae8c66b94fa..4005326c3ba9 100644
> --- a/Documentation/rust/index.rst
> +++ b/Documentation/rust/index.rst
> @@ -6,6 +6,9 @@ Rust
> Documentation related to Rust within the kernel. To start using Rust
> in the kernel, please read the quick-start.rst guide.
>
> +If this documentation includes rustdoc-generated HTML, the entry point can
> +be found `here. <rustdoc/kernel/index.html>`_

This cross reference will only make sense in htmldocs build.
Perhaps, you can use the "only::" directive [1] as follows:

.. only:: html

If this documentation includes rustdoc-generated HTML, the entry point can
be found `here. <rustdoc/kernel/index.html>`_

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-only

Thanks, Akira

> +
> .. toctree::
> :maxdepth: 1
>
> diff --git a/rust/Makefile b/rust/Makefile
> index 7700d3853404..080c07048065 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -1,5 +1,8 @@
> # SPDX-License-Identifier: GPL-2.0
>
> +# Where to place rustdoc generated documentation
> +RUSTDOC_OUTPUT = $(objtree)/Documentation/output/rust/rustdoc
> +
> always-$(CONFIG_RUST) += target.json
> no-clean-files += target.json
>
> @@ -58,7 +61,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
> OBJTREE=$(abspath $(objtree)) \
> $(RUSTDOC) $(if $(rustdoc_host),$(rust_common_flags),$(rust_flags)) \
> $(rustc_target_flags) -L$(objtree)/$(obj) \
> - --output $(objtree)/$(obj)/doc \
> + --output $(RUSTDOC_OUTPUT) \
> --crate-name $(subst rustdoc-,,$@) \
> @$(objtree)/include/generated/rustc_cfg $<
>
> @@ -75,15 +78,15 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
> # and then retouch the generated files.
> rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
> rustdoc-alloc rustdoc-kernel
> - $(Q)cp $(srctree)/Documentation/images/logo.svg $(objtree)/$(obj)/doc
> - $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(objtree)/$(obj)/doc
> - $(Q)find $(objtree)/$(obj)/doc -name '*.html' -type f -print0 | xargs -0 sed -Ei \
> + $(Q)cp $(srctree)/Documentation/images/logo.svg $(RUSTDOC_OUTPUT)
> + $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(RUSTDOC_OUTPUT)
> + $(Q)find $(RUSTDOC_OUTPUT) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
> -e 's:rust-logo\.svg:logo.svg:g' \
> -e 's:rust-logo\.png:logo.svg:g' \
> -e 's:favicon\.svg:logo.svg:g' \
> -e 's:<link rel="alternate icon" type="image/png" href="[./]*favicon-(16x16|32x32)\.png">::g'
> $(Q)echo '.logo-container > img { object-fit: contain; }' \
> - >> $(objtree)/$(obj)/doc/rustdoc.css
> + >> $(RUSTDOC_OUTPUT)/rustdoc.css
>
> rustdoc-macros: private rustdoc_host = yes
> rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
> @@ -141,7 +144,7 @@ quiet_cmd_rustdoc_test = RUSTDOC T $<
> @$(objtree)/include/generated/rustc_cfg \
> $(rustc_target_flags) $(rustdoc_test_target_flags) \
> --sysroot $(objtree)/$(obj)/test/sysroot $(rustdoc_test_quiet) \
> - -L$(objtree)/$(obj)/test --output $(objtree)/$(obj)/doc \
> + -L$(objtree)/$(obj)/test --output $(RUSTDOC_OUTPUT) \
> --crate-name $(subst rusttest-,,$@) $<
>
> # We cannot use `-Zpanic-abort-tests` because some tests are dynamic,
>
> base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780

2022-12-05 17:06:46

by Bilbao, Carlos

[permalink] [raw]
Subject: Re: [PATCH v2] docs: Integrate rustdoc into Rust documentation

On 12/4/22 19:06, Akira Yokosawa wrote:

> Hi,
>
> On Thu, 1 Dec 2022 14:48:14 -0600, Carlos Bilbao wrote:
>> Include HTML output generated with rustdoc into the Linux kernel
>> documentation on Rust. Change target `make htmldocs` to combine RST Sphinx
>> and the generation of Rust documentation, when support is available.
>>
>> Signed-off-by: Carlos Bilbao <[email protected]>
>> ---
>>
>> Changes since V1:
>> - Work on top of v6.1-rc1.
> Thank you for the rebase.
>
>> - Don't use rustdoc.rst, instead add link to Documentation/rust/index.rst.
>> - In Documentation/Makefile, replace @make rustdoc for $(Q)$(MAKE) rustdoc.
>> - Don't do LLVM=1 for all rustdoc generation within `make htmldocs`.
>> - Add spaces on definition of RUSTDOC_OUTPUT, for consistency.
>>
>> ---
>> Documentation/Makefile | 4 ++++
>> Documentation/rust/index.rst | 3 +++
>> rust/Makefile | 15 +++++++++------
>> 3 files changed, 16 insertions(+), 6 deletions(-)
>>
>> diff --git a/Documentation/Makefile b/Documentation/Makefile
>> index 64d44c1ecad3..f537cf558af6 100644
>> --- a/Documentation/Makefile
>> +++ b/Documentation/Makefile
>> @@ -92,6 +92,10 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
>> fi
>>
>> htmldocs:
>> +# If Rust support is available, add rustdoc generated contents
>> +ifdef CONFIG_RUST
>> + $(Q)$(MAKE) rustdoc
>> +endif
>> @$(srctree)/scripts/sphinx-pre-install --version-check
>> @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
> So, this means "make htmldocs" will require kernel .config if CONFIG_RUST=y.
> I'm not sure this new requirement is acceptable for kernel documentation
> testers who just want to build kernel documentation.


This is already kind of the case for Rust-related business.


>
> You are doing three things in this patch.
>
> 1) Change the destination of rustdoc to under Documentation/output/
> 2) Add a cross reference to the generated rustdoc in
> Documentation/rust/index.rst.
> 3) Integrate rustdoc generation into htmldocs.
>
> I'm OK with 1) and 2).
> Can you separate 3) into another patch and respin?


Glad we can agree on 1) and 2). Why moving 3)? This is a small patch with
one overall purpose (Integrate rustdoc into website).


>
> By the way, is rustdoc's requirement of .config only for CONFIG_RUST?
> In other words, are contents of rustdoc affected by other config settings?
>
> If not, I think rustdoc can be generated regardless of config settings as
> far as necessary tools (rustc, bindgen, etc.) are available.


Yes, but someone with the tools may not want to use them. Keep in mind that
generating rustdoc takes a few extra seconds.


>
>>
>> diff --git a/Documentation/rust/index.rst b/Documentation/rust/index.rst
>> index 4ae8c66b94fa..4005326c3ba9 100644
>> --- a/Documentation/rust/index.rst
>> +++ b/Documentation/rust/index.rst
>> @@ -6,6 +6,9 @@ Rust
>> Documentation related to Rust within the kernel. To start using Rust
>> in the kernel, please read the quick-start.rst guide.
>>
>> +If this documentation includes rustdoc-generated HTML, the entry point can
>> +be found `here. <rustdoc/kernel/index.html>`_
> This cross reference will only make sense in htmldocs build.
> Perhaps, you can use the "only::" directive [1] as follows:
>
> .. only:: html


This I can gladly do on a V3. I will wait for an answer on issues above.


>
> If this documentation includes rustdoc-generated HTML, the entry point can
> be found `here. <rustdoc/kernel/index.html>`_
>
> [1]: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.sphinx-doc.org%2Fen%2Fmaster%2Fusage%2Frestructuredtext%2Fdirectives.html%23directive-only&amp;data=05%7C01%7Ccarlos.bilbao%40amd.com%7C163763a795284a542e4f08dad65cf4c6%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C638057991984040258%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=DU8nmQp7gCCGNMUR6urtHHCz5nXAtomeV17%2BzB%2F4L38%3D&amp;reserved=0
>
> Thanks, Akira
>
>> +
>> .. toctree::
>> :maxdepth: 1
>>
>> diff --git a/rust/Makefile b/rust/Makefile
>> index 7700d3853404..080c07048065 100644
>> --- a/rust/Makefile
>> +++ b/rust/Makefile
>> @@ -1,5 +1,8 @@
>> # SPDX-License-Identifier: GPL-2.0
>>
>> +# Where to place rustdoc generated documentation
>> +RUSTDOC_OUTPUT = $(objtree)/Documentation/output/rust/rustdoc
>> +
>> always-$(CONFIG_RUST) += target.json
>> no-clean-files += target.json
>>
>> @@ -58,7 +61,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
>> OBJTREE=$(abspath $(objtree)) \
>> $(RUSTDOC) $(if $(rustdoc_host),$(rust_common_flags),$(rust_flags)) \
>> $(rustc_target_flags) -L$(objtree)/$(obj) \
>> - --output $(objtree)/$(obj)/doc \
>> + --output $(RUSTDOC_OUTPUT) \
>> --crate-name $(subst rustdoc-,,$@) \
>> @$(objtree)/include/generated/rustc_cfg $<
>>
>> @@ -75,15 +78,15 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
>> # and then retouch the generated files.
>> rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
>> rustdoc-alloc rustdoc-kernel
>> - $(Q)cp $(srctree)/Documentation/images/logo.svg $(objtree)/$(obj)/doc
>> - $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(objtree)/$(obj)/doc
>> - $(Q)find $(objtree)/$(obj)/doc -name '*.html' -type f -print0 | xargs -0 sed -Ei \
>> + $(Q)cp $(srctree)/Documentation/images/logo.svg $(RUSTDOC_OUTPUT)
>> + $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(RUSTDOC_OUTPUT)
>> + $(Q)find $(RUSTDOC_OUTPUT) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
>> -e 's:rust-logo\.svg:logo.svg:g' \
>> -e 's:rust-logo\.png:logo.svg:g' \
>> -e 's:favicon\.svg:logo.svg:g' \
>> -e 's:<link rel="alternate icon" type="image/png" href="[./]*favicon-(16x16|32x32)\.png">::g'
>> $(Q)echo '.logo-container > img { object-fit: contain; }' \
>> - >> $(objtree)/$(obj)/doc/rustdoc.css
>> + >> $(RUSTDOC_OUTPUT)/rustdoc.css
>>
>> rustdoc-macros: private rustdoc_host = yes
>> rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
>> @@ -141,7 +144,7 @@ quiet_cmd_rustdoc_test = RUSTDOC T $<
>> @$(objtree)/include/generated/rustc_cfg \
>> $(rustc_target_flags) $(rustdoc_test_target_flags) \
>> --sysroot $(objtree)/$(obj)/test/sysroot $(rustdoc_test_quiet) \
>> - -L$(objtree)/$(obj)/test --output $(objtree)/$(obj)/doc \
>> + -L$(objtree)/$(obj)/test --output $(RUSTDOC_OUTPUT) \
>> --crate-name $(subst rusttest-,,$@) $<
>>
>> # We cannot use `-Zpanic-abort-tests` because some tests are dynamic,
>>
>> base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780


Thanks,
Carlos

2022-12-05 17:19:01

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH v2] docs: Integrate rustdoc into Rust documentation

On Mon, Dec 5, 2022 at 2:06 AM Akira Yokosawa <[email protected]> wrote:
>
> So, this means "make htmldocs" will require kernel .config if CONFIG_RUST=y.
> I'm not sure this new requirement is acceptable for kernel documentation
> testers who just want to build kernel documentation.

If the worry is that "full tree testers" (or CIs in general) cannot
fully test the docs anymore without a config, that is definitely a
change, and one of the reasons why I initially didn't add it to
`htmldocs`.

However, full tree testers will need other changes anyway (at least
installing the Rust toolchain), even if there was no need for a
config. So it may be not too bad, and putting it in `htmldocs` means
not having to call another target in the CIs; and for humans, less
chance of forgetting etc.

(It is also why I wondered above about
`CONFIG_WARN_MISSING_DOCUMENTS`: if `Documentation/` intended to
require a config as a whole, then it would be fine. I assume that is
not the case, though, but not doing the sync is nevertheless a bit
confusing)

> By the way, is rustdoc's requirement of .config only for CONFIG_RUST?
> In other words, are contents of rustdoc affected by other config settings?
>
> If not, I think rustdoc can be generated regardless of config settings as
> far as necessary tools (rustc, bindgen, etc.) are available.

Yeah, at the moment the config affects what gets generated. However,
that may change in the future: there has been some movement around the
Rust features needed for this recently, so I want to try that approach
again (it would require some other changes, though).

Cheers,
Miguel

2022-12-06 14:03:11

by Akira Yokosawa

[permalink] [raw]
Subject: Re: [PATCH v2] docs: Integrate rustdoc into Rust documentation

On Mon, 5 Dec 2022 17:08:53 +0100, Miguel Ojeda wrote:
> On Mon, Dec 5, 2022 at 2:06 AM Akira Yokosawa <[email protected]> wrote:
>>
>> So, this means "make htmldocs" will require kernel .config if CONFIG_RUST=y.
>> I'm not sure this new requirement is acceptable for kernel documentation
>> testers who just want to build kernel documentation.
>
> If the worry is that "full tree testers" (or CIs in general) cannot
> fully test the docs anymore without a config, that is definitely a
> change, and one of the reasons why I initially didn't add it to
> `htmldocs`.

Well, I'm actually worrying about additional TAT when I want to test
a particular change in a .rst file and test-build under the relevant
subdirectory using a command, e.g., "make SPHINXDIRS=doc-guide htmldocs".

This completes almost instantly when CONFIG_RUST is not set.

With CONFIG_RUST=y, in my test, it runs RUSTDOC even when rustdoc is
already generated once, as shown below:

------
CALL scripts/checksyscalls.sh
DESCEND objtool
RUSTDOC /home/foo/.rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/lib.rs
RUSTDOC H rust/macros/lib.rs
RUSTDOC rust/compiler_builtins.rs
RUSTDOC rust/alloc/lib.rs
RUSTDOC rust/kernel/lib.rs
SPHINX htmldocs --> file:///linux/Documentation/output/doc-guide
make[2]: Nothing to be done for 'html'.
Using classic theme
source directory: doc-guide
------

It takes 10 seconds or so (under a not-fast PC), 97% or more of which
is wasted for redundant RUSTDOC runs.

Why is RUSTDOC invoked when there is no change in rustdoc?

If those redundant runs can be resolved, I might change my mind and ack
the integration of generating rustdoc and htmldocs.

>
> However, full tree testers will need other changes anyway (at least
> installing the Rust toolchain), even if there was no need for a
> config. So it may be not too bad, and putting it in `htmldocs` means
> not having to call another target in the CIs; and for humans, less
> chance of forgetting etc.

Full tree testers wouldn't mind the redundant runs of RUSTDOC.

I think you can add a new target in the top-devel Makefile which
runs both rustdoc and htmldocs for CIs. Something like 'htmldocsboth'
or 'htmldocsall'???

htmldocs and other *docs targets are the most primitive ones for
running Sphinx, so my gut feeling tells me _not_ to contaminate
htmldocs with rustdoc or vice versa.

>
> (It is also why I wondered above about
> `CONFIG_WARN_MISSING_DOCUMENTS`: if `Documentation/` intended to
> require a config as a whole, then it would be fine. I assume that is
> not the case, though, but not doing the sync is nevertheless a bit
> confusing)

I have no idea. (Note: I was not around when the kernel documentation
transitioned to Sphinx.)

>
>> By the way, is rustdoc's requirement of .config only for CONFIG_RUST?
>> In other words, are contents of rustdoc affected by other config settings?
>>
>> If not, I think rustdoc can be generated regardless of config settings as
>> far as necessary tools (rustc, bindgen, etc.) are available.
>
> Yeah, at the moment the config affects what gets generated. However,
> that may change in the future: there has been some movement around the
> Rust features needed for this recently, so I want to try that approach
> again (it would require some other changes, though).

Interesting.
So rustdoc needs .config. I'm convinced.

Thanks, Akira

>
> Cheers,
> Miguel

2022-12-06 15:07:23

by Akira Yokosawa

[permalink] [raw]
Subject: Re: [PATCH v2] docs: Integrate rustdoc into Rust documentation

On Mon, 5 Dec 2022 10:36:11 -0600, Carlos Bilbao wrote:
> On 12/4/22 19:06, Akira Yokosawa wrote:
>
>> Hi,
>>
>> On Thu, 1 Dec 2022 14:48:14 -0600, Carlos Bilbao wrote:
>>> Include HTML output generated with rustdoc into the Linux kernel
>>> documentation on Rust. Change target `make htmldocs` to combine RST Sphinx
>>> and the generation of Rust documentation, when support is available.
>>>
>>> Signed-off-by: Carlos Bilbao <[email protected]>
>>> ---
>>>
>>> Changes since V1:
>>>   - Work on top of v6.1-rc1.
>> Thank you for the rebase.
>>
>>>   - Don't use rustdoc.rst, instead add link to Documentation/rust/index.rst.
>>>   - In Documentation/Makefile, replace @make rustdoc for $(Q)$(MAKE) rustdoc.
>>>   - Don't do LLVM=1 for all rustdoc generation within `make htmldocs`.
>>>   - Add spaces on definition of RUSTDOC_OUTPUT, for consistency.
>>>
>>> ---
>>>   Documentation/Makefile       |  4 ++++
>>>   Documentation/rust/index.rst |  3 +++
>>>   rust/Makefile                | 15 +++++++++------
>>>   3 files changed, 16 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/Documentation/Makefile b/Documentation/Makefile
>>> index 64d44c1ecad3..f537cf558af6 100644
>>> --- a/Documentation/Makefile
>>> +++ b/Documentation/Makefile
>>> @@ -92,6 +92,10 @@ quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
>>>       fi
>>>     htmldocs:
>>> +# If Rust support is available, add rustdoc generated contents
>>> +ifdef CONFIG_RUST
>>> +    $(Q)$(MAKE) rustdoc
>>> +endif
>>>       @$(srctree)/scripts/sphinx-pre-install --version-check
>>>       @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
>> So, this means "make htmldocs" will require kernel .config if CONFIG_RUST=y.
>> I'm not sure this new requirement is acceptable for kernel documentation
>> testers who just want to build kernel documentation.
>
>
> This is already kind of the case for Rust-related business.
>
>
>>
>> You are doing three things in this patch.
>>
>>   1) Change the destination of rustdoc to under Documentation/output/
>>   2) Add a cross reference to the generated rustdoc in
>>      Documentation/rust/index.rst.
>>   3) Integrate rustdoc generation into htmldocs.
>>
>> I'm OK with 1) and 2).
>> Can you separate 3) into another patch and respin?
>
>
> Glad we can agree on 1) and 2). Why moving 3)? This is a small patch with
> one overall purpose (Integrate rustdoc into website).

Yes, I agree that 3) is a small change. I understand what you want to
do. But there are a couple of options for _how_ to do it.
My current position is that Documentation/Makefile is _not_ the right
place for the change, as mentioned in my reply to Miguel.

>
>
>>
>> By the way, is rustdoc's requirement of .config only for CONFIG_RUST?
>> In other words, are contents of rustdoc affected by other config settings?
>>
>> If not, I think rustdoc can be generated regardless of config settings as
>> far as necessary tools (rustc, bindgen, etc.) are available.
>
>
> Yes, but someone with the tools may not want to use them. Keep in mind that
> generating rustdoc takes a few extra seconds.

As mentioned in another reply, I'm convinced of the dependency on .config.

>
>
>>
>>>   diff --git a/Documentation/rust/index.rst b/Documentation/rust/index.rst
>>> index 4ae8c66b94fa..4005326c3ba9 100644
>>> --- a/Documentation/rust/index.rst
>>> +++ b/Documentation/rust/index.rst
>>> @@ -6,6 +6,9 @@ Rust
>>>   Documentation related to Rust within the kernel. To start using Rust
>>>   in the kernel, please read the quick-start.rst guide.
>>>   +If this documentation includes rustdoc-generated HTML, the entry point can
>>> +be found `here. <rustdoc/kernel/index.html>`_
>> This cross reference will only make sense in htmldocs build.
>> Perhaps, you can use the "only::" directive [1] as follows:
>>
>> .. only:: html
>
>
> This I can gladly do on a V3. I will wait for an answer on issues above.

OK.

So if you split this into a two-patch series, 1/2 for 1) and 2), and 2/2
for 3) (or an updated one), I'm glad to give my RB tag to 1/2 for Miguel
to be able take it for v6.2 (timing is tight!). 2/2 will need at least
a couple of respins, I guess.

Thanks, Akira
>
>
>>
>>      If this documentation includes rustdoc-generated HTML, the entry point can
>>      be found `here. <rustdoc/kernel/index.html>`_
>>
>> [1]: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.sphinx-doc.org%2Fen%2Fmaster%2Fusage%2Frestructuredtext%2Fdirectives.html%23directive-only&amp;data=05%7C01%7Ccarlos.bilbao%40amd.com%7C163763a795284a542e4f08dad65cf4c6%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C638057991984040258%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=DU8nmQp7gCCGNMUR6urtHHCz5nXAtomeV17%2BzB%2F4L38%3D&amp;reserved=0
>>
>>          Thanks, Akira
>>
>>> +
>>>   .. toctree::
>>>       :maxdepth: 1
>>>   diff --git a/rust/Makefile b/rust/Makefile
>>> index 7700d3853404..080c07048065 100644
>>> --- a/rust/Makefile
>>> +++ b/rust/Makefile
>>> @@ -1,5 +1,8 @@
>>>   # SPDX-License-Identifier: GPL-2.0
>>>   +# Where to place rustdoc generated documentation
>>> +RUSTDOC_OUTPUT = $(objtree)/Documentation/output/rust/rustdoc
>>> +
>>>   always-$(CONFIG_RUST) += target.json
>>>   no-clean-files += target.json
>>>   @@ -58,7 +61,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
>>>       OBJTREE=$(abspath $(objtree)) \
>>>       $(RUSTDOC) $(if $(rustdoc_host),$(rust_common_flags),$(rust_flags)) \
>>>           $(rustc_target_flags) -L$(objtree)/$(obj) \
>>> -        --output $(objtree)/$(obj)/doc \
>>> +        --output $(RUSTDOC_OUTPUT) \
>>>           --crate-name $(subst rustdoc-,,$@) \
>>>           @$(objtree)/include/generated/rustc_cfg $<
>>>   @@ -75,15 +78,15 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
>>>   # and then retouch the generated files.
>>>   rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
>>>       rustdoc-alloc rustdoc-kernel
>>> -    $(Q)cp $(srctree)/Documentation/images/logo.svg $(objtree)/$(obj)/doc
>>> -    $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(objtree)/$(obj)/doc
>>> -    $(Q)find $(objtree)/$(obj)/doc -name '*.html' -type f -print0 | xargs -0 sed -Ei \
>>> +    $(Q)cp $(srctree)/Documentation/images/logo.svg $(RUSTDOC_OUTPUT)
>>> +    $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(RUSTDOC_OUTPUT)
>>> +    $(Q)find $(RUSTDOC_OUTPUT) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
>>>           -e 's:rust-logo\.svg:logo.svg:g' \
>>>           -e 's:rust-logo\.png:logo.svg:g' \
>>>           -e 's:favicon\.svg:logo.svg:g' \
>>>           -e 's:<link rel="alternate icon" type="image/png" href="[./]*favicon-(16x16|32x32)\.png">::g'
>>>       $(Q)echo '.logo-container > img { object-fit: contain; }' \
>>> -        >> $(objtree)/$(obj)/doc/rustdoc.css
>>> +        >> $(RUSTDOC_OUTPUT)/rustdoc.css
>>>     rustdoc-macros: private rustdoc_host = yes
>>>   rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
>>> @@ -141,7 +144,7 @@ quiet_cmd_rustdoc_test = RUSTDOC T $<
>>>           @$(objtree)/include/generated/rustc_cfg \
>>>           $(rustc_target_flags) $(rustdoc_test_target_flags) \
>>>           --sysroot $(objtree)/$(obj)/test/sysroot $(rustdoc_test_quiet) \
>>> -        -L$(objtree)/$(obj)/test --output $(objtree)/$(obj)/doc \
>>> +        -L$(objtree)/$(obj)/test --output $(RUSTDOC_OUTPUT) \
>>>           --crate-name $(subst rusttest-,,$@) $<
>>>     # We cannot use `-Zpanic-abort-tests` because some tests are dynamic,
>>>
>>> base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
>
>
> Thanks,
> Carlos

2022-12-06 15:10:54

by Jonathan Corbet

[permalink] [raw]
Subject: Re: [PATCH v2] docs: Integrate rustdoc into Rust documentation

Akira Yokosawa <[email protected]> writes:

> Well, I'm actually worrying about additional TAT when I want to test
> a particular change in a .rst file and test-build under the relevant
> subdirectory using a command, e.g., "make SPHINXDIRS=doc-guide htmldocs".
>
> This completes almost instantly when CONFIG_RUST is not set.
>
> With CONFIG_RUST=y, in my test, it runs RUSTDOC even when rustdoc is
> already generated once, as shown below:

This is something that would be nice to avoid if we can; narrowing
things with SPHINXDIRS should avoid building anything that the user
isn't asking for. I'm not sure how much makefile pain would be required
to make that happen...Documentation/Makefile is not the easiest place to
make changes, alas.

> I think you can add a new target in the top-devel Makefile which
> runs both rustdoc and htmldocs for CIs. Something like 'htmldocsboth'
> or 'htmldocsall'???
>
> htmldocs and other *docs targets are the most primitive ones for
> running Sphinx, so my gut feeling tells me _not_ to contaminate
> htmldocs with rustdoc or vice versa.

Well, I *would* like for a bare "make htmldocs" to make *all* of the
docs; I don't think Rust should be special in that regard.

>> (It is also why I wondered above about
>> `CONFIG_WARN_MISSING_DOCUMENTS`: if `Documentation/` intended to
>> require a config as a whole, then it would be fine. I assume that is
>> not the case, though, but not doing the sync is nevertheless a bit
>> confusing)
>
> I have no idea. (Note: I was not around when the kernel documentation
> transitioned to Sphinx.)

I think we're just seeing the implementation as was rammed in by
somebody in a hurry; I don't doubt it could be improved.

Thanks,

jon (currently traveling and scrambling to get ready for the merge window)

2022-12-06 15:20:59

by Bilbao, Carlos

[permalink] [raw]
Subject: Re: [PATCH v2] docs: Integrate rustdoc into Rust documentation

On 12/6/22 08:22, Akira Yokosawa wrote:

> On Mon, 5 Dec 2022 10:36:11 -0600, Carlos Bilbao wrote:
>> On 12/4/22 19:06, Akira Yokosawa wrote:
>>
>>> Hi,
>>>
>>> On Thu, 1 Dec 2022 14:48:14 -0600, Carlos Bilbao wrote:
>>>> Include HTML output generated with rustdoc into the Linux kernel
>>>> documentation on Rust. Change target `make htmldocs` to combine RST Sphinx
>>>> and the generation of Rust documentation, when support is available.
>>>>
>>>> Signed-off-by: Carlos Bilbao <[email protected]>
>>>> ---
>>>>
>>>> Changes since V1:
>>>>   - Work on top of v6.1-rc1.
>>> Thank you for the rebase.
>>>
>>>>   - Don't use rustdoc.rst, instead add link to Documentation/rust/index.rst.
>>>>   - In Documentation/Makefile, replace @make rustdoc for $(Q)$(MAKE) rustdoc.
>>>>   - Don't do LLVM=1 for all rustdoc generation within `make htmldocs`.
>>>>   - Add spaces on definition of RUSTDOC_OUTPUT, for consistency.
>>>>
>>>> ---
>>>>   Documentation/Makefile       |  4 ++++
>>>>   Documentation/rust/index.rst |  3 +++
>>>>   rust/Makefile                | 15 +++++++++------
>>>>   3 files changed, 16 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/Documentation/Makefile b/Documentation/Makefile
>>>> index 64d44c1ecad3..f537cf558af6 100644
>>>> --- a/Documentation/Makefile
>>>> +++ b/Documentation/Makefile
>>>> @@ -92,6 +92,10 @@ quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
>>>>       fi
>>>>     htmldocs:
>>>> +# If Rust support is available, add rustdoc generated contents
>>>> +ifdef CONFIG_RUST
>>>> +    $(Q)$(MAKE) rustdoc
>>>> +endif
>>>>       @$(srctree)/scripts/sphinx-pre-install --version-check
>>>>       @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
>>> So, this means "make htmldocs" will require kernel .config if CONFIG_RUST=y.
>>> I'm not sure this new requirement is acceptable for kernel documentation
>>> testers who just want to build kernel documentation.
>>
>> This is already kind of the case for Rust-related business.
>>
>>
>>> You are doing three things in this patch.
>>>
>>>   1) Change the destination of rustdoc to under Documentation/output/
>>>   2) Add a cross reference to the generated rustdoc in
>>>      Documentation/rust/index.rst.
>>>   3) Integrate rustdoc generation into htmldocs.
>>>
>>> I'm OK with 1) and 2).
>>> Can you separate 3) into another patch and respin?
>>
>> Glad we can agree on 1) and 2). Why moving 3)? This is a small patch with
>> one overall purpose (Integrate rustdoc into website).
> Yes, I agree that 3) is a small change. I understand what you want to
> do. But there are a couple of options for _how_ to do it.
> My current position is that Documentation/Makefile is _not_ the right
> place for the change, as mentioned in my reply to Miguel.
>
>>
>>> By the way, is rustdoc's requirement of .config only for CONFIG_RUST?
>>> In other words, are contents of rustdoc affected by other config settings?
>>>
>>> If not, I think rustdoc can be generated regardless of config settings as
>>> far as necessary tools (rustc, bindgen, etc.) are available.
>>
>> Yes, but someone with the tools may not want to use them. Keep in mind that
>> generating rustdoc takes a few extra seconds.
> As mentioned in another reply, I'm convinced of the dependency on .config.
>
>>
>>>>   diff --git a/Documentation/rust/index.rst b/Documentation/rust/index.rst
>>>> index 4ae8c66b94fa..4005326c3ba9 100644
>>>> --- a/Documentation/rust/index.rst
>>>> +++ b/Documentation/rust/index.rst
>>>> @@ -6,6 +6,9 @@ Rust
>>>>   Documentation related to Rust within the kernel. To start using Rust
>>>>   in the kernel, please read the quick-start.rst guide.
>>>>   +If this documentation includes rustdoc-generated HTML, the entry point can
>>>> +be found `here. <rustdoc/kernel/index.html>`_
>>> This cross reference will only make sense in htmldocs build.
>>> Perhaps, you can use the "only::" directive [1] as follows:
>>>
>>> .. only:: html
>>
>> This I can gladly do on a V3. I will wait for an answer on issues above.
> OK.
>
> So if you split this into a two-patch series, 1/2 for 1) and 2), and 2/2
> for 3) (or an updated one), I'm glad to give my RB tag to 1/2 for Miguel
> to be able take it for v6.2 (timing is tight!). 2/2 will need at least
> a couple of respins, I guess.


Sounds good, I will divide for v3.


>
> Thanks, Akira
>>
>>>      If this documentation includes rustdoc-generated HTML, the entry point can
>>>      be found `here. <rustdoc/kernel/index.html>`_
>>>
>>> [1]: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.sphinx-doc.org%2Fen%2Fmaster%2Fusage%2Frestructuredtext%2Fdirectives.html%23directive-only&amp;data=05%7C01%7Ccarlos.bilbao%40amd.com%7Cbed091b8fae74b3d314408dad7954fc2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C638059333550278394%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=xGbmhYsge%2BoPo%2BRrsc6fCW8htY3yh0dHk4E8gQBQV9o%3D&amp;reserved=0
>>>
>>>          Thanks, Akira
>>>
>>>> +
>>>>   .. toctree::
>>>>       :maxdepth: 1
>>>>   diff --git a/rust/Makefile b/rust/Makefile
>>>> index 7700d3853404..080c07048065 100644
>>>> --- a/rust/Makefile
>>>> +++ b/rust/Makefile
>>>> @@ -1,5 +1,8 @@
>>>>   # SPDX-License-Identifier: GPL-2.0
>>>>   +# Where to place rustdoc generated documentation
>>>> +RUSTDOC_OUTPUT = $(objtree)/Documentation/output/rust/rustdoc
>>>> +
>>>>   always-$(CONFIG_RUST) += target.json
>>>>   no-clean-files += target.json
>>>>   @@ -58,7 +61,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
>>>>       OBJTREE=$(abspath $(objtree)) \
>>>>       $(RUSTDOC) $(if $(rustdoc_host),$(rust_common_flags),$(rust_flags)) \
>>>>           $(rustc_target_flags) -L$(objtree)/$(obj) \
>>>> -        --output $(objtree)/$(obj)/doc \
>>>> +        --output $(RUSTDOC_OUTPUT) \
>>>>           --crate-name $(subst rustdoc-,,$@) \
>>>>           @$(objtree)/include/generated/rustc_cfg $<
>>>>   @@ -75,15 +78,15 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
>>>>   # and then retouch the generated files.
>>>>   rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
>>>>       rustdoc-alloc rustdoc-kernel
>>>> -    $(Q)cp $(srctree)/Documentation/images/logo.svg $(objtree)/$(obj)/doc
>>>> -    $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(objtree)/$(obj)/doc
>>>> -    $(Q)find $(objtree)/$(obj)/doc -name '*.html' -type f -print0 | xargs -0 sed -Ei \
>>>> +    $(Q)cp $(srctree)/Documentation/images/logo.svg $(RUSTDOC_OUTPUT)
>>>> +    $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(RUSTDOC_OUTPUT)
>>>> +    $(Q)find $(RUSTDOC_OUTPUT) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
>>>>           -e 's:rust-logo\.svg:logo.svg:g' \
>>>>           -e 's:rust-logo\.png:logo.svg:g' \
>>>>           -e 's:favicon\.svg:logo.svg:g' \
>>>>           -e 's:<link rel="alternate icon" type="image/png" href="[./]*favicon-(16x16|32x32)\.png">::g'
>>>>       $(Q)echo '.logo-container > img { object-fit: contain; }' \
>>>> -        >> $(objtree)/$(obj)/doc/rustdoc.css
>>>> +        >> $(RUSTDOC_OUTPUT)/rustdoc.css
>>>>     rustdoc-macros: private rustdoc_host = yes
>>>>   rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
>>>> @@ -141,7 +144,7 @@ quiet_cmd_rustdoc_test = RUSTDOC T $<
>>>>           @$(objtree)/include/generated/rustc_cfg \
>>>>           $(rustc_target_flags) $(rustdoc_test_target_flags) \
>>>>           --sysroot $(objtree)/$(obj)/test/sysroot $(rustdoc_test_quiet) \
>>>> -        -L$(objtree)/$(obj)/test --output $(objtree)/$(obj)/doc \
>>>> +        -L$(objtree)/$(obj)/test --output $(RUSTDOC_OUTPUT) \
>>>>           --crate-name $(subst rusttest-,,$@) $<
>>>>     # We cannot use `-Zpanic-abort-tests` because some tests are dynamic,
>>>>
>>>> base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
>>
>> Thanks,
>> Carlos



2022-12-06 15:46:15

by Bilbao, Carlos

[permalink] [raw]
Subject: Re: [PATCH v2] docs: Integrate rustdoc into Rust documentation

On 12/6/22 08:22, Akira Yokosawa wrote:

> On Mon, 5 Dec 2022 10:36:11 -0600, Carlos Bilbao wrote:
>> On 12/4/22 19:06, Akira Yokosawa wrote:
>>
>>> Hi,
>>>
>>> On Thu, 1 Dec 2022 14:48:14 -0600, Carlos Bilbao wrote:
>>>> Include HTML output generated with rustdoc into the Linux kernel
>>>> documentation on Rust. Change target `make htmldocs` to combine RST Sphinx
>>>> and the generation of Rust documentation, when support is available.
>>>>
>>>> Signed-off-by: Carlos Bilbao <[email protected]>
>>>> ---
>>>>
>>>> Changes since V1:
>>>>   - Work on top of v6.1-rc1.
>>> Thank you for the rebase.
>>>
>>>>   - Don't use rustdoc.rst, instead add link to Documentation/rust/index.rst.
>>>>   - In Documentation/Makefile, replace @make rustdoc for $(Q)$(MAKE) rustdoc.
>>>>   - Don't do LLVM=1 for all rustdoc generation within `make htmldocs`.
>>>>   - Add spaces on definition of RUSTDOC_OUTPUT, for consistency.
>>>>
>>>> ---
>>>>   Documentation/Makefile       |  4 ++++
>>>>   Documentation/rust/index.rst |  3 +++
>>>>   rust/Makefile                | 15 +++++++++------
>>>>   3 files changed, 16 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/Documentation/Makefile b/Documentation/Makefile
>>>> index 64d44c1ecad3..f537cf558af6 100644
>>>> --- a/Documentation/Makefile
>>>> +++ b/Documentation/Makefile
>>>> @@ -92,6 +92,10 @@ quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
>>>>       fi
>>>>     htmldocs:
>>>> +# If Rust support is available, add rustdoc generated contents
>>>> +ifdef CONFIG_RUST
>>>> +    $(Q)$(MAKE) rustdoc
>>>> +endif
>>>>       @$(srctree)/scripts/sphinx-pre-install --version-check
>>>>       @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
>>> So, this means "make htmldocs" will require kernel .config if CONFIG_RUST=y.
>>> I'm not sure this new requirement is acceptable for kernel documentation
>>> testers who just want to build kernel documentation.
>>
>> This is already kind of the case for Rust-related business.
>>
>>
>>> You are doing three things in this patch.
>>>
>>>   1) Change the destination of rustdoc to under Documentation/output/
>>>   2) Add a cross reference to the generated rustdoc in
>>>      Documentation/rust/index.rst.
>>>   3) Integrate rustdoc generation into htmldocs.
>>>
>>> I'm OK with 1) and 2).
>>> Can you separate 3) into another patch and respin?
>>
>> Glad we can agree on 1) and 2). Why moving 3)? This is a small patch with
>> one overall purpose (Integrate rustdoc into website).
> Yes, I agree that 3) is a small change. I understand what you want to
> do. But there are a couple of options for _how_ to do it.
> My current position is that Documentation/Makefile is _not_ the right
> place for the change, as mentioned in my reply to Miguel.


Actually, I originally used `make rustdocs` [1] but good arguments were
given to use `make htmldocs` instead, and I was convinced too.


>
>>
>>> By the way, is rustdoc's requirement of .config only for CONFIG_RUST?
>>> In other words, are contents of rustdoc affected by other config settings?
>>>
>>> If not, I think rustdoc can be generated regardless of config settings as
>>> far as necessary tools (rustc, bindgen, etc.) are available.
>>
>> Yes, but someone with the tools may not want to use them. Keep in mind that
>> generating rustdoc takes a few extra seconds.
> As mentioned in another reply, I'm convinced of the dependency on .config.
>
>>
>>>>   diff --git a/Documentation/rust/index.rst b/Documentation/rust/index.rst
>>>> index 4ae8c66b94fa..4005326c3ba9 100644
>>>> --- a/Documentation/rust/index.rst
>>>> +++ b/Documentation/rust/index.rst
>>>> @@ -6,6 +6,9 @@ Rust
>>>>   Documentation related to Rust within the kernel. To start using Rust
>>>>   in the kernel, please read the quick-start.rst guide.
>>>>   +If this documentation includes rustdoc-generated HTML, the entry point can
>>>> +be found `here. <rustdoc/kernel/index.html>`_
>>> This cross reference will only make sense in htmldocs build.
>>> Perhaps, you can use the "only::" directive [1] as follows:
>>>
>>> .. only:: html
>>
>> This I can gladly do on a V3. I will wait for an answer on issues above.
> OK.
>
> So if you split this into a two-patch series, 1/2 for 1) and 2), and 2/2
> for 3) (or an updated one), I'm glad to give my RB tag to 1/2 for Miguel
> to be able take it for v6.2 (timing is tight!). 2/2 will need at least
> a couple of respins, I guess.


Sounds good, I will divide for v3.


>
> Thanks, Akira
>>
>>>      If this documentation includes rustdoc-generated HTML, the entry point can
>>>      be found `here. <rustdoc/kernel/index.html>`_
>>>
>>> [1]: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.sphinx-doc.org%2Fen%2Fmaster%2Fusage%2Frestructuredtext%2Fdirectives.html%23directive-only&amp;data=05%7C01%7Ccarlos.bilbao%40amd.com%7Cbed091b8fae74b3d314408dad7954fc2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C638059333550278394%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=xGbmhYsge%2BoPo%2BRrsc6fCW8htY3yh0dHk4E8gQBQV9o%3D&amp;reserved=0
>>>
>>>          Thanks, Akira
>>>
>>>> +
>>>>   .. toctree::
>>>>       :maxdepth: 1
>>>>   diff --git a/rust/Makefile b/rust/Makefile
>>>> index 7700d3853404..080c07048065 100644
>>>> --- a/rust/Makefile
>>>> +++ b/rust/Makefile
>>>> @@ -1,5 +1,8 @@
>>>>   # SPDX-License-Identifier: GPL-2.0
>>>>   +# Where to place rustdoc generated documentation
>>>> +RUSTDOC_OUTPUT = $(objtree)/Documentation/output/rust/rustdoc
>>>> +
>>>>   always-$(CONFIG_RUST) += target.json
>>>>   no-clean-files += target.json
>>>>   @@ -58,7 +61,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
>>>>       OBJTREE=$(abspath $(objtree)) \
>>>>       $(RUSTDOC) $(if $(rustdoc_host),$(rust_common_flags),$(rust_flags)) \
>>>>           $(rustc_target_flags) -L$(objtree)/$(obj) \
>>>> -        --output $(objtree)/$(obj)/doc \
>>>> +        --output $(RUSTDOC_OUTPUT) \
>>>>           --crate-name $(subst rustdoc-,,$@) \
>>>>           @$(objtree)/include/generated/rustc_cfg $<
>>>>   @@ -75,15 +78,15 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
>>>>   # and then retouch the generated files.
>>>>   rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
>>>>       rustdoc-alloc rustdoc-kernel
>>>> -    $(Q)cp $(srctree)/Documentation/images/logo.svg $(objtree)/$(obj)/doc
>>>> -    $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(objtree)/$(obj)/doc
>>>> -    $(Q)find $(objtree)/$(obj)/doc -name '*.html' -type f -print0 | xargs -0 sed -Ei \
>>>> +    $(Q)cp $(srctree)/Documentation/images/logo.svg $(RUSTDOC_OUTPUT)
>>>> +    $(Q)cp $(srctree)/Documentation/images/COPYING-logo $(RUSTDOC_OUTPUT)
>>>> +    $(Q)find $(RUSTDOC_OUTPUT) -name '*.html' -type f -print0 | xargs -0 sed -Ei \
>>>>           -e 's:rust-logo\.svg:logo.svg:g' \
>>>>           -e 's:rust-logo\.png:logo.svg:g' \
>>>>           -e 's:favicon\.svg:logo.svg:g' \
>>>>           -e 's:<link rel="alternate icon" type="image/png" href="[./]*favicon-(16x16|32x32)\.png">::g'
>>>>       $(Q)echo '.logo-container > img { object-fit: contain; }' \
>>>> -        >> $(objtree)/$(obj)/doc/rustdoc.css
>>>> +        >> $(RUSTDOC_OUTPUT)/rustdoc.css
>>>>     rustdoc-macros: private rustdoc_host = yes
>>>>   rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
>>>> @@ -141,7 +144,7 @@ quiet_cmd_rustdoc_test = RUSTDOC T $<
>>>>           @$(objtree)/include/generated/rustc_cfg \
>>>>           $(rustc_target_flags) $(rustdoc_test_target_flags) \
>>>>           --sysroot $(objtree)/$(obj)/test/sysroot $(rustdoc_test_quiet) \
>>>> -        -L$(objtree)/$(obj)/test --output $(objtree)/$(obj)/doc \
>>>> +        -L$(objtree)/$(obj)/test --output $(RUSTDOC_OUTPUT) \
>>>>           --crate-name $(subst rusttest-,,$@) $<
>>>>     # We cannot use `-Zpanic-abort-tests` because some tests are dynamic,
>>>>
>>>> base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
>>
>> Thanks,
>> Carlos

[1]
https://lore.kernel.org/lkml/[email protected]/T/


Thanks,
Carlos

2022-12-06 16:01:52

by Bilbao, Carlos

[permalink] [raw]
Subject: [PATCH v3 0/2] docs: Integrate rustdoc into Rust documentation

Include HTML output generated with rustdoc into the Linux kernel
documentation on Rust.

Carlos Bilbao:
docs: Move rustdoc output, cross-reference it
docs: Integrate rustdoc generation into htmldocs

---

Changes since V2:
- Split v2 into two-patch series.
- Add "only:: html" directive in Documentation/rust/index.rst reference

Changes since V1:
- Work on top of v6.1-rc1.
- Don't use rustdoc.rst, instead add link to Documentation/rust/index.rst.
- In Documentation/Makefile, replace @make rustdoc for $(Q)$(MAKE) rustdoc.
- Don't do LLVM=1 for all rustdoc generation within `make htmldocs`.
- Add spaces on definition of RUSTDOC_OUTPUT, for consistency.

---
Documentation/Makefile | 4 ++++
Documentation/rust/index.rst | 5 +++++
rust/Makefile | 15 +++++++++------
3 files changed, 18 insertions(+), 6 deletions(-)

2022-12-06 16:01:55

by Bilbao, Carlos

[permalink] [raw]
Subject: [PATCH v3 2/2] docs: Integrate rustdoc generation into htmldocs

Change target `make htmldocs` to combine RST Sphinx and the
generation of Rust documentation, when support is available.

Signed-off-by: Carlos Bilbao <[email protected]>
---
Documentation/Makefile | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 64d44c1ecad3..f537cf558af6 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -92,6 +92,10 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
fi

htmldocs:
+# If Rust support is available, add rustdoc generated contents
+ifdef CONFIG_RUST
+ $(Q)$(MAKE) rustdoc
+endif
@$(srctree)/scripts/sphinx-pre-install --version-check
@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))

--
2.34.1

2022-12-06 16:02:54

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH v2] docs: Integrate rustdoc into Rust documentation

On Tue, Dec 6, 2022 at 2:32 PM Akira Yokosawa <[email protected]> wrote:
>
> Why is RUSTDOC invoked when there is no change in rustdoc?

I think we can give proper dependencies to `rustdoc`, so if that is
the main concern, then it should be OK.

But note that `htmldocs` also calls Sphinx every run. It does a subset
of the work, but perhaps we can save some time there if we could
detect whether anything changed.

> I think you can add a new target in the top-devel Makefile which
> runs both rustdoc and htmldocs for CIs. Something like 'htmldocsboth'
> or 'htmldocsall'???
>
> htmldocs and other *docs targets are the most primitive ones for
> running Sphinx, so my gut feeling tells me _not_ to contaminate
> htmldocs with rustdoc or vice versa.

That is reasonable, but others wanted it in `htmldocs` (and the goal
is to eventually do so, so if we can do it already, even better).

Cheers,
Miguel

2022-12-07 00:00:49

by Akira Yokosawa

[permalink] [raw]
Subject: Re: [PATCH v3 2/2] docs: Integrate rustdoc generation into htmldocs

On Tue, 6 Dec 2022 09:31:51 -0600, Carlos Bilbao wrote:
> Change target `make htmldocs` to combine RST Sphinx and the
> generation of Rust documentation, when support is available.
>
> Signed-off-by: Carlos Bilbao <[email protected]>
> ---
> Documentation/Makefile | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index 64d44c1ecad3..f537cf558af6 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -92,6 +92,10 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
> fi
>
> htmldocs:
> +# If Rust support is available, add rustdoc generated contents
> +ifdef CONFIG_RUST
> + $(Q)$(MAKE) rustdoc
> +endif
> @$(srctree)/scripts/sphinx-pre-install --version-check
> @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
>

What about patch below on top of this?
This way, it is possible to skip rustdoc generation by saying:

make CONFIG_RUST=n SPHINXDIRS=doc-guide htmldocs

The reordering is to complete Sphinx runs even if rustdoc generation
ends up in error.

With this applied on top,

Reviewed-by: Akira Yokosawa <[email protected]>

Thanks, Akira

------
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 2cf3e0fd7839..4d334468aaaf 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -92,12 +92,12 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
fi

htmldocs:
+ @$(srctree)/scripts/sphinx-pre-install --version-check
+ @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
# If Rust support is available, add rustdoc generated contents
-ifdef CONFIG_RUST
+ifeq ($(CONFIG_RUST),y)
$(Q)$(MAKE) rustdoc
endif
- @$(srctree)/scripts/sphinx-pre-install --version-check
- @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))

texinfodocs:
@$(srctree)/scripts/sphinx-pre-install --version-check
--

2022-12-07 00:16:10

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH v3 2/2] docs: Integrate rustdoc generation into htmldocs



On 12/6/22 15:11, Akira Yokosawa wrote:
> On Tue, 6 Dec 2022 09:31:51 -0600, Carlos Bilbao wrote:
>> Change target `make htmldocs` to combine RST Sphinx and the
>> generation of Rust documentation, when support is available.
>>
>> Signed-off-by: Carlos Bilbao <[email protected]>
>> ---
>> Documentation/Makefile | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/Documentation/Makefile b/Documentation/Makefile
>> index 64d44c1ecad3..f537cf558af6 100644
>> --- a/Documentation/Makefile
>> +++ b/Documentation/Makefile
>> @@ -92,6 +92,10 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
>> fi
>>
>> htmldocs:
>> +# If Rust support is available, add rustdoc generated contents
>> +ifdef CONFIG_RUST
>> + $(Q)$(MAKE) rustdoc
>> +endif
>> @$(srctree)/scripts/sphinx-pre-install --version-check
>> @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
>>
>
> What about patch below on top of this?
> This way, it is possible to skip rustdoc generation by saying:
>
> make CONFIG_RUST=n SPHINXDIRS=doc-guide htmldocs
>
> The reordering is to complete Sphinx runs even if rustdoc generation
> ends up in error.
>
> With this applied on top,
>
> Reviewed-by: Akira Yokosawa <[email protected]>
>
> Thanks, Akira
>

Oh yes, I like both of those changes.
Thanks.

> ------
> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index 2cf3e0fd7839..4d334468aaaf 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -92,12 +92,12 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
> fi
>
> htmldocs:
> + @$(srctree)/scripts/sphinx-pre-install --version-check
> + @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
> # If Rust support is available, add rustdoc generated contents
> -ifdef CONFIG_RUST
> +ifeq ($(CONFIG_RUST),y)
> $(Q)$(MAKE) rustdoc
> endif
> - @$(srctree)/scripts/sphinx-pre-install --version-check
> - @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
>
> texinfodocs:
> @$(srctree)/scripts/sphinx-pre-install --version-check

--
~Randy