public static void startTemplate(PyDocstringGenerator generator) {
    Preconditions.checkNotNull(generator.getDocStringOwner(), "For this action docstring owner must be supplied");
    final PyStringLiteralExpression docStringExpression = (PyStringLiteralExpression)generator.getDocStringExpression();
    assert docStringExpression != null;

    final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(docStringExpression);

    if (generator.getAddedParams().size() > 1) {
      throw new IllegalArgumentException("TemplateBuilder can be created only for one parameter");
    }

    final PyDocstringGenerator.DocstringParam paramToEdit = generator.getParamToEdit();
    final DocStringFormat format = generator.getDocStringFormat();
    if (format == DocStringFormat.PLAIN) {
      return;
    }
    final StructuredDocString parsed = DocStringUtil.parseDocString(format, docStringExpression);
    final Substring substring;
    if (paramToEdit.isReturnValue()) {
      substring = parsed.getReturnTypeSubstring();
    }
    else {
      final String paramName = paramToEdit.getName();
      substring = parsed.getParamTypeSubstring(paramName);
    }
    if (substring == null) {
      return;
    }
    builder.replaceRange(substring.getTextRange(), PyDocstringGenerator.getDefaultType(generator.getParamToEdit()));

    final VirtualFile virtualFile = generator.getDocStringOwner().getContainingFile().getVirtualFile();
    if (virtualFile == null) return;
    final Editor targetEditor = PsiEditorUtil.findEditor(generator.getDocStringOwner());
    if (targetEditor != null) {
      PyUtil.updateDocumentUnblockedAndCommitted(generator.getDocStringOwner(), document -> {
        builder.run(targetEditor, true);
        return null;
      });

    }
  }
public static void startTemplate(PyDocstringGenerator generator)