tools/lib/python/kdoc/kdoc_yaml_file.py
Source file repositories/reference/linux-study-clean/tools/lib/python/kdoc/kdoc_yaml_file.py
File Facts
- System
- Linux kernel
- Corpus path
tools/lib/python/kdoc/kdoc_yaml_file.py- Extension
.py- Size
- 5268 bytes
- Lines
- 179
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
# Copyright(c) 2026: Mauro Carvalho Chehab <mchehab@kernel.org>.
import os
from kdoc.kdoc_output import ManFormat, RestFormat
class KDocTestFile():
"""
Handles the logic needed to store kernel‑doc output inside a YAML file.
Useful for unit tests and regression tests.
"""
def __init__(self, config, yaml_file, yaml_content):
#
# Bail out early if yaml is not available
#
try:
import yaml
except ImportError:
sys.exit("Warning: yaml package not available. Aborting it.")
self.config = config
self.test_file = os.path.expanduser(yaml_file)
self.yaml_content = yaml_content
self.test_names = set()
self.tests = []
out_dir = os.path.dirname(self.test_file)
if out_dir and not os.path.isdir(out_dir):
sys.exit(f"Directory {out_dir} doesn't exist.")
self.out_style = []
if "man" in self.yaml_content:
out_style = ManFormat()
out_style.set_config(self.config)
self.out_style.append(out_style)
if "rst" in self.yaml_content:
out_style = RestFormat()
out_style.set_config(self.config)
self.out_style.append(out_style)
def set_filter(self, export, internal, symbol, nosymbol,
function_table, enable_lineno, no_doc_sections):
"""
Set filters at the output classes.
"""
for out_style in self.out_style:
out_style.set_filter(export, internal, symbol,
nosymbol, function_table,
enable_lineno, no_doc_sections)
@staticmethod
def get_kdoc_item(arg, start_line=1):
d = vars(arg)
declaration_start_line = d.get("declaration_start_line")
if not declaration_start_line:
return d
d["declaration_start_line"] = start_line
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.