handler: function()

in tools/api-builder/links-package/inline-tag-defs/example.js [18:39]


    handler: function(doc, tagName, tagDescription) {

      var tagArgs = parseArgString(tagDescription);
      var unnamedArgs = tagArgs._;
      var relativePath = unnamedArgs[0];
      var mixinFilePath = path.join('_api', relativePath);
      var region = tagArgs.region || (unnamedArgs.length > 1 ?  unnamedArgs[1] : null);
      var title = tagArgs.title || (unnamedArgs.length > 2 ? unnamedArgs[2] : null );
      // TODO: not yet implemented here
      var stylePattern = tagArgs.stylePattern;

      // check if fragment file actually exists.
      var fragFileName = getApiFragmentFileName(relativePath, region);
      if ( !fs.existsSync(fragFileName)) {
        log.warn(createDocMessage('Invalid example (unable to locate fragment file: ' + quote(fragFileName) + ")", doc));
      }

      var comma = ', ';
      // the '+' character is a jade thing for mixins http://jade-lang.com/reference/mixins/
      var res = [ "+makeExample(", quote(mixinFilePath), comma, region ? quote(region) : 'null', comma, title ? quote(title) : 'null', ")" ].join('');
      return res;
    }