-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use @namespace
in addition to @enum
for jsdoc
#10259
Comments
We need to be careful here. For things in the public API, making them a namespace means they are not enums, they are namespaces. This matters a lot when generating TypeScript bindings. However, if we are globbing functions on to enums, they aren't enums either. I did a bunch of work to make sure we made enums actually enums as part of the initial TS works: #8878 This included removing functions being globbed onto them and changing them to actually use @enum in JSDoc. CesiumJS should have a clear policy for all of this, what we have may be out of date. If the goal is to put them into their own page, we could probably do that at the JSDoc template level. What does this do to TS output? |
Ahh good catch. When I do
The goals are:
Are there any examples of well behaved public enums that have static functions? Any workarounds you found during the TS cleanup? It seems like an increasingly common pattern in the codebase. For example, it's nice to be able to do
|
The fundamental issue here is that an enums don't exist in JavaScript (because types don't exist). I don't know of any strongly typed language that lets you define an enum that also has methods on it (static or not). So we should not every augment enums with function definitions in Cesium is we want to cleanly interop with strongly typed languages, like TypeScript. I believe the documentation side can be handled entirely in JSDoc. I don't know the direct solution off the top of my head, but JSDoc gives you a lot of control over how the doc is generated. |
Old
When using the
@enum
tag by itself it puts the documentation in the global section and omits static functions on the enum. It's cluttered and missing information.New
By adding the

@namespace
tag it creates a new page for the enum and show the static functions:Here's how the fix would look for
VoxelShapeType
:One way to go about fixing this for all enums is to:
npm run generateDocumentation
http://localhost:8080/Build/Documentation/global.html
@namespace
to every enum until there are no more in the global sectionAlso, update https://github.com/CesiumGS/cesium/tree/main/Documentation/Contributors/DocumentationGuide with information about enums / namespace.
The text was updated successfully, but these errors were encountered: