Skip to content

Commit 3773386

Browse files
committed
Add generated docs check and generated headers target, and remove FIREBASE_NAMESPACE macro. (#499)
Run Doxygen as part of the common PR checks. This will fail if Doxygen returns any errors or warnings. This could include missing or misspelled parameters, missing method documentation, or other issues. Because we don't perform a full header scrub here, the Doxygen config file uses _sed_ to remove everything between `<SWIG>` and `</SWIG>`. We could potentially perform a second pass with SWIG enabled, or do this in the Unity repo in the future, to check C# documentation. This PR also fixes some of those same issues present in our build right now, including a few missing method docs in Firestore, a missing parameter in Database, and bad cross-references in a few different places, including all references to App and Future, which were failing due to the FIREBASE_NAMESPACE macro which is no longer needed. _This PR removes all usages of the FIREBASE_NAMESPACE macro._ Note that because we also run Doxygen on some generated headers, this PR includes a new CMake target to build those headers without building the entire build. Any future generated headers should be added to that target. This PR also contains a small change to print the list of files requiring code formatting directly to the GitHub workflow log.
1 parent 63e56c2 commit 3773386

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+340
-460
lines changed

.github/workflows/checks.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
run: git fetch origin main
3232
- name: Detect Formatting Changes
3333
shell: bash
34-
run: python3 scripts/format_code.py -git_diff -noformat_file -verbose
34+
run: python3 scripts/format_code.py -git_diff -noformat_file -verbose -github_log
3535

3636
check_integration_test_labels:
3737
# This check fails if integration tests are queued, in progress, or failed.
@@ -42,4 +42,37 @@ jobs:
4242
none_of: "${{ env.statusLabelInProgress }},${{ env.statusLabelFailed }},${{ env.triggerLabelFull }},${{ env.triggerLabelQuick }}"
4343
repo_token: ${{ github.token }}
4444

45-
45+
generated_docs_check:
46+
# This check succeeds if Doxygen documentation generates without errors.
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v2
50+
with:
51+
submodules: false
52+
- name: Setup python
53+
uses: actions/setup-python@v2
54+
with:
55+
python-version: 3.7
56+
- name: Install prerequisites
57+
run: python scripts/gha/install_prereqs_desktop.py
58+
- name: Generate headers
59+
run: |
60+
mkdir build
61+
cd build
62+
cmake ..
63+
cmake --build . --target FIREBASE_GENERATED_HEADERS
64+
- name: Install doxygen
65+
run: sudo apt-get install doxygen
66+
- name: Run doxygen
67+
run: |
68+
cp docs/Doxyfile /tmp/Doxyfile
69+
echo INPUT = $(find */src/include/firebase/ build/generated/ -name '*.h') >> /tmp/Doxyfile
70+
doxygen /tmp/Doxyfile 2>doxygen_errors.txt
71+
cat doxygen_errors.txt
72+
- name: Check output
73+
run: |
74+
if grep -Eq "error:|warning:" doxygen_errors.txt; then
75+
# Grep for warnings and print them out (replacing \n with %0A for github log)
76+
grep -E "error:|warning:|^ parameter" doxygen_errors.txt | sed ':a;N;$!ba;s/\n/%0A/g' | sed 's/^/::error ::DOXYGEN ERRORS: %0A/'
77+
exit 1
78+
fi

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,12 @@ if(FIREBASE_CPP_BUILD_TESTS)
529529
add_subdirectory(testing)
530530
endif()
531531

532+
# Custom target containing all generated headers, used to generate docs only.
533+
add_custom_target(FIREBASE_GENERATED_HEADERS)
534+
532535
if(NOT FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD)
533536
add_subdirectory(app)
537+
add_dependencies(FIREBASE_GENERATED_HEADERS FIREBASE_APP_GENERATED_HEADERS)
534538
else()
535539
# Add firebase_app as a target on the previously built app.
536540
add_library(firebase_app STATIC IMPORTED GLOBAL)
@@ -552,6 +556,7 @@ if (FIREBASE_INCLUDE_ADMOB)
552556
endif()
553557
if (FIREBASE_INCLUDE_ANALYTICS)
554558
add_subdirectory(analytics)
559+
add_dependencies(FIREBASE_GENERATED_HEADERS FIREBASE_ANALYTICS_GENERATED_HEADERS)
555560
endif()
556561
if (FIREBASE_INCLUDE_AUTH)
557562
add_subdirectory(auth)
@@ -564,6 +569,7 @@ if (FIREBASE_INCLUDE_DYNAMIC_LINKS)
564569
endif()
565570
if (FIREBASE_INCLUDE_FIRESTORE)
566571
add_subdirectory(firestore)
572+
add_dependencies(FIREBASE_GENERATED_HEADERS FIREBASE_FIRESTORE_GENERATED_HEADERS)
567573
endif()
568574
if (FIREBASE_INCLUDE_FUNCTIONS)
569575
add_subdirectory(functions)

analytics/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ generate_analytics_header(
5050
"${CMAKE_CURRENT_LIST_DIR}/ios_headers/FIRUserPropertyNames.h"
5151
"${user_property_names_header}"
5252
)
53+
add_custom_target(FIREBASE_ANALYTICS_GENERATED_HEADERS
54+
DEPENDS
55+
"${user_property_names_header}"
56+
"${parameter_names_header}"
57+
"${event_names_header}"
58+
)
5359

5460
# Common source files used by all platforms
5561
set(common_SRCS

app/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ binary_to_array("invites_resources"
4343
# Generate version.h
4444
set(version_header_dir ${FIREBASE_GEN_FILE_DIR}/app/src/include/firebase)
4545
set(version_header ${version_header_dir}/version.h)
46+
add_custom_target(FIREBASE_APP_GENERATED_HEADERS DEPENDS "${version_header}")
4647
file(MAKE_DIRECTORY ${version_header_dir})
4748
add_custom_command(
4849
OUTPUT ${version_header}

app/memory/atomic.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
#include <atomic>
2323
#endif // !defined(_STLPORT_VERSION)
2424

25-
#if !defined(FIREBASE_NAMESPACE)
26-
#define FIREBASE_NAMESPACE firebase
27-
#endif
28-
29-
namespace FIREBASE_NAMESPACE {
25+
namespace firebase {
3026
namespace compat {
3127

3228
// For now only the types below are allowed to be atomic. Feel free to add more
@@ -149,5 +145,5 @@ T Atomic<T>::fetch_sub(T arg) {
149145

150146
} // namespace compat
151147
// NOLINTNEXTLINE - allow namespace overridden
152-
} // namespace FIREBASE_NAMESPACE
148+
} // namespace firebase
153149
#endif // FIREBASE_APP_CLIENT_CPP_MEMORY_ATOMIC_H_

app/memory/shared_ptr.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
#include "app/meta/move.h"
2424
#include "app/src/include/firebase/internal/type_traits.h"
2525

26-
#if !defined(FIREBASE_NAMESPACE)
27-
#define FIREBASE_NAMESPACE firebase
28-
#endif
29-
30-
namespace FIREBASE_NAMESPACE {
26+
namespace firebase {
3127

3228
namespace internal {
3329

@@ -49,7 +45,7 @@ class ControlBlock {
4945
uint64_t ref_count() const { return ref_count_.load(); }
5046

5147
private:
52-
::FIREBASE_NAMESPACE::compat::Atomic<uint64_t> ref_count_;
48+
::firebase::compat::Atomic<uint64_t> ref_count_;
5349
};
5450

5551
} // namespace internal
@@ -229,5 +225,5 @@ void SharedPtr<T>::Clear() {
229225
ctrl_ = nullptr;
230226
}
231227
// NOLINTNEXTLINE - allow namespace overridden
232-
} // namespace FIREBASE_NAMESPACE
228+
} // namespace firebase
233229
#endif // FIREBASE_APP_CLIENT_CPP_MEMORY_SHARED_PTR_H_

app/memory/unique_ptr.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020
#include "app/meta/move.h"
2121
#include "app/src/include/firebase/internal/type_traits.h"
2222

23-
#if !defined(FIREBASE_NAMESPACE)
24-
#define FIREBASE_NAMESPACE firebase
25-
#endif
26-
27-
namespace FIREBASE_NAMESPACE {
23+
namespace firebase {
2824

2925
// Smart pointer that owns another object and releases it when destroyed.
3026
//
@@ -123,6 +119,6 @@ UniquePtr<T> MakeUnique(Args&&... args) {
123119
}
124120

125121
// NOLINTNEXTLINE - allow namespace overridden
126-
} // namespace FIREBASE_NAMESPACE
122+
} // namespace firebase
127123

128124
#endif // FIREBASE_APP_CLIENT_CPP_MEMORY_UNIQUE_PTR_H_

app/meta/move.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919

2020
#include "app/src/include/firebase/internal/type_traits.h"
2121

22-
#if !defined(FIREBASE_NAMESPACE)
23-
#define FIREBASE_NAMESPACE firebase
24-
#endif
25-
26-
namespace FIREBASE_NAMESPACE {
22+
namespace firebase {
2723

2824
// Casts the argument to an rvalue-reference.
2925
//
@@ -51,6 +47,6 @@ inline T&& Forward(typename remove_reference<T>::type&& arg) {
5147
}
5248

5349
// NOLINTNEXTLINE - allow namespace overridden
54-
} // namespace FIREBASE_NAMESPACE
50+
} // namespace firebase
5551

5652
#endif // FIREBASE_APP_CLIENT_CPP_META_MOVE_H_

app/src/app_common.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@
4040
#define strtok_r strtok_s
4141
#endif // FIREBASE_PLATFORM_WINDOWS
4242

43-
#if !defined(FIREBASE_NAMESPACE)
44-
#define FIREBASE_NAMESPACE firebase
45-
#endif
46-
47-
namespace FIREBASE_NAMESPACE {
43+
namespace firebase {
4844

4945
#ifdef FIREBASE_LINUX_BUILD_CONFIG_STRING
5046
void CheckCompilerString(const char* input) {
@@ -487,4 +483,4 @@ Logger* FindAppLoggerByName(const char* name) {
487483

488484
} // namespace app_common
489485
// NOLINTNEXTLINE - allow namespace overridden
490-
} // namespace FIREBASE_NAMESPACE
486+
} // namespace firebase

app/src/app_common.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@
2525
#include "app/src/include/firebase/app.h"
2626
#include "app/src/logger.h"
2727

28-
#if !defined(FIREBASE_NAMESPACE)
29-
#define FIREBASE_NAMESPACE firebase
30-
#endif
31-
32-
namespace FIREBASE_NAMESPACE {
28+
namespace firebase {
3329

3430
// Default app name.
3531
extern const char* const kDefaultAppName;
@@ -102,6 +98,6 @@ Logger* FindAppLoggerByName(const char* name);
10298

10399
} // namespace app_common
104100
// NOLINTNEXTLINE - allow namespace overridden
105-
} // namespace FIREBASE_NAMESPACE
101+
} // namespace firebase
106102

107103
#endif // FIREBASE_APP_CLIENT_CPP_SRC_APP_COMMON_H_

app/src/app_identifier.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "app/src/include/firebase/app.h"
2424

25-
namespace FIREBASE_NAMESPACE {
25+
namespace firebase {
2626
namespace internal {
2727

2828
// Generate a unique identifier from the Firebase app options.
@@ -42,4 +42,4 @@ std::string CreateAppIdentifierFromOptions(const AppOptions& options) {
4242
}
4343

4444
} // namespace internal
45-
} // namespace FIREBASE_NAMESPACE
45+
} // namespace firebase

app/src/app_identifier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121

2222
#include "app/src/include/firebase/app.h"
2323

24-
namespace FIREBASE_NAMESPACE {
24+
namespace firebase {
2525
namespace internal {
2626

2727
// Generate a unique identifier from the Firebase app options.
2828
std::string CreateAppIdentifierFromOptions(const AppOptions& options);
2929

3030
} // namespace internal
31-
} // namespace FIREBASE_NAMESPACE
31+
} // namespace firebase
3232

3333
#endif // FIREBASE_APP_CLIENT_CPP_SRC_APP_IDENTIFIER_H_

app/src/assert.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
__FILE__ "(" FIREBASE_EXPAND_STRINGIFY(__LINE__) "): "
3333
#endif // defined(NDEBUG)
3434

35-
#if !defined(FIREBASE_NAMESPACE)
36-
#define FIREBASE_NAMESPACE firebase
37-
#endif
38-
3935
// FIREBASE_ASSERT_* macros are not compiled out of release builds. They should
4036
// be used for assertions that need to be propagated to end-users of SDKs.
4137
// FIREBASE_DEV_ASSERT_* macros are compiled out of release builds, similar to
@@ -47,7 +43,7 @@
4743
#define FIREBASE_ASSERT_WITH_EXPRESSION(condition, expression) \
4844
do { \
4945
if (!(condition)) { \
50-
FIREBASE_NAMESPACE::LogAssert( \
46+
firebase::LogAssert( \
5147
FIREBASE_ASSERT_MESSAGE_PREFIX FIREBASE_EXPAND_STRINGIFY( \
5248
expression)); \
5349
} \
@@ -113,10 +109,10 @@
113109
#define FIREBASE_ASSERT_MESSAGE_WITH_EXPRESSION(condition, expression, ...) \
114110
do { \
115111
if (!(condition)) { \
116-
FIREBASE_NAMESPACE::LogError( \
112+
firebase::LogError( \
117113
FIREBASE_ASSERT_MESSAGE_PREFIX FIREBASE_EXPAND_STRINGIFY( \
118114
expression)); \
119-
FIREBASE_NAMESPACE::LogAssert(__VA_ARGS__); \
115+
firebase::LogAssert(__VA_ARGS__); \
120116
} \
121117
} while (false)
122118

app/src/callback.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@
2424
#include "app/src/semaphore.h"
2525
#include "app/src/thread.h"
2626

27-
#if !defined(FIREBASE_NAMESPACE)
28-
#define FIREBASE_NAMESPACE firebase
29-
#endif
30-
31-
namespace FIREBASE_NAMESPACE {
27+
namespace firebase {
3228
namespace callback {
3329

3430
class CallbackEntry;
@@ -339,4 +335,4 @@ void PollCallbacks() {
339335

340336
} // namespace callback
341337
// NOLINTNEXTLINE - allow namespace overridden
342-
} // namespace FIREBASE_NAMESPACE
338+
} // namespace firebase

app/src/callback.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
#include <functional>
2525
#endif
2626

27-
#if !defined(FIREBASE_NAMESPACE)
28-
#define FIREBASE_NAMESPACE firebase
29-
#endif
3027

3128
/// @cond FIREBASE_APP_INTERNAL
3229

@@ -36,7 +33,7 @@
3633

3734
#include <string>
3835

39-
namespace FIREBASE_NAMESPACE {
36+
namespace firebase {
4037
namespace callback {
4138

4239
/// Initialize the Callback system.
@@ -397,7 +394,7 @@ void PollCallbacks();
397394

398395
} // namespace callback
399396
// NOLINTNEXTLINE - allow namespace overridden
400-
} // namespace FIREBASE_NAMESPACE
397+
} // namespace firebase
401398
/// @endcond
402399

403400
#endif // FIREBASE_APP_CLIENT_CPP_SRC_CALLBACK_H_

app/src/cleanup_notifier.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020

2121
#include <algorithm>
2222

23-
#if !defined(FIREBASE_NAMESPACE)
24-
#define FIREBASE_NAMESPACE firebase
25-
#endif
26-
27-
namespace FIREBASE_NAMESPACE {
23+
namespace firebase {
2824

2925
Mutex *CleanupNotifier::cleanup_notifiers_by_owner_mutex_ = new Mutex();
3026
std::map<void *, CleanupNotifier *>
@@ -121,4 +117,4 @@ CleanupNotifier *CleanupNotifier::FindByOwner(void *owner) {
121117
}
122118

123119
// NOLINTNEXTLINE - allow namespace overridden
124-
} // namespace FIREBASE_NAMESPACE
120+
} // namespace firebase

app/src/cleanup_notifier.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222

2323
#include "app/src/mutex.h"
2424

25-
#if !defined(FIREBASE_NAMESPACE)
26-
#define FIREBASE_NAMESPACE firebase
27-
#endif
28-
29-
namespace FIREBASE_NAMESPACE {
25+
namespace firebase {
3026

3127
// If an object gives out other objects that refer back to it, the original
3228
// object can use this CleanupNotifier class to invalidate any other objects it
@@ -131,6 +127,6 @@ class TypedCleanupNotifier {
131127
};
132128

133129
// NOLINTNEXTLINE - allow namespace overridden
134-
} // namespace FIREBASE_NAMESPACE
130+
} // namespace firebase
135131

136132
#endif // FIREBASE_APP_CLIENT_CPP_SRC_CLEANUP_NOTIFIER_H_

0 commit comments

Comments
 (0)