I bring this up now and then, but I feel that we need to figure out a proper solution for this. We are continuing to rack up more and more documentation where there are interfaces that are based on other interfaces, and we are either cross-linking, leading to some confusion when the parent interface is, say, read-only while the derived interface is not (like DOMPointReadOnly
being the base class for DOMPoint
). If you reuse DOMPointReadOnly
content for DOMPoint
, the text about being read-only is misleading (along with, of course, any uses of the base interface’s name).
I thought about creating a macro that would insert the name of the interface you’re reading about, but the macro is already run when the content is inserted into the page, so embedded content would not pick up the inherited class’s name still. Then I had a bit of an idea.
What about something like this: we create a new {{InheritPage}}
macro that would embed the content from the specified page, but would do it indirectly. Any tokens shown below are just placeholders.
- Collect the output from the existing
{{page}}
macro into a variable. - Find
<code>
blocks that have the classbase-interface
and replace the interface name within (the text before the first period) with the name of the interface portion of the current page’s slug. If the immediate parent or immediate child of the<code>
block is an<a>
element, correct itshref
, replacing the base interface name with the current interface’s name. - Find any blocks with the class
base-interface-only
and remove them entirely. - Return the resulting transformed output.
This would let us craft API documentation using special classes to allow derived classes to transclude the content and have the text match the derived class’s names, as well as leave out any text that’s specific to the base class.
The macro could also offer the ability to automatically link to the corresponding base class and/or member of the base class.
This could all be done with no new code on the platform side, other than the addition of support for a couple of new classes.
This seems like it could be an interesting experiment to me.
Sheppy