code: function() {
      this.setColour(120);
      this.appendDummyInput()
          .appendField('name')
          .appendField(new Blockly.FieldTextInput('math_foo'), 'NAME');
      this.appendStatementInput('INPUTS')
          .setCheck('Input')
          .appendField('inputs');
      var dropdown = new Blockly.FieldDropdown([
          ['automatic inputs', 'AUTO'],
          ['external inputs', 'EXT'],
          ['inline inputs', 'INT']]);
      this.appendDummyInput()
          .appendField(dropdown, 'INLINE');
      dropdown = new Blockly.FieldDropdown([
          ['no connections', 'NONE'],
          ['← left output', 'LEFT'],
          ['↕ top+bottom connections', 'BOTH'],
          ['↑ top connection', 'TOP'],
          ['↓ bottom connection', 'BOTTOM']],
          function(option) {
            this.sourceBlock_.updateShape_(option);
          });
      this.appendDummyInput()
          .appendField(dropdown, 'CONNECTIONS');
      this.appendValueInput('COLOUR')
          .setCheck('Colour')
          .appendField('colour');
      this.setTooltip('Build a custom block by plugging\n' +
          'fields, inputs and other blocks here.');
      this.setHelpUrl(
          'https://developers.google.com/blockly/custom-blocks/block-factory');
    }
docs: Base of new block.