2828from .utils import has_scope_resolution_outside_angles , parse_qualified_path
2929
3030
31- def _process_namespace_sections (snapshot , namespace_scope , compound_object ):
31+ def _should_exclude_symbol (name : str , exclude_symbols : list [str ]) -> bool :
32+ """
33+ Check if a compound name should be excluded based on symbol patterns.
34+
35+ Each pattern in exclude_symbols is treated as a substring match against
36+ the compound's qualified name.
37+ """
38+ return any (pattern in name for pattern in exclude_symbols )
39+
40+
41+ def _process_namespace_sections (
42+ snapshot , namespace_scope , compound_object , exclude_symbols : list [str ]
43+ ):
3244 """
3345 Process all section definitions inside a namespace compound.
3446 """
47+ compound_name = compound_object .compoundname
3548 for section_def in compound_object .sectiondef :
3649 if section_def .kind == "var" :
3750 for variable_def in section_def .memberdef :
3851 # Skip out-of-class definitions (e.g. "Strct<T>::VALUE")
3952 if has_scope_resolution_outside_angles (variable_def .get_name ()):
4053 continue
54+ qualified_name = f"{ compound_name } ::{ variable_def .get_name ()} "
55+ if _should_exclude_symbol (qualified_name , exclude_symbols ):
56+ continue
4157 is_static = variable_def .static == "yes"
4258 namespace_scope .add_member (
4359 get_variable_member (variable_def , "public" , is_static )
@@ -47,6 +63,9 @@ def _process_namespace_sections(snapshot, namespace_scope, compound_object):
4763 # Skip out-of-class definitions (e.g. "Strct<T>::convert")
4864 if has_scope_resolution_outside_angles (function_def .get_name ()):
4965 continue
66+ qualified_name = f"{ compound_name } ::{ function_def .get_name ()} "
67+ if _should_exclude_symbol (qualified_name , exclude_symbols ):
68+ continue
5069 function_static = function_def .static == "yes"
5170
5271 if not function_static :
@@ -55,20 +74,29 @@ def _process_namespace_sections(snapshot, namespace_scope, compound_object):
5574 )
5675 elif section_def .kind == "typedef" :
5776 for typedef_def in section_def .memberdef :
77+ qualified_name = f"{ compound_name } ::{ typedef_def .get_name ()} "
78+ if _should_exclude_symbol (qualified_name , exclude_symbols ):
79+ continue
5880 namespace_scope .add_member (get_typedef_member (typedef_def , "public" ))
5981 elif section_def .kind == "enum" :
6082 for enum_def in section_def .memberdef :
83+ qualified_name = f"{ compound_name } ::{ enum_def .get_name ()} "
84+ if _should_exclude_symbol (qualified_name , exclude_symbols ):
85+ continue
6186 create_enum_scope (snapshot , enum_def )
6287 else :
6388 print (
6489 f"Unknown section kind: { section_def .kind } in { compound_object .location .file } "
6590 )
6691
6792
68- def _handle_namespace_compound (snapshot , compound_object ):
93+ def _handle_namespace_compound (snapshot , compound_object , exclude_symbols = None ):
6994 """
7095 Handle a namespace compound definition.
7196 """
97+ if exclude_symbols is None :
98+ exclude_symbols = []
99+
72100 # Skip anonymous namespaces (internal linkage, not public API).
73101 # Doxygen encodes them with a '@' prefix in the compound name.
74102 if "@" in compound_object .compoundname :
@@ -78,7 +106,9 @@ def _handle_namespace_compound(snapshot, compound_object):
78106
79107 namespace_scope .location = compound_object .location .file
80108
81- _process_namespace_sections (snapshot , namespace_scope , compound_object )
109+ _process_namespace_sections (
110+ snapshot , namespace_scope , compound_object , exclude_symbols
111+ )
82112
83113
84114def _handle_concept_compound (snapshot , compound_object ):
@@ -140,10 +170,18 @@ def _handle_class_compound(snapshot, compound_object):
140170)
141171
142172
143- def build_snapshot (xml_dir : str ) -> Snapshot :
173+ def build_snapshot (xml_dir : str , exclude_symbols : list [ str ] | None = None ) -> Snapshot :
144174 """
145175 Reads the Doxygen XML output and builds a snapshot of the C++ API.
176+
177+ Args:
178+ xml_dir: Path to the Doxygen XML output directory.
179+ exclude_symbols: Optional list of substring patterns. Compounds whose
180+ qualified name contains any of these patterns will be excluded.
146181 """
182+ if exclude_symbols is None :
183+ exclude_symbols = []
184+
147185 index_path = os .path .join (xml_dir , "index.xml" )
148186 if not os .path .exists (index_path ):
149187 raise RuntimeError (f"Doxygen entry point not found at { index_path } " )
@@ -163,12 +201,19 @@ def build_snapshot(xml_dir: str) -> Snapshot:
163201 if compound_object .prot == "private" :
164202 continue
165203
204+ if _should_exclude_symbol (compound_object .compoundname , exclude_symbols ):
205+ continue
206+
166207 kind = compound_object .kind
167208
168209 if kind in _IGNORED_COMPOUNDS :
169210 pass
170211 elif kind in _COMPOUND_HANDLERS :
171- _COMPOUND_HANDLERS [kind ](snapshot , compound_object )
212+ handler = _COMPOUND_HANDLERS [kind ]
213+ if handler == _handle_namespace_compound :
214+ handler (snapshot , compound_object , exclude_symbols )
215+ else :
216+ handler (snapshot , compound_object )
172217 else :
173218 print (f"Unknown compound kind: { kind } " )
174219
0 commit comments