Skip to content

Normalize pointer and reference spacing in parser output#55901

Closed
coado wants to merge 6 commits intofacebook:mainfrom
coado:export-D95078214
Closed

Normalize pointer and reference spacing in parser output#55901
coado wants to merge 6 commits intofacebook:mainfrom
coado:export-D95078214

Conversation

@coado
Copy link
Contributor

@coado coado commented Mar 4, 2026

Summary:
Fixes inconsistent spacing around pointer (*) and reference (&, &&) symbols in the parser output.

Doxygen outputs types with a space before * and & (e.g., NSString *), which is inconsistent. This diff adds normalize_pointer_spacing() to standardize the output:

  • NSString *NSString*
  • int &int&
  • T &&T&&
  • For function arguments: NSString *nameNSString* name

Changes

  1. Added normalize_pointer_spacing() function in text_resolution.py
  2. Applied normalization in resolve_ref_text_name() and resolve_linked_text_name()
  3. Applied normalization to block property argsstrings in builders.py
  4. Updated all affected snapshot files to use normalized spacing

Changelog:
[Internal]

Reviewed By: cortinico

Differential Revision: D95078214

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 4, 2026
@facebook-github-bot facebook-github-bot added p: Software Mansion Partner: Software Mansion Partner p: Facebook Partner: Facebook labels Mar 4, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 4, 2026

@coado has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95078214.

Copy link
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@coado coado force-pushed the export-D95078214 branch from 0787110 to 5b7135f Compare March 4, 2026 14:43
coado added a commit to coado/react-native that referenced this pull request Mar 4, 2026
)

Summary:
Pull Request resolved: facebook#55901

Fixes inconsistent spacing around pointer (`*`) and reference (`&`, `&&`) symbols in the parser output.

Doxygen outputs types with a space before `*` and `&` (e.g., `NSString *`), which is inconsistent. This diff adds `normalize_pointer_spacing()` to standardize the output:

- `NSString *` → `NSString*`
- `int &` → `int&`
- `T &&` → `T&&`
- For function arguments: `NSString *name` → `NSString* name`

## Changes

1. Added `normalize_pointer_spacing()` function in `text_resolution.py`
2. Applied normalization in `resolve_ref_text_name()` and `resolve_linked_text_name()`
3. Applied normalization to block property argsstrings in `builders.py`
4. Updated all affected snapshot files to use normalized spacing

Changelog:
[Internal]

Reviewed By: cortinico

Differential Revision: D95078214
Dawid Małecki added 5 commits March 5, 2026 01:49
Summary:
Doxygen incorrectly parses Objective-C interface declarations with protocol conformance. For example:

```objc
interface RCTAppearance : RCTEventEmitter <RCTBridgeModule>
```

Doxygen splits this into **two separate base classes** in the XML:
```xml
<basecompoundref>RCTEventEmitter</basecompoundref>
<basecompoundref>&lt;RCTBridgeModule&gt;</basecompoundref>
```

This caused the parser to output:
```
interface RCTAppearance : public RCTEventEmitter, public <RCTBridgeModule> {
```

Instead of the expected:
```
interface RCTAppearance : public RCTEventEmitter <RCTBridgeModule> {
```

