3 // We can use .replaceAll since Node.js 15
4 /* eslint-disable es-x/no-string-prototype-replaceall */
7 * JSDoc incorrectly handles dots in 'module' annotations. When the module name includes any dots,
8 * it removes everything up to the last dot. This makes no sense because file names (and MediaWiki
9 * module names) can contain dots. https://github.com/jsdoc/jsdoc/issues/1157
11 * To work around this bug, replace dots with special markers before JSDoc parses the code,
12 * and then replace them back after it has parsed the code.
15 beforeParse: function ( e ) {
16 e.source = e.source.replaceAll( /@(module|exports) .+/g, function ( m ) {
17 return m.replaceAll( '.', '(DOT)' );
21 newDoclet: function ( e ) {
22 for ( const key in e.doclet ) {
23 if ( typeof e.doclet[ key ] === 'string' ) {
24 e.doclet[ key ] = e.doclet[ key ].replaceAll( '(DOT)', '.' );