o3d/documentation/jsdoc-toolkit-templates/publish.js
/**
 * Converts a reference to a single JSDOC type specification to an html link.
 * @param {string} place Use to print error message if type not found.
 * @param {string} str to linkify.
 * @return {string} linkified string.
 */
Converts a reference to a single JSDOC type specification to an html link.
@param {string} place Use to print error message if type not found.
@param {string} str to linkify.
@return {string} linkified string.
Converts a reference to a single JSDOC type specification to an html link . @param { string } place Use to print error message if type not found . @param { string } str to linkify . @return { string } linkified string .
function linkifySingleType(place, type) {
  var not = '';
  var equals = '';
  if (type[0] == '!') {
    not = '!'
    type = type.substring(1);
  }
  if (endsWith(type, '=')) {
    equals = '=';
    type = type.substring(0, type.length - 1);
  }
  var link = type;
  if (startsWith(type, 'Array.<')) {
    var closingAngle = getIndexOfClosingCharacter(type, 6);
    if (closingAngle < 0) {
      generatePlaceError(place, 'Unmatched "<" in Array type : ' + type);
    } else {
      link = 'Array.&lt;' +
        linkifySingleType(place, type.substring(7, closingAngle)) + '>';
    }
  } else if (startsWith(type, 'function(')) {
    var closingParen = getIndexOfClosingCharacter(type, 8);
    if (closingParen < 0) {
      generatePlaceError(place, 'Unmatched "(" in function type : ' + type);
    } else {
      var end = type.substring(closingParen + 1);
      if (!startsWith(end, ': ')) {
        generatePlaceError(place,
            'Malformed return specification on function. Must be' +
            ' "function(args): type" including the space after the colon.');
      } else {
        var output = '';
        var argsStr = type.substring(9, closingParen);
        if (argsStr) {
          var args = argsStr.split(/ *, */);
          for (var ii = 0; ii < args.length; ++ii) {
            if (ii > 0) {
              output += ', ';
            }
            output += linkifyTypeSpec(place, args[ii]);
          }
        }
        link = 'function(' + output + '): ' +
               linkifyTypeSpec(place, end.substring(2));
      }
    }
  } else if (type.indexOf(':') >= 0) { 
    if (type.indexOf('::') >= 0) { 
      generatePlaceError(place,
                         'CPP "::" scope operator found for type "' + type +
                         '" must be Javascript "." scope operator.');
    } else {
      var elements = type.split(/\s*,\s*/);
      var output = '{';
      for (var ii = 0; ii < elements.length; ++ii) {
        if (ii > 0) {
          output += ', ';
        }
        var element = elements[ii];
        var colon = element.indexOf(': ');
        if (colon < 0) {
          generatePlaceError(place,
                             'Malformed record specification. Format must be ' +
                             '{id1: type1, id2: type2, ...}.');
          output += element;
        } else {
          var name = element.substring(0, colon);
          var subType = element.substring(colon + 2);
          output += name + ':&nbsp;' + linkifyTypeSpec(place, subType)
        }
      }
      link = output + '}';
    }
  } else {
    var symbol = getSymbol(type);
    if (symbol) {
      link = '<a class="el" href="' + getLinkToSymbol(symbol) + '">' +
          type + '</a>';
    } else {
      var period = type.lastIndexOf('.');
      if (period >= 0 && type != '...') {
        var subType = type.substring(0, period);
        symbol = getSymbol(subType);
        if (symbol) {
          var field = type.substring(period + 1);
          link = '<a class="el" href="' + getLinkToSymbol(symbol) + '#' +
              field + '">' +  type + '</a>';
        } else {
          if (startsWith(type, 'o3d.')) {
            reportUnknownType(place, type);
            link = '<a class="el" href="../classo3d_1_1_' +
                camelCaseToUnderscore(type.substring(4)) + '.html">' +
                type + '</a>';
          } else {
            if (subType[0] == '?') {
              subType = subType.substring(1);
            }
            if (!g_validJSDOCTypes[subType]) {
              reportUnknownType(place, type);
            }
          }
        }
      }
    }
  }
  return not + link + equals;
}
function linkifySingleType ( place , type ) { var not = '' ; var equals = '' ; if ( type [ 0 ] == '!' ) { not = '!' type = type . substring ( 1 ) ; } if ( endsWith ( type , '=' ) ) { equals = '=' ; type = type . substring ( 0 , type . length - 1 ) ; } var link = type ; if ( startsWith ( type , 'Array.<' ) ) { var closingAngle = getIndexOfClosingCharacter ( type , 6 ) ; if ( closingAngle < 0 ) { generatePlaceError ( place , 'Unmatched "<" in Array type : ' + type ) ; } else { link = 'Array.&lt;' + linkifySingleType ( place , type . substring ( 7 , closingAngle ) ) + '>' ; } } else if ( startsWith ( type , 'function(' ) ) { var closingParen = getIndexOfClosingCharacter ( type , 8 ) ; if ( closingParen < 0 ) { generatePlaceError ( place , 'Unmatched "(" in function type : ' + type ) ; } else { var end = type . substring ( closingParen + 1 ) ; if ( ! startsWith ( end , ': ' ) ) { generatePlaceError ( place , 'Malformed return specification on function. Must be' + ' "function(args): type" including the space after the colon.' ) ; } else { var output = '' ; var argsStr = type . substring ( 9 , closingParen ) ; if ( argsStr ) { var args = argsStr . split ( /  *, * / ) ; for ( var ii = 0 ; ii < args . length ; ++ ii ) { if ( ii > 0 ) { output += ', ' ; } output += linkifyTypeSpec ( place , args [ ii ] ) ; } } link = 'function(' + output + '): ' + linkifyTypeSpec ( place , end . substring ( 2 ) ) ; } } } else if ( type . indexOf ( ':' ) >= 0 ) { if ( type . indexOf ( '::' ) >= 0 ) { generatePlaceError ( place , 'CPP "::" scope operator found for type "' + type + '" must be Javascript "." scope operator.' ) ; } else { var elements = type . split ( / \s*,\s* / ) ; var output = '{' ; for ( var ii = 0 ; ii < elements . length ; ++ ii ) { if ( ii > 0 ) { output += ', ' ; } var element = elements [ ii ] ; var colon = element . indexOf ( ': ' ) ; if ( colon < 0 ) { generatePlaceError ( place , 'Malformed record specification. Format must be ' + '{id1: type1, id2: type2, ...}.' ) ; output += element ; } else { var name = element . substring ( 0 , colon ) ; var subType = element . substring ( colon + 2 ) ; output += name + ':&nbsp;' + linkifyTypeSpec ( place , subType ) } } link = output + '}' ; } } else { var symbol = getSymbol ( type ) ; if ( symbol ) { link = '<a class="el" href="' + getLinkToSymbol ( symbol ) + '">' + type + '</a>' ; } else { var period = type . lastIndexOf ( '.' ) ; if ( period >= 0 && type != '...' ) { var subType = type . substring ( 0 , period ) ; symbol = getSymbol ( subType ) ; if ( symbol ) { var field = type . substring ( period + 1 ) ; link = '<a class="el" href="' + getLinkToSymbol ( symbol ) + '#' + field + '">' + type + '</a>' ; } else { if ( startsWith ( type , 'o3d.' ) ) { reportUnknownType ( place , type ) ; link = '<a class="el" href="../classo3d_1_1_' + camelCaseToUnderscore ( type . substring ( 4 ) ) + '.html">' + type + '</a>' ; } else { if ( subType [ 0 ] == '?' ) { subType = subType . substring ( 1 ) ; } if ( ! g_validJSDOCTypes [ subType ] ) { reportUnknownType ( place , type ) ; } } } } } } return not + link + equals ; }
Converts a reference to a single JSDOC type specification to an html link.
Converts a reference to a single JSDOC type specification to an html link .
// Remove ! if it exists. // Check for array wrapper. // check for records. // check for CPP scope // See if the symbol is a property or field. // TODO(gman): remove this hack, make nixysa generate JSDOC js //     files instead of C++ headers and pass those into //     jsdoctoolkit.