Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions scripts/cxx-api/parser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,31 +87,32 @@ def build_snapshot_for_view(
definitions=definitions,
)

print("Running Doxygen")

# If there is already a doxygen output directory, delete it
if os.path.exists(os.path.join(react_native_dir, "api")):
print("Deleting existing output directory")
subprocess.run(["rm", "-rf", os.path.join(react_native_dir, "api")])

print("Running Doxygen")

# Run doxygen with the config file
doxygen_bin = os.environ.get("DOXYGEN_BIN", "doxygen")
result = subprocess.run(
["doxygen", DOXYGEN_CONFIG_FILE],
[doxygen_bin, DOXYGEN_CONFIG_FILE],
cwd=react_native_dir,
capture_output=True,
text=True,
)

# Delete the Doxygen config file
print("Deleting Doxygen config file")
subprocess.run(["rm", DOXYGEN_CONFIG_FILE], cwd=react_native_dir)

# Check the result
if result.returncode != 0:
print(f"Doxygen finished with error: {result.stderr}")
else:
print("Doxygen finished successfully")

# Delete the Doxygen config file
print("Deleting Doxygen config file")
subprocess.run(["rm", DOXYGEN_CONFIG_FILE], cwd=react_native_dir)

# build snapshot, convert to string, and save to file
snapshot = build_snapshot(os.path.join(react_native_dir, "api", "xml"))
snapshot_string = snapshot.to_string()
Expand Down Expand Up @@ -145,6 +146,14 @@ def main():
)
args = parser.parse_args()

doxygen_bin = os.environ.get("DOXYGEN_BIN", "doxygen")
version_result = subprocess.run(
[doxygen_bin, "--version"],
capture_output=True,
text=True,
)
print(f"Using Doxygen {version_result.stdout.strip()} ({doxygen_bin})")

# Define the path to the react-native directory
react_native_dir = (
os.path.join(get_react_native_dir(), "packages", "react-native")
Expand Down
7 changes: 6 additions & 1 deletion scripts/cxx-api/tests/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ def _assert_text_equal_with_diff(
tc.fail(diff)


def _get_doxygen_bin() -> str:
return os.environ.get("DOXYGEN_BIN", "doxygen")


def _generate_doxygen_api(case_dir_path: str, doxygen_config_path: str) -> None:
"""Run doxygen to generate XML API documentation."""
doxygen_bin = _get_doxygen_bin()
result = subprocess.run(
["doxygen", doxygen_config_path],
[doxygen_bin, doxygen_config_path],
cwd=case_dir_path,
capture_output=True,
text=True,
Expand Down
Loading