Fix html build with Sphinx 3.1 and above
Subsystems (29)
PATCH v4 51/52 docs: conf.py: fix c:function support with Sphinx 3.x
In reply to Mauro Carvalho ChehabSphinx C parser for the C domain is now more pedantic when trying to identify the function types. That prevents scope macros to be used as type defines.
Yet, since 3.0.2, it is possible to provide it a list of such macros. Add them, in order to solve several Sphinx 3.x warnings.
--- Documentation/conf.py | 65 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-)
Documentation/conf.py +62 -3
@@ -47,9 +47,68 @@ extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', # if major >= 3: sys.stderr.write('''WARNING: The kernel documentation build process - does not work correctly with Sphinx v3.0 and above. Expect errors - in the generated output. - ''') + does not work correctly with Sphinx v3.0 and above. Expect errors + in the generated output. + ''') + if minor > 0 or patch >= 2: + # Sphinx c function parser is more pedantic with regards to type + # checking. Due to that, having macros at c:function cause problems. + # Those needed to be scaped by using c_id_attributes[] array + c_id_attributes = [ + # GCC Compiler types not parsed by Sphinx: + "__restrict__", + + # include/linux/compiler_types.h: + "__iomem", + "__kernel", + "noinstr", + "notrace", + "__percpu", + "__rcu", + "__user", + + # include/linux/compiler_attributes.h: + "__alias", + "__aligned", + "__aligned_largest", + "__always_inline", + "__assume_aligned", + "__cold", + "__attribute_const__", + "__copy", + "__pure", + "__designated_init", + "__visible", + "__printf", + "__scanf", + "__gnu_inline", + "__malloc", + "__mode", + "__no_caller_saved_registers", + "__noclone", + "__nonstring", + "__noreturn", + "__packed", + "__pure", + "__section", + "__always_unused", + "__maybe_unused", + "__used", + "__weak", + "noinline", + + # include/linux/memblock.h: + "__init_memblock", + "__meminit", + + # include/linux/init.h: + "__init", + "__ref", + + # include/linux/linkage.h: + "asmlinkage", + ] + else: extensions.append('cdomain') extensions.append('automarkup')
Signature · 1 line
2.26.2
PATCH v4 52/52 docs: conf.py: change the Sphinx 3.x+ text
In reply to Mauro Carvalho ChehabAfter the build fix patches, it is believed that the output with Sphinx 3.x won't be a problem. Still, the C domain support was re-written, and this can have caused hidden issues.
So, let's keep the warning, changing it to a lighter warning text.
--- Documentation/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/conf.py +2 -2
@@ -47,8 +47,8 @@ extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', # if major >= 3: sys.stderr.write('''WARNING: The kernel documentation build process - does not work correctly with Sphinx v3.0 and above. Expect errors - in the generated output. + support for Sphinx v3.0 and above is brand new. Be prepared for + possible issues in the generated output. ''') if minor > 0 or patch >= 2: # Sphinx c function parser is more pedantic with regards to type
Signature · 1 line
2.26.2
Jonathan Corbet
maintainerQuoted 15 lines · On Wed, 30 Sep 2020 15:24:23 +0200 Mauro Carvalho Chehab…
This series add proper support for Sphinx 3.1 and above for building the html docs.
This series comes after the one I wrote fixing the warnings.
With this series applied on the top of next-20200922, there are just 12 warnings:
- 2 of them happens also on Sphinx 2.4.4
(both seem easy to fix: I'll send later fixes for those);
- 10 happens only on Sphinx 3.2.1.The new warnings are all due to duplicated C domain cross-reference symbols.
Basically, the C domain on Sphinx doesn't allow to have an struct and a function with the same name. I opened an issue on Sphinx.:
Quoted 8 lines
https://github.com/sphinx-doc/sphinx/issues/8241Hopefully, some newer version may have it fixed.
There is still one thing that requires a fix: the
automarkup.py. The way cross-references are stored with Sphinx 3 are different. I didn't try yet to address it, but I suspect that it shouldn't be hard to address it.
Modulo my comment on part 4, I think this is what we want. It's kind of unfortunate that it's all necessary, but that's the way things are these days, I guess.
This part is a bit intimidating, though:
Quoted 1 line
288 files changed, 1709 insertions(+), 2183 deletions(-)
Should we maybe position this as an end-of-merge-window blast, once other stuff has hopefully mostly settled? I can certainly warn Linus that it's coming when I send the main docs pull.
I wonder how soon we could pull our minimum version forward to 3.1 and drop a bunch of stuff? I fear it may not be for a while, alas...
Thanks for doing all this work,
jon
Em Thu, 1 Oct 2020 15:48:54 -0600
Jonathan Corbet <[email protected]> escreveu:
Quoted 22 lines
Quoted 19 lines · On Wed, 30 Sep 2020 15:24:23 +0200 Mauro Carvalho Chehab…
This series add proper support for Sphinx 3.1 and above for building the html docs.
This series comes after the one I wrote fixing the warnings.
With this series applied on the top of next-20200922, there are just 12 warnings:
- 2 of them happens also on Sphinx 2.4.4
(both seem easy to fix: I'll send later fixes for those);
- 10 happens only on Sphinx 3.2.1.The new warnings are all due to duplicated C domain cross-reference symbols.
Basically, the C domain on Sphinx doesn't allow to have an struct and a function with the same name. I opened an issue on Sphinx.:
https://github.com/sphinx-doc/sphinx/issues/8241Hopefully, some newer version may have it fixed.
Quoted 8 lines
Quoted 4 lines
There is still one thing that requires a fix: the
automarkup.py. The way cross-references are stored with Sphinx 3 are different. I didn't try yet to address it, but I suspect that it shouldn't be hard to address it.Modulo my comment on part 4, I think this is what we want. It's kind of unfortunate that it's all necessary, but that's the way things are these days, I guess.
Yes, it is unfortunate. Yet, my feeling is that this approach provides us a good way to transition to the new C domain parser, which has some advantages over the older code.
Quoted 3 lines
This part is a bit intimidating, though:
Quoted 1 line
288 files changed, 1709 insertions(+), 2183 deletions(-)
Yes. Yet, the media userspace API is responsible for most of it:
224 files changed, 1076 insertions(+), 1716 deletions(-)
As most of the uAPI documentation doesn't rely on kernel-doc (mostly due to historic reasons).
To be fair, most of the other changes outside the building system are due to already-existing issues at the documentation. There are several kernel-doc tags creating duplicated C references.
While Sphinx < 3 C domain parser were able to detect them, such warnings are disabled by default.
Quoted 3 lines
Should we maybe position this as an end-of-merge-window blast, once other stuff has hopefully mostly settled? I can certainly warn Linus that it's coming when I send the main docs pull.
Yeah, adding this series, together with the remaining patches fixing all warnings with Sphinx < 3 at the end of the merge window seems the right thing to do, IMO.
Quoted 2 lines
I wonder how soon we could pull our minimum version forward to 3.1 and drop a bunch of stuff? I fear it may not be for a while, alas...
I guess it may take some time. In any case, for the next minimal version, I would set for the upcoming one that will fix those issue reported here:
https://github.com/sphinx-doc/sphinx/issues/7819 https://github.com/sphinx-doc/sphinx/issues/8241
One such example is this warning:
.../Documentation/driver-api/miscellaneous:48: ../drivers/pwm/core.c:669: WARNING: Duplicate C declaration, also defined in 'driver-api/miscellaneous'. Declaration is 'int pwm_capture (struct pwm_device *pwm, struct pwm_capture *result, unsigned long timeout)'.
(See: we have a function pwm_capture and a struct with the
same name. Both have kernel-doc tags at drivers/pwm/core.c)
Without fixing it, there's no way to produce a zero-warning docs building[1] with Sphinx versions above 2.4.x.
[1] Well, it could be possible to rename such kAPI symbols to make Sphinx happy, but IMO, the C domain there should be able to fully support the C language.
Quoted 1 line
Thanks for doing all this work,
Anytime.
Thanks,
Mauro