QDoc: Render SFINAE constraints as requires clauses
Qt's public API uses SFINAE-based type constraints on template
functions, expressed as unnamed non-type template parameters with
enable_if_t defaults. These appear in documentation as cryptic
boolean parameters that convey no meaning to readers. A signature
such as `template <typename T, if_integral<T> = true>` leaves
readers guessing what the constraint means and why the parameter
exists.
QDoc detects these SFINAE patterns and presents them as readable
requires clauses in the rendered signature. The opaque parameters
are replaced with `requires if_integral<T>`, giving documentation
readers immediate visibility into the type constraints that govern
API availability. When a function also carries an explicit requires
clause, the synthesized and explicit constraints are combined.
Namespace qualification is preserved so that aliases from different
scopes render unambiguously. End-to-end tests validate the rendering
across all three output formats.
[ChangeLog][QDoc] Functions using enable_if-based SFINAE constraints
now display requires clauses in the documentation output.
Fixes: QTBUG-145067
Change-Id: Iaff0469063fda0c70a6268fcf368249d209a5db9
Reviewed-by: Topi Reinio <topi.reinio@qt.io>
| commit | f2e56b6b07f2d9f0b03bd0ef89f7ed25c37708fb |
| parent | 2f9de2b3e613fb3f2782f0ae1c6bc61ae14b73d6 |
| author | Paul Wicking <paul.wicking@qt.io> |
| committer | Paul Wicking <paul.wicking@qt.io> |
| commit time | Fri, 20 Mar 2026 09:30:05 +0100 |
- M src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp
- M src/qdoc/qdoc/src/qdoc/cppcodemarker.cpp
- M src/qdoc/qdoc/src/qdoc/docbookgenerator.cpp
- M src/qdoc/qdoc/src/qdoc/template_declaration.h
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/docbook/qdoctests-sfinaecontainer.xml
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/docbook/qdoctests.xml
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/docbook/sfinaemodule-module.xml
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/html/qdoctests-sfinaecontainer-members.html
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/html/qdoctests-sfinaecontainer.html
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/html/qdoctests.html
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/html/sfinae-constraints.index
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/html/sfinaemodule-module.html
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/webxml/qdoctests-sfinaecontainer.webxml
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/webxml/qdoctests.webxml
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/expected/webxml/sfinaemodule-module.webxml
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/sfinae_constraints.qdocconf
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/src/sfinae_constraints.h
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/sfinae_constraints/src/sfinae_constraints.qdoc