Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
inclusionstrategy.qdoc
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \headerfile inclusionflags.h
6 \title Inclusion Strategy Components
7 \inmodule QDoc
8 \brief Defines types for controlling documentation inclusion of private and internal API elements.
9
10 The inclusion strategy system provides a centralized way to determine which
11 documentation nodes should be included in generated output. It consists of
12 three main components that work together to implement inclusion decisions:
13
14 \list
15 \li \l{InclusionFlag} and \l{InclusionFlags} - Flags representing different types of private API
16 \li \l{InclusionPolicy} - Configuration-driven policy for what to include
17 \li \l{NodeContext} - Lightweight node state capture for policy evaluation
18 \endlist
19
20 This system replaces scattered inclusion checks throughout QDoc with a
21 unified approach, ensuring consistent behavior across all output generators.
22*/
23
24/*!
25 \enum InclusionFlag
26 \headerfile inclusionflags.h
27 \inmodule QDoc
28 \brief Flags for different categories of private API elements.
29
30 These flags represent different types of private API elements that can be
31 selectively included in documentation based on configuration settings.
32
33 \value PrivateFunction
34 Private functions and methods. Corresponds to the
35 \c{includeprivate.functions} configuration option, or if unset,
36 to the general \c{includeprivate} option.
37
38 \value PrivateType
39 Private types including classes, enums, and typedefs. Corresponds to
40 the \c{includeprivate.types} configuration option, or if unset,
41 to the general \c{includeprivate} option.
42
43 \value PrivateVariable
44 Private member variables and properties. Corresponds to the
45 \c{includeprivate.variables} configuration option, or if unset,
46 to the general \c{includeprivate} option.
47
48 \value Internal
49 Internal API elements marked with \\internal. Corresponds to the
50 \c{showinternal} configuration option and command line flag.
51
52 \sa InclusionFlags, InclusionPolicy
53*/
54
55/*!
56 \typedef InclusionFlags
57 \relates InclusionFlag
58 \headerfile inclusionflags.h
59 \inmodule QDoc
60
61 QFlags type for combining multiple InclusionFlag values.
62*/
63
64/*!
65 \struct InclusionPolicy
66 \headerfile inclusionpolicy.h
67 \inmodule QDoc
68 \brief Configuration-driven policy for including private API in documentation.
69
70 InclusionPolicy captures the current configuration settings for private API
71 documentation. It is constructed from QDoc's configuration variables and
72 provides a consistent interface for inclusion decisions.
73
74 The policy is typically created once per documentation run from the current
75 configuration and passed to InclusionFilter for making inclusion decisions.
76
77 \sa Config::createInclusionPolicy(), InclusionFilter
78*/
79
80/*!
81 \variable InclusionPolicy::includePrivateFunction
82 \brief Whether to include private functions in documentation.
83
84 When true, private functions and methods are included in documentation
85 output. Corresponds to the \c{includeprivate.functions} configuration
86 variable. Takes precedence over the general includePrivate setting for
87 function nodes.
88*/
89
90/*!
91 \variable InclusionPolicy::includePrivateType
92 \brief Whether to include private types in documentation.
93
94 When true, private classes, enums, and typedefs are included in
95 documentation output. Corresponds to the \c{includeprivate.types}
96 configuration variable. Takes precedence over the general includePrivate
97 setting for type nodes.
98*/
99
100/*!
101 \variable InclusionPolicy::includePrivateVariable
102 \brief Whether to include private variables in documentation.
103
104 When true, private member variables and properties are included in
105 documentation output. Corresponds to the \c{includeprivate.variables}
106 configuration variable. Takes precedence over the general includePrivate
107 setting for variable nodes.
108*/
109
110/*!
111 \variable InclusionPolicy::showInternal
112 \brief Whether to include internal API elements in documentation.
113
114 When true, API elements marked with \\internal comments are included in
115 documentation output. Corresponds to the \c{showinternal} configuration
116 variable and the \c{--show-internal} command line option.
117*/
118
119/*!
120 \fn InclusionFlags InclusionPolicy::toFlags() const
121 \brief Converts the policy settings to flags for efficient comparison.
122
123 Returns an InclusionFlags value representing which categories of private
124 API should be included based on the current policy settings.
125*/
126
127/*!
128 \struct NodeContext
129 \headerfile nodecontext.h
130 \inmodule QDoc
131 \brief Lightweight capture of node state for inclusion decisions.
132
133 NodeContext is a value type that captures relevant node properties once,
134 avoiding repeated type checks and casts when evaluating inclusion rules.
135 It is created from a Node via Node::createContext() and used by
136 InclusionFilter to make inclusion decisions.
137
138 The context captures:
139 \list
140 \li The node's type (function, class, variable, etc.)
141 \li Whether the node has private access
142 \li Whether the node is marked as internal
143 \li Whether the node is a pure virtual function
144 \endlist
145
146 This approach eliminates redundant RTTI operations that were previously
147 performed at each inclusion check point.
148
149 \sa Node::createContext(), InclusionFilter
150*/
151
152/*!
153 \variable NodeContext::type
154 \brief The type of the documentation node.
155
156 Stores the NodeType enum value, indicating whether this is a function,
157 class, variable, or other type of documentation node.
158*/
159
160/*!
161 \variable NodeContext::isPrivate
162 \brief Whether the node has private access level.
163
164 True if the node represents a private member of a class or a non-public
165 API element.
166*/
167
168/*!
169 \variable NodeContext::isInternal
170 \brief Whether the node is marked as internal API.
171
172 True if the node is marked with \\internal documentation command,
173 indicating it's internal API not intended for public consumption.
174*/
175
176/*!
177 \variable NodeContext::isPureVirtual
178 \brief Whether the node is a pure virtual function.
179
180 Pure virtual functions require special handling as they must always be
181 documented when included, since derived classes must implement them.
182*/
183
184/*!
185 \fn InclusionFlags NodeContext::toFlags() const
186 \brief Converts node properties to flags for policy matching.
187
188 Returns an InclusionFlags value representing the categories this node
189 belongs to. For non-private nodes, returns an empty flag set. For
190 private nodes, returns flags indicating what specific type of
191 private element it is (function, type, or variable).
192*/
193
194/*!
195 \class InclusionFilter
196 \headerfile inclusionfilter.h
197 \inmodule QDoc
198 \brief Centralized logic for documentation inclusion decisions.
199
200 InclusionFilter provides static methods that implement the logic for
201 determining whether a documentation node should be included in output
202 or whether warnings should be generated for undocumented nodes.
203
204 All inclusion decisions flow through this class, ensuring consistent
205 behavior across different output generators and eliminating duplicate
206 logic that was previously scattered throughout QDoc.
207
208 \sa InclusionPolicy, NodeContext
209*/
210
211/*!
212 \fn bool InclusionFilter::isIncluded(const InclusionPolicy& policy, const NodeContext& context)
213 \brief Determines if a node should be included in documentation output.
214
215 Returns true if the node described by \a context should be included
216 in documentation according to the given \a policy.
217
218 The method handles several special cases:
219 \list
220 \li Internal nodes are only included when showInternal policy is enabled
221 \li Non-private nodes are always included (unless internal and showInternal is false)
222 \li Pure virtual functions are always included (even if private, unless internal and showInternal is false)
223 \li Private nodes are included based on policy flags
224 \endlist
225*/
226
227/*!
228 \fn bool InclusionFilter::requiresDocumentation(const InclusionPolicy& policy, const NodeContext& context)
229 \brief Determines if warnings should be generated for undocumented nodes.
230
231 Returns true if QDoc should warn about the node described by \a context
232 being undocumented, according to the given \a policy.
233
234 Generally follows the same rules as isIncluded(), but is used specifically
235 for determining when to generate warnings about missing documentation.
236*/
237
238/*!
239 \fn bool InclusionFilter::isPubliclyVisible(const InclusionPolicy& policy, const NodeContext& context)
240 \brief Determines if a node should be visible in public documentation.
241
242 Returns true if the node described by \a context should be considered
243 publicly visible according to the given \a policy. This method implements
244 the business rule: "Include everything except internal nodes when
245 showInternal is disabled."
246
247 This is primarily used by index file generation and cross-referencing
248 systems that need to include private members for completeness but should
249 respect the internal visibility policy.
250
251 Unlike isIncluded(), this method only checks internal status and ignores
252 private member inclusion policies, making it suitable for systems that
253 need to preserve private API information for cross-referencing while
254 still respecting internal API visibility rules.
255
256 \sa isIncluded(), processInternalDocs()
257*/
258
259/*!
260 \fn bool InclusionFilter::processInternalDocs(const InclusionPolicy& policy)
261 \brief Determines if internal documentation should be processed.
262
263 Returns true if the given \a policy indicates that internal documentation
264 should be processed. This method implements the business rule: "Process
265 internal documentation only when showInternal is enabled."
266
267 This method is used by parsers, warning systems, and other components
268 that need to make decisions based solely on the internal documentation
269 policy without requiring a specific node context.
270
271 \sa isPubliclyVisible(), isIncluded()
272*/
273
274/*!
275 \fn bool InclusionFilter::isReimplementedMemberVisible(const InclusionPolicy& policy, const NodeContext& context)
276 \brief Determines if a reimplemented member should appear in documentation.
277
278 Returns true if the reimplemented member described by \a context should be
279 documented according to the given \a policy. This method implements the
280 business rule: "Reimplemented members are documented based on their access
281 level in the derived class, not their internal status."
282
283 This is specifically used for populating "Reimplemented Functions" sections,
284 where the fact that a function overrides a base class method is architectural
285 information that should be visible regardless of whether the implementation
286 details are marked as internal.
287
288 Unlike isIncluded(), this method treats internal status as orthogonal to
289 reimplementation visibility - a public override of an internal base class
290 function should still appear in the reimplemented functions list.
291
292 The method handles several cases:
293 \list
294 \li Public and protected reimplemented members are always visible
295 \li Pure virtual reimplemented members are always visible (even if private)
296 \li Private reimplemented members follow private inclusion policies
297 \li Internal status is explicitly ignored for reimplemented member visibility
298 \endlist
299
300 \sa isIncluded(), isPubliclyVisible(), requiresDocumentation()
301*/