hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/Documentation/sphinx/kerneldoc.py
....@@ -59,15 +59,22 @@
5959 optional_arguments = 4
6060 option_spec = {
6161 'doc': directives.unchanged_required,
62
- 'functions': directives.unchanged,
6362 'export': directives.unchanged,
6463 'internal': directives.unchanged,
64
+ 'identifiers': directives.unchanged,
65
+ 'no-identifiers': directives.unchanged,
66
+ 'functions': directives.unchanged,
6567 }
6668 has_content = False
6769
6870 def run(self):
6971 env = self.state.document.settings.env
7072 cmd = [env.config.kerneldoc_bin, '-rst', '-enable-lineno']
73
+
74
+ # Pass the version string to kernel-doc, as it needs to use a different
75
+ # dialect, depending what the C domain supports for each specific
76
+ # Sphinx versions
77
+ cmd += ['-sphinx-version', sphinx.__version__]
7178
7279 filename = env.config.kerneldoc_srctree + '/' + self.arguments[0]
7380 export_file_patterns = []
....@@ -76,6 +83,10 @@
7683 env.note_dependency(os.path.abspath(filename))
7784
7885 tab_width = self.options.get('tab-width', self.state.document.settings.tab_width)
86
+
87
+ # 'function' is an alias of 'identifiers'
88
+ if 'functions' in self.options:
89
+ self.options['identifiers'] = self.options.get('functions')
7990
8091 # FIXME: make this nicer and more robust against errors
8192 if 'export' in self.options:
....@@ -86,13 +97,19 @@
8697 export_file_patterns = str(self.options.get('internal')).split()
8798 elif 'doc' in self.options:
8899 cmd += ['-function', str(self.options.get('doc'))]
89
- elif 'functions' in self.options:
90
- functions = self.options.get('functions').split()
91
- if functions:
92
- for f in functions:
93
- cmd += ['-function', f]
100
+ elif 'identifiers' in self.options:
101
+ identifiers = self.options.get('identifiers').split()
102
+ if identifiers:
103
+ for i in identifiers:
104
+ cmd += ['-function', i]
94105 else:
95106 cmd += ['-no-doc-sections']
107
+
108
+ if 'no-identifiers' in self.options:
109
+ no_identifiers = self.options.get('no-identifiers').split()
110
+ if no_identifiers:
111
+ for i in no_identifiers:
112
+ cmd += ['-nosymbol', i]
96113
97114 for pattern in export_file_patterns:
98115 for f in glob.glob(env.config.kerneldoc_srctree + '/' + pattern):
....@@ -131,7 +148,8 @@
131148 lineoffset = int(match.group(1)) - 1
132149 # we must eat our comments since the upset the markup
133150 else:
134
- result.append(line, filename, lineoffset)
151
+ doc = env.srcdir + "/" + env.docname + ":" + str(self.lineno)
152
+ result.append(line, doc + ": " + filename, lineoffset)
135153 lineoffset += 1
136154
137155 node = nodes.section()