Skip to content

Commit a28ac22

Browse files
authored
Merge pull request torvalds#687 from ojeda/docs
Documentation cleanups
2 parents 4a18fc4 + a8cd8f8 commit a28ac22

File tree

6 files changed

+40
-50
lines changed

6 files changed

+40
-50
lines changed

Documentation/process/changes.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ Each Rust toolchain comes with several "components", some of which are required
9292
is optional) needs to be installed to build the kernel. Other components are
9393
useful for developing.
9494

95-
Please see :ref:`Documentation/rust/quick-start.rst <rust_quick_start>` for
96-
instructions on how to satify the build requirements of Rust support. In
97-
particular, the Makefile target 'rustavailable' is useful to check why the Rust
98-
toolchain may not be detected.
95+
Please see Documentation/rust/quick-start.rst for instructions on how to
96+
satisfy the build requirements of Rust support. In particular, the ``Makefile``
97+
target ``rustavailable`` is useful to check why the Rust toolchain may not
98+
be detected.
9999

100100
bindgen (optional)
101101
------------------
@@ -369,8 +369,7 @@ rustdoc
369369
-------
370370

371371
``rustdoc`` is used to generate the documentation for Rust code. Please see
372-
:ref:`Documentation/rust/general-information.rst <rust_general_information>`
373-
for more information.
372+
Documentation/rust/general-information.rst for more information.
374373

375374
Getting updated software
376375
========================
@@ -391,12 +390,12 @@ Clang/LLVM
391390
Rust
392391
----
393392

394-
- :ref:`Documentation/rust/quick-start.rst <rust_quick_start>`.
393+
- Documentation/rust/quick-start.rst.
395394

396395
bindgen
397396
-------
398397

399-
- :ref:`Documentation/rust/quick-start.rst <rust_quick_start>`.
398+
- Documentation/rust/quick-start.rst.
400399

401400
Make
402401
----

Documentation/rust/arch-support.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
.. _rust_arch_support:
2-
31
Arch Support
42
============
53

64
Currently, the Rust compiler (``rustc``) uses LLVM for code generation,
75
which limits the supported architectures that can be targeted. In addition,
8-
support for building the kernel with LLVM/Clang varies (see :ref:`kbuild_llvm`).
9-
This support is needed for ``bindgen`` which uses ``libclang``.
6+
support for building the kernel with LLVM/Clang varies (please see
7+
Documentation/kbuild/llvm.rst). This support is needed for ``bindgen``
8+
which uses ``libclang``.
109

1110
Below is a general summary of architectures that currently work. Level of
1211
support corresponds to ``S`` values in the ``MAINTAINERS`` file.

Documentation/rust/coding-guidelines.rst

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. _rust_coding_guidelines:
2-
31
Coding Guidelines
42
=================
53

@@ -46,7 +44,7 @@ Comments
4644
with ``///`` or ``//!``) are written in Markdown the same way as documentation
4745
comments are, even though they will not be rendered. This improves consistency,
4846
simplifies the rules and allows to move content between the two kinds of
49-
comments more easily. For instance::
47+
comments more easily. For instance:
5048

5149
.. code-block:: rust
5250
@@ -55,7 +53,7 @@ comments more easily. For instance::
5553
5654
Furthermore, just like documentation, comments are capitalized at the beginning
5755
of a sentence and ended with a period (even if it is a single sentence). This
58-
includes `// SAFETY: `, `// TODO: ` and other "tagged" comments, e.g.::
56+
includes ``// SAFETY:``, ``// TODO:`` and other "tagged" comments, e.g.:
5957

6058
.. code-block:: rust
6159
@@ -65,10 +63,10 @@ Comments should not be used for documentation purposes: comments are intended
6563
for implementation details, not users. This distinction is useful even if the
6664
reader of the source file is both an implementor and a user of an API. In fact,
6765
sometimes it is useful to use both comments and documentation at the same time.
68-
For instance, for a `TODO` list or to comment on the documentation itself. For
69-
the latter case, comments can be inserted in the middle; that is, closer to
66+
For instance, for a ``TODO`` list or to comment on the documentation itself.
67+
For the latter case, comments can be inserted in the middle; that is, closer to
7068
the line of documentation to be commented. For any other case, comments are
71-
written after the documentation, e.g.::
69+
written after the documentation, e.g.:
7270

7371
.. code-block:: rust
7472
@@ -82,21 +80,21 @@ written after the documentation, e.g.::
8280
/// ```
8381
// FIXME: Use fallible approach.
8482
pub fn f(x: i32) -> Foo {
85-
// ...
83+
// ...
8684
}
8785
88-
One special kind of comments are the `// SAFETY: ` comments. These must appear
89-
before every `unsafe` block, and they explain why the code inside the block is
90-
correct/sound, i.e. why it cannot trigger undefined behavior in any case, e.g.::
86+
One special kind of comments are the ``// SAFETY:`` comments. These must appear
87+
before every ``unsafe`` block, and they explain why the code inside the block is
88+
correct/sound, i.e. why it cannot trigger undefined behavior in any case, e.g.:
9189

