Skip to content

Commit 92c2f34

Browse files
authored
Merge pull request #420 from ojeda/rustdoc
Using Rust for Linux logo in generated docs and more
2 parents ff004ed + f97e06f commit 92c2f34

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed
798 Bytes
Loading
2.03 KB
Loading
52.7 KB
Loading

Documentation/rust/docs.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ code, etc.
2626

2727
Like for the rest of the kernel documentation, pregenerated HTML docs for
2828
the libraries (crates) inside ``rust/`` that are used by the rest of the kernel
29-
are available at `kernel.org`_.
30-
31-
// TODO: link when ready
29+
are available at `kernel.org`_ (TODO: link when in mainline and generated
30+
alongside the rest of the documentation).
3231

3332
.. _kernel.org: http://kernel.org/
3433

@@ -88,7 +87,9 @@ This example showcases a few ``rustdoc`` features and some common conventions
8887
safe under a ``Safety`` section.
8988

9089
* While not shown here, if a function may panic, the conditions under which
91-
that happens must be described under a ``Panics`` section.
90+
that happens must be described under a ``Panics`` section. Please note that
91+
panicking should be very rare and used only with a good reason. In almost
92+
all cases, you should use a fallible approach, returning a `Result`.
9293

9394
* If providing examples of usage would help readers, they must be written in
9495
a section called ``Examples``.

rust/Makefile

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,42 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
3737
--output $(objtree)/rust/doc --crate-name $(subst rustdoc-,,$@) \
3838
@$(objtree)/include/generated/rustc_cfg $<
3939

40-
rustdoc: rustdoc-macros rustdoc-compiler_builtins rustdoc-alloc rustdoc-kernel
40+
# This is a temporary fix for the CSS, visible on `type`s (`Result`).
41+
# It is already fixed in nightly.
42+
RUSTDOC_FIX_BEFORE := .impl,.method,.type:not(.container-rustdoc),.associatedconstant,.associatedtype
43+
RUSTDOC_FIX_AFTER := .impl,.impl-items .method,.methods .method,.impl-items \
44+
.type,.methods .type,.impl-items .associatedconstant,.methods \
45+
.associatedconstant,.impl-items .associatedtype,.methods .associatedtype
46+
47+
rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins rustdoc-alloc rustdoc-kernel
48+
$(Q)cp $(srctree)/Documentation/rust/assets/* $(objtree)/rust/doc
49+
$(Q)sed -i "s/$(RUSTDOC_FIX_BEFORE)/$(RUSTDOC_FIX_AFTER)/" \
50+
$(objtree)/rust/doc/rustdoc.css
4151

4252
rustdoc-macros: private rustdoc_host = yes
4353
rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
4454
--extern proc_macro
4555
rustdoc-macros: $(srctree)/rust/macros/lib.rs FORCE
4656
$(call if_changed,rustdoc)
4757

48-
rustdoc-compiler_builtins: $(srctree)/rust/compiler_builtins.rs FORCE
58+
rustdoc-compiler_builtins: $(srctree)/rust/compiler_builtins.rs rustdoc-core FORCE
4959
$(call if_changed,rustdoc)
5060

5161
# We need to allow `broken_intra_doc_links` because some
5262
# `no_global_oom_handling` functions refer to non-`no_global_oom_handling`
5363
# functions. Ideally `rustdoc` would have a way to distinguish broken links
5464
# due to things that are "configured out" vs. entirely non-existing ones.
5565
rustdoc-alloc: private rustc_target_flags = --cfg no_global_oom_handling \
56-
-Abroken_intra_doc_links
57-
rustdoc-alloc: $(srctree)/rust/alloc/lib.rs FORCE
66+
-Abroken_intra_doc_links
67+
rustdoc-alloc: $(srctree)/rust/alloc/lib.rs rustdoc-core \
68+
rustdoc-compiler_builtins FORCE
5869
$(call if_changed,rustdoc)
5970

6071
rustdoc-kernel: private rustc_target_flags = --extern alloc \
6172
--extern build_error \
6273
--extern macros=$(objtree)/rust/libmacros.so
63-
rustdoc-kernel: $(srctree)/rust/kernel/lib.rs rustdoc-macros \
74+
rustdoc-kernel: $(srctree)/rust/kernel/lib.rs rustdoc-core \
75+
rustdoc-macros rustdoc-compiler_builtins rustdoc-alloc \
6476
$(objtree)/rust/libmacros.so $(objtree)/rust/bindings_generated.rs FORCE
6577
$(call if_changed,rustdoc)
6678

@@ -299,3 +311,6 @@ $(objtree)/rust/kernel.o: $(srctree)/rust/kernel/lib.rs $(objtree)/rust/alloc.o
299311
$(objtree)/rust/core.o: private skip_clippy = 1
300312
$(objtree)/rust/core.o: $$(RUST_LIB_SRC)/core/src/lib.rs FORCE
301313
$(call if_changed_dep,rustc_library)
314+
315+
rustdoc-core: $$(RUST_LIB_SRC)/core/src/lib.rs FORCE
316+
$(call if_changed,rustdoc)

0 commit comments

Comments
 (0)