<commit_before>{ stdenv
, rtpPath ? "share/vim-plugins"
, vim
}:

rec {
  addRtp = path: attrs: derivation:
    derivation // { rtp = "${derivation}/${path}"; } // {
      overrideAttrs = f: buildVimPlugin (attrs // f attrs);
    };

  buildVimPlugin = attrs@{
    name ? "${attrs.pname}-${attrs.version}",
    namePrefix ? "vimplugin-",
    src,
    unpackPhase ? "",
    configurePhase ? "",
    buildPhase ? "",
    preInstall ? "",
    postInstall ? "",
    path ? (builtins.parseDrvName name).name,
    addonInfo ? null,
    ...
  }:
    addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // {
      name = namePrefix + name;

      inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;

      installPhase = ''
        runHook preInstall

        target=$out/${rtpPath}/${path}
        mkdir -p $out/${rtpPath}
        cp -r . $target

        # build help tags
        if [ -d "$target/doc" ]; then
          ${vim}/bin/vim -N -u NONE -i NONE -n -E -s -c "helptags $1/doc" +quit! || echo "docs to build failed"
        fi

        if [ -n "$addonInfo" ]; then
          echo "$addonInfo" > $target/addon-info.json
        fi

        runHook postInstall
      '';
    }));

  buildVimPluginFrom2Nix = attrs: buildVimPlugin ({
    buildPhase = ":";
    configurePhase =":";
  } // attrs);
}<commit_msg>vimUtils.buildVimPlugin: fix helptag generation (#53071)<commit_after>{ stdenv
, rtpPath ? "share/vim-plugins"
, vim
}:

rec {
  addRtp = path: attrs: derivation:
    derivation // { rtp = "${derivation}/${path}"; } // {
      overrideAttrs = f: buildVimPlugin (attrs // f attrs);
    };

  buildVimPlugin = attrs@{
    name ? "${attrs.pname}-${attrs.version}",
    namePrefix ? "vimplugin-",
    src,
    unpackPhase ? "",
    configurePhase ? "",
    buildPhase ? "",
    preInstall ? "",
    postInstall ? "",
    path ? (builtins.parseDrvName name).name,
    addonInfo ? null,
    ...
  }:
    addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // {
      name = namePrefix + name;

      inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;

      installPhase = ''
        runHook preInstall

        target=$out/${rtpPath}/${path}
        mkdir -p $out/${rtpPath}
        cp -r . $target

        # build help tags
        if [ -d "$target/doc" ]; then
          echo "Building help tags"
          if ! ${vim}/bin/vim -N -u NONE -i NONE -n -E -s -c "helptags $target/doc" +quit!; then
            echo "Failed to build help tags!"
            exit 1
          fi
        else
          echo "No docs available"
        fi

        if [ -n "$addonInfo" ]; then
          echo "$addonInfo" > $target/addon-info.json
        fi

        runHook postInstall
      '';
    }));

  buildVimPluginFrom2Nix = attrs: buildVimPlugin ({
    buildPhase = ":";
    configurePhase =":";
  } // attrs);
}
{'fraction_non_alphanumeric': 0.15208333333333332, 'fraction_numerical': 0.003125, 'mean_word_length': 2.1145945945945948, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2128452', 'n_tokens_mistral': 969, 'n_tokens_neox': 942, 'n_words': 225}