9290
.. code-block:: rust
9391
9492
// SAFETY: `p` is valid by the safety requirements.
9593
unsafe { *p = 0; }
9694
97-
`// SAFETY: ` comments are not to be confused with the `# Safety` sections in
98-
code documentation. ``# Safety`` sections specify the contract that callers
99-
(for functions) or implementors (for traits) need to abide by. ``// SAFETY: ``
95+
``// SAFETY:`` comments are not to be confused with the ``# Safety`` sections
96+
in code documentation. ``# Safety`` sections specify the contract that callers
97+
(for functions) or implementors (for traits) need to abide by. ``// SAFETY:``
10098
comments show why a call (for functions) or implementation (for traits) actually
10199
respects the preconditions stated in a ``# Safety`` section or the language
102100
reference.
@@ -134,12 +132,12 @@ This is how a well-documented Rust function may look like:
134132
/// assert_eq!(unsafe { x.unwrap_unchecked() }, "air");
135133
/// ```
136134
pub unsafe fn unwrap_unchecked(self) -> T {
137-
match self {
138-
Some(val) => val,
135+
match self {
136+
Some(val) => val,
139137
140-
// SAFETY: The safety contract must be upheld by the caller.
141-
None => unsafe { hint::unreachable_unchecked() },
142-
}
138+
// SAFETY: The safety contract must be upheld by the caller.
139+
None => unsafe { hint::unreachable_unchecked() },
140+
}
143141
}
144142
145143
This example showcases a few ``rustdoc`` features and some conventions followed
@@ -167,15 +165,15 @@ in the kernel:
167165
- Any ``unsafe`` block must be preceded by a ``// SAFETY:`` comment
168166
describing why the code inside is sound.
169167

170-
While sometimes the reason might look trivial and therefore unneeded, writing
171-
these comments is not just a good way of documenting what has been taken into
172-
account, but most importantly, it provides a way to know that there are
173-
no *extra* implicit constraints.
168+
While sometimes the reason might look trivial and therefore unneeded,
169+
writing these comments is not just a good way of documenting what has been
170+
taken into account, but most importantly, it provides a way to know that
171+
there are no *extra* implicit constraints.
174172

175173
To learn more about how to write documentation for Rust and extra features,
176-
please take a look at the ``rustdoc`` `book`_.
174+
please take a look at the ``rustdoc`` book at:
177175

178-
.. _book: https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html
176+
https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html
179177

180178

181179
Naming

Documentation/rust/general-information.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. _rust_general_information:
2-
31
General Information
42
===================
53

@@ -31,8 +29,7 @@ To read the docs locally in your web browser, run e.g.::
3129

3230
xdg-open rust/doc/kernel/index.html
3331

34-
To learn about how to write the documentation, please see the coding guidelines
35-
at :ref:`Documentation/rust/coding-guidelines.rst <rust_coding_guidelines>`.
32+
To learn about how to write the documentation, please see coding-guidelines.rst.
3633

3734

3835
Extra lints

Documentation/rust/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ Rust
22
====
33

44
Documentation related to Rust within the kernel. To start using Rust
5-
in the kernel, please read the
6-
:ref:`Documentation/rust/quick-start.rst <rust_quick_start>` guide.
5+
in the kernel, please read the quick-start.rst guide.
76

87
.. toctree::
98
:maxdepth: 1

Documentation/rust/quick-start.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. _rust_quick_start:
2-
31
Quick Start
42
===========
53

@@ -86,8 +84,8 @@ Otherwise, building LLVM takes quite a while, but it is not a complex process:
8684

8785
https://llvm.org/docs/GettingStarted.html#getting-the-source-code-and-building-llvm
8886

89-
See :ref:`Documentation/kbuild/llvm.rst <kbuild_llvm>` for more information and
90-
further ways to fetch pre-built releases and distribution packages.
87+
Please see Documentation/kbuild/llvm.rst for more information and further ways
88+
to fetch pre-built releases and distribution packages.
9189

9290

9391
bindgen
@@ -113,7 +111,7 @@ rustfmt
113111

114112
The ``rustfmt`` tool is used to automatically format all the Rust kernel code,
115113
including the generated C bindings (for details, please see
116-
:ref:`Documentation/rust/coding-guidelines.rst <rust_coding_guidelines>`).
114+
coding-guidelines.rst).
117115

118116
If ``rustup`` is being used, its ``default`` profile already installs the tool,
119117
thus nothing needs to be done. If another profile is being used, the component
@@ -129,7 +127,7 @@ clippy
129127

130128
``clippy`` is a Rust linter. Running it provides extra warnings for Rust code.
131129
It can be run by passing ``CLIPPY=1`` to ``make`` (for details, please see
132-
:ref:`Documentation/rust/general-information.rst <rust_general_information>`).
130+
general-information.rst).
133131

134132
If ``rustup`` is being used, its ``default`` profile already installs the tool,
135133
thus nothing needs to be done. If another profile is being used, the component
@@ -159,7 +157,7 @@ rustdoc
159157

160158
``rustdoc`` is the documentation tool for Rust. It generates pretty HTML
161159
documentation for Rust code (for details, please see
162-
:ref:`Documentation/rust/general-information.rst <rust_general_information>`).
160+
general-information.rst).
163161

164162
``rustdoc`` is also used to test the examples provided in documented Rust code
165163
(called doctests or documentation tests). The ``rusttest`` Make target uses

0 commit comments

Comments
 (0)