This document describes my personal method for generating the NeoForge JavaDocs. It is by no means a very stable or efficient approach and i make no guarantees that this will continue to work in the future. It is based on a custom Gradle task, added to the official Forge repository source to generate a combined JavaDoc for all packages.
Please make sure that you have the corresponding Java Development Kit version installed for the Forge version you want to address!
git clone --depth=1 --branch=<TAG_NAME> https://github.com/neoforged/NeoForge.git
./gradlew setup
(or .\gradlew.bat setup
) command in the project directory.
This step is crucial as it downloads and decompiles the actual Minecraft sources required for the project to work.Open the build.gradle
file from the project root directory in your favorite editor and append the following snippet at the end of the file:
apply plugin: 'java'
subprojects {
apply plugin: 'java'
}
afterEvaluate {
def neoForgeVersion = "20.2.88"
def exportedProjects = [
":",
":neoforge",
]
task alljavadoc(type: Javadoc) {
options.tags = [
'apiNote:a:<em>API Note:</em>',
'implSpec:a:<em>Implementation Requirements:</em>',
'implNote:a:<em>Implementation Note:</em>'
]
options.addStringOption('Xdoclint:none', '-private')
options.addStringOption('locale', 'en_US')
options.addStringOption('encoding', 'utf-8')
options.addStringOption('docencoding', 'utf-8')
options.addStringOption('charset', 'utf-8')
options.addStringOption('windowtitle', "NeoForge ${neoForgeVersion} Modding API for Minecraft ${project.minecraft_version}")
options.addStringOption('doctitle', "NeoForge ${neoForgeVersion} Modding API for Minecraft ${project.minecraft_version}")
source exportedProjects.collect { project(it).sourceSets.main.allJava }
classpath = files(exportedProjects.collect { project(it).sourceSets.main.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
}
}
You must adapt this snippet slightly:
exportedProjects
list.neoForgeVersion
to the one you’re buildings the docs for.destinationDir
path if you want to store the docs somewhere else than the default build/docs/javadoc
directory.All you still have to do now is to run ./gradlew alljavadoc
(or .\gradlew.bat alljavadoc
respectively).
This will go through all projects and generate a combined JavaDoc for all of them in the configured location.
If you are working on a system with a non-english locale, you will need to force Java to use english for the
JavaDoc by setting the env variable JAVA_TOOL_OPTIONS="-Duser.language=en"
for Gradle prior to building.
Please note that a lot of warnings will be thrown during the process, but these can safely be ignored. Most of them complain about missing reference links or inproper formatting and do not really affect the result. As long as you get no errors you should be fine.
If you run into any errors:
exportedProjects
list is correct! This is the most common source of errors in this process.