@gravityforms/gulp-tasks
Version:
Configurable Gulp tasks for use in Gravity Forms projects.
47 lines (34 loc) • 1 kB
JavaScript
const { Token } = require( './token' );
const { render } = require( '../../renderers/as-definition-list' );
class details extends Token {
typeText = 'details';
constructor( text ) {
super( text );
// Add more tags as needed to add them to the details definition list
this.tagNames = [ '@since', '@deprecated' ];
}
tokenCondition( text ) {
return this.tagNames.includes( text.trim().split( ' ' )[0] );
}
endCondition( text ) {
const trimmedText = text.trim();
// End if an empty line is encountered
if ( trimmedText === '' ) {
return true;
}
const firstWord = trimmedText.split( ' ' )[0];
// Continue collecting if it's one of the tagNames
if ( this.tagNames.includes( firstWord ) ) {
return false;
}
// Stop collecting if we hit a different tag or the end of the comment block
if ( firstWord.startsWith( '@' ) ) {
return true;
}
return false;
}
getContent() {
return render( this.lines, this.tagNames );
}
}
module.exports = { details };