Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: kernel_include.py: remove Include class inheritance

While the original code came from the Sphinx Include class,
such class is monolithic: it has only one function that does
everything, and 3 variables that are used:

- required_arguments
- optional_arguments
- option_spec

So, basically those are the only members that remain from
the original class, but hey! Those are the same vars that every
other Sphinx directive extension has to define!

In summary, keeping inheritance here doesn't make much sense.

Worse than that, kernel-include doesn't support the current set
of options that the original Include class has, but it also
has its own set of options.

So, let's fill in the argument vars with what it does
support, dropping the rest.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/a9f2eebf11c6b0c3a2e3bf42e71392cdfd2835d1.1755872208.git.mchehab+huawei@kernel.org

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
428c1d35 4aa578f9

+32 -8
+32 -8
Documentation/sphinx/kernel_include.py
··· 62 62 from docutils import io, nodes, statemachine 63 63 from docutils.statemachine import ViewList 64 64 from docutils.utils.error_reporting import SafeString, ErrorString 65 - from docutils.parsers.rst import directives 65 + from docutils.parsers.rst import Directive, directives 66 66 from docutils.parsers.rst.directives.body import CodeBlock, NumberLines 67 - from docutils.parsers.rst.directives.misc import Include 68 67 69 68 from sphinx.util import logging 70 69 ··· 80 81 81 82 82 83 # ============================================================================== 83 - class KernelInclude(Include): 84 - """KernelInclude (``kernel-include``) directive""" 84 + class KernelInclude(Directive): 85 + """ 86 + KernelInclude (``kernel-include``) directive 85 87 86 - # Add extra options 87 - option_spec = Include.option_spec.copy() 88 + Most of the stuff here came from Include directive defined at: 89 + docutils/parsers/rst/directives/misc.py 88 90 89 - option_spec.update({ 91 + Yet, overriding the class don't has any benefits: the original class 92 + only have run() and argument list. Not all of them are implemented, 93 + when checked against latest Sphinx version, as with time more arguments 94 + were added. 95 + 96 + So, keep its own list of supported arguments 97 + """ 98 + 99 + required_arguments = 1 100 + optional_arguments = 0 101 + final_argument_whitespace = True 102 + option_spec = { 103 + 'literal': directives.flag, 104 + 'code': directives.unchanged, 105 + 'encoding': directives.encoding, 106 + 'tab-width': int, 107 + 'start-line': int, 108 + 'end-line': int, 109 + 'start-after': directives.unchanged_required, 110 + 'end-before': directives.unchanged_required, 111 + # ignored except for 'literal' or 'code': 112 + 'number-lines': directives.unchanged, # integer or None 113 + 'class': directives.class_option, 114 + 115 + # Arguments that aren't from Sphinx Include directive 90 116 'generate-cross-refs': directives.flag, 91 117 'warn-broken': directives.flag, 92 118 'toc': directives.flag, 93 119 'exception-file': directives.unchanged, 94 - }) 120 + } 95 121 96 122 def read_rawtext(self, path, encoding): 97 123 """Read and process file content with error handling"""