docs: def init(name, description, bucket, timeout, memory, stages, requirements,
           function, runtime, config_file, **kwargs):
      """Generate a configuration file."""
      if os.path.exists(config_file):
          raise RuntimeError('Please delete the old version {} if you want to '
                             'reconfigure your project.'.format(config_file))
  
      module, app = function.split(':')
      if not name:
          name = module.replace('_', '-')
      if not re.match('^[a-zA-Z][-a-zA-Z0-9]*$', name):
          raise ValueError('The name {} is invalid, only letters, numbers and '
                           'dashes are allowed.'.format(name))
      if not bucket:
          random_suffix = ''.join(
              random.choice(string.ascii_uppercase + string.digits)
              for n in range(8))
          bucket = '{}-{}'.format(name, random_suffix)
  
      stages = [s.strip() for s in stages.split(',')]
  
      if runtime is None:
          if sys.version_info[0] == 2:  # pragma: no cover
              runtime = 'python2.7'
          else:
              runtime = 'python3.6'
  
      # generate slam.yaml
      template_file = os.path.join(os.path.dirname(__file__),
                                   'templates/slam.yaml')
      with open(template_file) as f:
          template = f.read()
      template = render_template(template, name=name, description=description,
                                 module=module, app=app, bucket=bucket,
                                 timeout=timeout, memory=memory,
                                 requirements=requirements, stages=stages,
                                 devstage=stages[0], runtime=runtime)
      with open(config_file, 'wt') as f:
          f.write(template)
  
      # plugins
      config = _load_config(config_file)
      for name, plugin in plugins.items():
          # write plugin documentation as a comment in config file
          with open(config_file, 'at') as f:
              f.write('\n\n# ' + (plugin.__doc__ or name).replace(
                  '\n', '\n# ') + '\n')
          if hasattr(plugin, 'init'):
              arguments = {k: v for k, v in kwargs.items()
                           if k in getattr(plugin.init, '_argnames', [])}
              plugin_config = plugin.init.func(config=config, **arguments)
              if plugin_config:
                  with open(config_file, 'at') as f:
                      yaml.dump({name: plugin_config}, f,
                                default_flow_style=False)
  
      print('The configuration file for your project has been generated. '
            'Remember to add {} to source control.'.format(config_file))