tools/lib/python/feat/parse_features.py

Source file repositories/reference/linux-study-clean/tools/lib/python/feat/parse_features.py

File Facts

System
Linux kernel
Corpus path
tools/lib/python/feat/parse_features.py
Extension
.py
Size
16721 bytes
Lines
508
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.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/usr/bin/env python3
# pylint: disable=R0902,R0911,R0912,R0914,R0915
# Copyright(c) 2025: Mauro Carvalho Chehab <mchehab@kernel.org>.
# SPDX-License-Identifier: GPL-2.0


"""
Library to parse the Linux Feature files and produce a ReST book.
"""

import os
import re
import sys

from glob import iglob


class ParseFeature:
    """
    Parses Documentation/features, allowing to generate ReST documentation
    from it.
    """

    #: feature header string.
    h_name = "Feature"

    #: Kernel config header string.
    h_kconfig = "Kconfig"

    #: description header string.
    h_description = "Description"

    #: subsystem header string.
    h_subsys = "Subsystem"

    #: status header string.
    h_status = "Status"

    #: architecture header string.
    h_arch = "Architecture"

    #: Sort order for status. Others will be mapped at the end.
    status_map = {
        "ok":   0,
        "TODO": 1,
        "N/A":  2,
        # The only missing status is "..", which was mapped as "---",
        # as this is an special ReST cell value. Let it get the
        # default order (99).
    }

    def __init__(self, prefix, debug=0, enable_fname=False):
        """
        Sets internal variables.
        """

        self.prefix = prefix
        self.debug = debug
        self.enable_fname = enable_fname

        self.data = {}

        # Initial maximum values use just the headers
        self.max_size_name = len(self.h_name)
        self.max_size_kconfig = len(self.h_kconfig)
        self.max_size_description = len(self.h_description)
        self.max_size_desc_word = 0
        self.max_size_subsys = len(self.h_subsys)
        self.max_size_status = len(self.h_status)
        self.max_size_arch = len(self.h_arch)

Annotation

Implementation Notes