diff --git a/js/flatbuffers.js b/js/flatbuffers.js index 6c3d15cc8..511c9a216 100644 --- a/js/flatbuffers.js +++ b/js/flatbuffers.js @@ -2,6 +2,10 @@ /// @addtogroup flatbuffers_javascript_api /// @{ /// @cond FLATBUFFERS_INTERNAL +/** + * @const + * @namespace + */ var flatbuffers = {}; /** diff --git a/src/idl_gen_js.cpp b/src/idl_gen_js.cpp index 32a06f1ef..d7c913e50 100644 --- a/src/idl_gen_js.cpp +++ b/src/idl_gen_js.cpp @@ -110,7 +110,7 @@ class JsGenerator : public BaseGenerator { std::string &exports = *exports_ptr; for (auto it = sorted_namespaces.begin(); it != sorted_namespaces.end(); it++) { - code += "/**\n * @const\n*/\n"; + code += "/**\n * @const\n * @namespace\n */\n"; if (it->find('.') == std::string::npos) { code += "var "; exports += "this." + *it + " = " + *it + ";\n"; diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs index e131ac8c2..1e8a270d8 100644 Binary files a/tests/monster_test.bfbs and b/tests/monster_test.bfbs differ diff --git a/tests/monster_test_generated.js b/tests/monster_test_generated.js index f67e84802..7c4c28f82 100644 --- a/tests/monster_test_generated.js +++ b/tests/monster_test_generated.js @@ -2,22 +2,26 @@ /** * @const -*/ + * @namespace + */ var MyGame = MyGame || {}; /** * @const -*/ + * @namespace + */ MyGame.Example = MyGame.Example || {}; /** * @const -*/ + * @namespace + */ MyGame.Example2 = MyGame.Example2 || {}; /** * @const -*/ + * @namespace + */ MyGame.OtherNameSpace = MyGame.OtherNameSpace || {}; /** diff --git a/tests/namespace_test/namespace_test1_generated.js b/tests/namespace_test/namespace_test1_generated.js index 769b523e3..e6390567f 100644 --- a/tests/namespace_test/namespace_test1_generated.js +++ b/tests/namespace_test/namespace_test1_generated.js @@ -2,12 +2,14 @@ /** * @const -*/ + * @namespace + */ var NamespaceA = NamespaceA || {}; /** * @const -*/ + * @namespace + */ NamespaceA.NamespaceB = NamespaceA.NamespaceB || {}; /** diff --git a/tests/namespace_test/namespace_test2_generated.js b/tests/namespace_test/namespace_test2_generated.js index c1953705e..f76d5a95a 100644 --- a/tests/namespace_test/namespace_test2_generated.js +++ b/tests/namespace_test/namespace_test2_generated.js @@ -2,17 +2,20 @@ /** * @const -*/ + * @namespace + */ var NamespaceA = NamespaceA || {}; /** * @const -*/ + * @namespace + */ NamespaceA.NamespaceB = NamespaceA.NamespaceB || {}; /** * @const -*/ + * @namespace + */ var NamespaceC = NamespaceC || {}; /**