The fix detects when a "base class" name starts and ends with `<...>` (indicating it's a protocol conformance) and combines it with the preceding actual base class name.

Differential Revision: D94351731
Summary:
Doxygen splits block property types across `<type>` and `<argsstring>` elements. For example:

```objc
property (nonatomic, copy) void (^eventInterceptor)(NSString *eventName, NSDictionary *event, NSNumber *reactTag);
```

Produces XML like:
```xml
<type>void(^</type>
<name>eventInterceptor</name>
<argsstring>)(NSString *eventName, NSDictionary *event, NSNumber *reactTag)</argsstring>
```

This caused the parser to output incomplete types. The fix detects when the property type ends with `(^` and combines it with the property name and argsstring:
```
property (copy) void(^eventInterceptor)(NSString *eventName, NSDictionary *event, NSNumber *reactTag);
```

Differential Revision: D94366205

Reviewed By: cipolleschi
Summary: Set predefined `__deprecated_msg` to empty string in the `.doxygen.config.template` as doxygen has problem with parsing and produces malformed xml.

Differential Revision: D94517576
Summary:
Adds a doxygen input filter (`input_filters/doxygen_strip_comments.py`) that strips block comments from source files before doxygen parses them.

This prevents doxygen from incorrectly parsing Objective-C code examples (like `interface`, `protocol`) within documentation comments as actual code declarations. For example, a doc comment containing:

```
/**
 * Example:
 *   interface RCT_EXTERN_MODULE(MyModule, NSObject)
 *   end
 */
```

Was being parsed by doxygen as an actual interface declaration, resulting in malformed output like `interface RCT_EXTERN_MODULE {}` in the API snapshot.

The filter preserves line numbers by replacing comment content with the equivalent number of newlines, ensuring error messages remain accurate.

Differential Revision: D94534964
Summary:
Adds a doxygen input filter (`input_filters/doxygen_strip_comments.py`) that strips block comments from source files before doxygen parses them.

This prevents doxygen from incorrectly parsing Objective-C code examples (like `interface`, `protocol`) within documentation comments as actual code declarations. For example, a doc comment containing:

```
/**
 * Example:
 *   interface RCT_EXTERN_MODULE(MyModule, NSObject)
 *   end
 */
```

Was being parsed by doxygen as an actual interface declaration, resulting in malformed output like `interface RCT_EXTERN_MODULE {}` in the API snapshot.

## Changes

1. **Input Filter**: Added `doxygen_strip_comments.py` that replaces block comments with equivalent newlines to preserve line numbers.

2. **Fixed Empty Snapshots**: Fixed the `__main__.py` to properly pass the `${DOXYGEN_INPUT_FILTER}` placeholder value to doxygen config, which was causing empty snapshot generation.

3. **Normalized Pointer Spacing**: Added `normalize_pointer_spacing()` function to normalize doxygen's output:
   - `NSString *` → `NSString*`
   - `int &` → `int&`
   - `T &&` → `T&&`

4. **Added Snapshot Test**: Created `should_not_parse_interface_from_doc_comment` test case demonstrating the issue.

Differential Revision: D94538938
coado added a commit to coado/react-native that referenced this pull request Mar 5, 2026
)

Summary:
Pull Request resolved: facebook#55901

Fixes inconsistent spacing around pointer (`*`) and reference (`&`, `&&`) symbols in the parser output.

Doxygen outputs types with a space before `*` and `&` (e.g., `NSString *`), which is inconsistent. This diff adds `normalize_pointer_spacing()` to standardize the output:

- `NSString *` → `NSString*`
- `int &` → `int&`
- `T &&` → `T&&`
- For function arguments: `NSString *name` → `NSString* name`

## Changes

1. Added `normalize_pointer_spacing()` function in `text_resolution.py`
2. Applied normalization in `resolve_ref_text_name()` and `resolve_linked_text_name()`
3. Applied normalization to block property argsstrings in `builders.py`
4. Updated all affected snapshot files to use normalized spacing

Changelog:
[Internal]

Reviewed By: cortinico

Differential Revision: D95078214
@coado coado force-pushed the export-D95078214 branch from 5b7135f to 40b7230 Compare March 5, 2026 10:22
)

Summary:
Pull Request resolved: facebook#55901

Fixes inconsistent spacing around pointer (`*`) and reference (`&`, `&&`) symbols in the parser output.

Doxygen outputs types with a space before `*` and `&` (e.g., `NSString *`), which is inconsistent. This diff adds `normalize_pointer_spacing()` to standardize the output:

- `NSString *` → `NSString*`
- `int &` → `int&`
- `T &&` → `T&&`
- For function arguments: `NSString *name` → `NSString* name`

## Changes

1. Added `normalize_pointer_spacing()` function in `text_resolution.py`
2. Applied normalization in `resolve_ref_text_name()` and `resolve_linked_text_name()`
3. Applied normalization to block property argsstrings in `builders.py`
4. Updated all affected snapshot files to use normalized spacing

Changelog:
[Internal]

Reviewed By: cortinico

Differential Revision: D95078214
@coado coado force-pushed the export-D95078214 branch from 40b7230 to c5424cd Compare March 5, 2026 10:29
@meta-codesync meta-codesync bot closed this in f2ea073 Mar 5, 2026
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 5, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 5, 2026

This pull request has been merged in f2ea073.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook p: Software Mansion Partner: Software Mansion Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants