Contribution and Documentation Guide
Relevant source files
The following files were used as context for generating this wiki page:
The Linux kernel project relies on high-quality documentation and structured contribution processes to manage its large, geographically dispersed development team. This guide outlines the procedures for improving kernel documentation, utilizing the Sphinx-based build system, and adhering to community standards for patch submission. Effective documentation prevents time wasted on reverse-engineering code and reduces avoidable errors for both new and established developers.
Sources: Documentation/doc-guide/contributing.rst:6-12, Documentation/process/howto.rst:41-45
Documentation Build System
The project uses Sphinx to generate formatted documentation from reStructuredText (ReST) files located under the Documentation directory. The build system supports multiple output formats, primarily HTML and PDF, through a toolchain that integrates ReST files with structured kernel-doc comments extracted from source code.
Build Toolchain Components
The documentation build process requires several key tools and environments to ensure consistency and prevent breaks caused by host system updates.
The diagram shows the flow from source files and markup to final generated documentation formats via the Sphinx engine.
Sources: Documentation/doc-guide/sphinx.rst:7-14, Documentation/doc-guide/sphinx.rst:45-50, Documentation/doc-guide/sphinx.rst:112-118
Environment Setup
Developers should use a Python virtual environment to install a stable version of Sphinx (version 3.4.3 or higher).
- Create a virtual environment:
virtualenv sphinx_latest - Activate the environment:
. sphinx_latest/bin/activate - Install requirements:
pip install -r Documentation/sphinx/requirements.txt
Sources: Documentation/doc-guide/sphinx.rst:24-34
Core Build Commands
| Command | Description | Output Location |
|---|---|---|
make htmldocs | Generates HTML documentation using the Alabaster or RTD theme. | Documentation/output/html |
make pdfdocs | Generates PDF files using XeLaTeX. | Documentation/output/pdf |
make cleandocs | Removes all generated documentation files. | Documentation/output |
make refcheckdocs | Finds references to nonexistent documentation files. | N/A |
Sources: Documentation/doc-guide/sphinx.rst:112-119, Documentation/doc-guide/sphinx.rst:138-140, Documentation/doc-guide/contributing.rst:111-112
Writing kernel-doc Comments
The kernel-doc format provides a structured way to document functions, structs, unions, enums, and typedefs directly within the source code. The documentation build system extracts these comments and converts them into reStructuredText.
Function Documentation Structure
A standard function comment must start with /** and include specific sections for parameters, context, and return values.
/**
* function_name() - Brief description.
* @arg1: Describe the first argument.
* @arg2: Describe the second argument.
*
* Longer description spanning multiple paragraphs.
*
* Context: Describes locking, sleeping, or interrupt requirements.
* Return: Describes the return value.
*/
Sources: Documentation/doc-guide/kernel-doc.rst:49-75
Key kernel-doc Syntax
- Functions: Referenced as
funcname(). - Parameters: Referenced with
@parameter. - Constants: Referenced with
%CONST(e.g.,%NULL). - Types: Referenced as
&struct name,&enum name, or&typedef name.
Sources: Documentation/doc-guide/kernel-doc.rst:314-345
Contribution Guidelines
The kernel development community enforces strict technical and procedural standards for all submissions.
Patch Quality and Structure
Maintainers prioritize technical merit and clean, elegant solutions. Patches must be broken down into small, logically cohesive changes to facilitate review and debugging.
- Atomicity: Each commit should be a single change.
- Justification: The commit message must explain why the change is necessary.
- Testing: Changes must be tested on multiple architectures and verified against regressions.
- Formatting: C code must follow
Documentation/process/coding-style.rst.
Sources: Documentation/process/howto.rst:335-345, Documentation/process/howto.rst:417-430, rust/pin-init/CONTRIBUTING.md:43-46
Tool-Generated Content
Contributors must disclose the use of tools (e.g., chatbots, Coccinelle scripts, or generative AI) in patch changelogs. While trivial tweaks like formatting or spelling fixes are out of scope for disclosure, any meaningful content created by a tool requires transparency regarding the tool used and the prompts provided.
Sources: Documentation/process/generated-content.rst:29-55
Maintainer Interaction
Submissions undergo public review on mailing lists. The typical lifecycle follows a sequence of feedback and iteration.
Documentation TODO List
The documentation maintainer identifies several high-priority tasks for contributors:
- Eliminating Warnings: Fix
bad lineor missing asterisk warnings inkernel-docblocks. - Unused Documentation: Pull languishing
kernel-doccomments into the build using thekernel-docdirective. - Obsolete Documentation: Update or remove documents referring to 2.x kernels or removed code.
- Coherency: Move documents into structured "books" such as the
admin-guide,core-api, ordriver-api.
Sources: Documentation/doc-guide/contributing.rst:25-35, Documentation/doc-guide/contributing.rst:116-125, Documentation/doc-guide/contributing.rst:155-165
Effective kernel contribution requires balancing technical implementation with clear communication and adherence to the project's specialized build and review processes. Maintaining this structure allows the community to manage thousands of files and contributors while ensuring the kernel remains robust and accessible.