<commit_before>package org.jetbrains.dokka.plugability

import java.io.File
import java.net.URLClassLoader
import java.util.*


class DokkaContext private constructor() {
    private val plugins = mutableListOf<DokkaPlugin>()

    val pluginNames: List<String>
        get() = plugins.map { it.name }

    private fun install(plugin: DokkaPlugin) {
        plugins += plugin
        plugin.install(this)
    }

    companion object {
        fun from(pluginsClasspath: Iterable<File>) = DokkaContext().apply {
            pluginsClasspath.map { it.relativeTo(File(".").absoluteFile).toURI().toURL() }
                .toTypedArray()
                .let { ServiceLoader.load(DokkaPlugin::class.java, URLClassLoader(it, this.javaClass.classLoader)) }
                .forEach { install(it) }
        }
    }
}<commit_msg>Adds simplest classpath checking for plugins<commit_after>package org.jetbrains.dokka.plugability

import java.io.File
import java.net.URLClassLoader
import java.util.*


class DokkaContext private constructor() {
    private val plugins = mutableListOf<DokkaPlugin>()

    val pluginNames: List<String>
        get() = plugins.map { it.name }

    private fun install(plugin: DokkaPlugin) {
        plugins += plugin
        plugin.install(this)
    }

    companion object {
        fun from(pluginsClasspath: Iterable<File>) = DokkaContext().apply {
            pluginsClasspath.map { it.relativeTo(File(".").absoluteFile).toURI().toURL() }
                .toTypedArray()
                .let { URLClassLoader(it, this.javaClass.classLoader) }
                .also { checkClasspath(it) }
                .let { ServiceLoader.load(DokkaPlugin::class.java, it) }
                .forEach { install(it) }
        }
    }

    private fun checkClasspath(classLoader: URLClassLoader) {
        classLoader.findResource(javaClass.name.replace('.','/') + ".class")?.also {
            throw AssertionError("Dokka API found on plugins classpath. This will lead to subtle bugs. " +
                    "Please fix your plugins dependencies or exclude dokka api artifact from plugin classpath")
        }
    }
}
{'fraction_non_alphanumeric': 0.11095439586271744, 'fraction_numerical': 0.0, 'mean_word_length': 2.6006768189509306, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5004743', 'n_tokens_mistral': 614, 'n_tokens_neox': 593, 'n_words': 129}