From f1ac82ca93b247af7d393a58f6da1691932f69d5 Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Wed, 11 Mar 2026 01:42:26 -0700 Subject: [PATCH] Don't include private compound objects in the snapshot (#56028) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56028 Changelog: [Internal] Updates the snapshot generator to ignore compound objects with visibility set to `private`. Reviewed By: cortinico Differential Revision: D95913606 fbshipit-source-id: 3c5b2e0bf46e16627c3f6bdf6cd700a862f56698 --- scripts/cxx-api/parser/main.py | 3 +++ .../should_ignore_private_enum/snapshot.api | 3 +++ .../should_ignore_private_enum/test.h | 21 +++++++++++++++++++ .../should_ignore_private_struct/snapshot.api | 3 +++ .../should_ignore_private_struct/test.h | 21 +++++++++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 scripts/cxx-api/tests/snapshots/should_ignore_private_enum/snapshot.api create mode 100644 scripts/cxx-api/tests/snapshots/should_ignore_private_enum/test.h create mode 100644 scripts/cxx-api/tests/snapshots/should_ignore_private_struct/snapshot.api create mode 100644 scripts/cxx-api/tests/snapshots/should_ignore_private_struct/test.h diff --git a/scripts/cxx-api/parser/main.py b/scripts/cxx-api/parser/main.py index 0c6aa1b7c34..c1f8b6ad1f0 100644 --- a/scripts/cxx-api/parser/main.py +++ b/scripts/cxx-api/parser/main.py @@ -48,6 +48,9 @@ def build_snapshot(xml_dir: str) -> Snapshot: doxygen_object = compound.parse(detail_file, silence=True) for compound_object in doxygen_object.compounddef: + if compound_object.prot == "private": + continue + # Check if this is an Objective-C interface by looking at the compound id # Doxygen reports ObjC interfaces as kind="class" but with id starting with "interface" is_objc_interface = ( diff --git a/scripts/cxx-api/tests/snapshots/should_ignore_private_enum/snapshot.api b/scripts/cxx-api/tests/snapshots/should_ignore_private_enum/snapshot.api new file mode 100644 index 00000000000..7db6e6e5741 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_ignore_private_enum/snapshot.api @@ -0,0 +1,3 @@ +class test::Clss { + public void hello(); +} diff --git a/scripts/cxx-api/tests/snapshots/should_ignore_private_enum/test.h b/scripts/cxx-api/tests/snapshots/should_ignore_private_enum/test.h new file mode 100644 index 00000000000..488c6c25716 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_ignore_private_enum/test.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +namespace test { + +class Clss { + enum class PrivateEnum { + A, + }; + + public: + void hello(); +}; + +} // namespace test diff --git a/scripts/cxx-api/tests/snapshots/should_ignore_private_struct/snapshot.api b/scripts/cxx-api/tests/snapshots/should_ignore_private_struct/snapshot.api new file mode 100644 index 00000000000..7db6e6e5741 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_ignore_private_struct/snapshot.api @@ -0,0 +1,3 @@ +class test::Clss { + public void hello(); +} diff --git a/scripts/cxx-api/tests/snapshots/should_ignore_private_struct/test.h b/scripts/cxx-api/tests/snapshots/should_ignore_private_struct/test.h new file mode 100644 index 00000000000..0c2f4dd03df --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_ignore_private_struct/test.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +namespace test { + +class Clss { + struct PrivateStruct { + int a; + }; + + public: + void hello(); +}; + +} // namespace test