Documenting typedefs in Web API docs #282
-
Web APIs take or return certain types defined in WebIDL. How does MDN document them? I'm working on Performance API docs and the type DOMHighResTimeStamp is quite an important concept there. However, it seems that typedefs aren't documented on their own page in the MDN Web/API/* reference anymore and so this page should rather be glossary page or so. I'm not yet quite clear where I should put it. See mdn/content#17096 as an example that creates a glossary entry and removes the API page. The browser-compat-data project doesn't include types anymore either, see mdn/browser-compat-data#9930 (that's why we have a broken compat table on DOMHighResTimeStamp). I believe a lot types are documented inline (like MDN does for dictionaries). While that is good in may cases, it might not make sense in all cases. Let's explore WebIDL typedefs. I think there are a few different categories to talk about here: AliasesVery often types are used to create aliases (or groups of types) to indicate that two or more types can be used or will be returned. These groups are invisible to web developers. On MDN, we don't talk about these aliases. And I think it has been a good idea that BCD also removed these. We always list all specific real types instead. See for example https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createPattern where for the image parameter, all canvas images sources are listed and it's not written "CanvasImageSource" that wouldn't necessarily mean anything to a web developer. Examples of these kinds of typedefs:
Ordinary types with meaningSome typedefs are ordinary types, however, they have special meaning and possibly constrains that are worth knowing. I believe that our current thinking is that these should be glossary pages? I think it would be nice to be consistent about them, either in the glossary or in a dedicated section on MDN that talks about them. I think the following typedefs fall into this category:
Data structuresSome types seem to have have defined data structures. If they are simple (for example, an array of specific elements), it seems that we can document them inline without introducing the abstract typedef at all. If they are more complex (see eg. the Costraints typedefs) then I guess they ought to be explained somewhere somehow. There seems to be no guideline about this, though. Documenting them inline might lead to repeatedly explaining their complex structure. I think the following typedefs are examples:
HandlersI think these typedefs are mostly functions and are used a lot (for all events for example). Might be worth have pages for these types? If so, where?
Other types (not yet sorted)
- Float32List
- FormDataEntryValue
- GPUBindingResource
- GPUBufferDynamicOffset
- GPUBufferUsageFlags
- GPUColor
- GPUColorWriteFlags
- GPUComputePassTimestampWrites
- GPUDepthBias
- GPUExtent3D
- GPUFlagsConstant
- GPUIndex32
- GPUIntegerCoordinate
- GPUMapModeFlags
- GPUOrigin2D
- GPUOrigin3D
- GPUPipelineConstantValue
- GPURenderPassTimestampWrites
- GPUSampleMask
- GPUShaderStageFlags
- GPUSignedOffset32
- GPUSize32
- GPUSize64
- GPUStencilValue
- GPUTextureUsageFlags
- GeometryNode
- HTMLOrSVGImageElement
- HTMLOrSVGScriptElement
- HTMLString
- HashAlgorithmIdentifier
- HeadersInit
- ImageBitmapSource
- ImageBufferSource
- Int32List
- LineAndPositionSetting
- MLBufferView
- MLGPUResource
- MLNamedArrayBufferViews
- MLNamedGPUResources
- MLNamedOperands
- MediaProvider
- Megabit
- MessageEventSource
- Millisecond
- NDEFMessageSource
- NamedCurve
- OffscreenRenderingContext
- PasswordCredentialInit
- PerformanceEntryList
- ProfilerResource
- PublicKeyCredentialJSON
- PushMessageDataInit
- RTCRtpTransform
- ReadableStreamController
- ReadableStreamReader
- RenderingContext
- ReportList
- RequestInfo
- RotationMatrixType
- ScriptString
- ScriptURLString
- SmallCryptoKeyID
- StartInDirectory
- TexImageSource
- TrustedType
- URLPatternInput
- UUID
- Uint32List
- UvmEntries
- UvmEntry
- VibratePattern
- XMLHttpRequestBodyInit
- XRWebGLRenderingContext
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
My understanding is that the rule is that:
Looking at a couple of cases:
In this case, if it were me I would be tempted to add a glossary for "Unix epoc time stamp" and perhaps have a guide topic "DOM timestamps" that captured If you keep |
Beta Was this translation helpful? Give feedback.
-
Sounds like y'all have resolved this - I think the above sounds more than resonable 👍 |
Beta Was this translation helpful? Give feedback.
My understanding is that the rule is that: