Creating offline Javadoc for the Spigot API

Oct 17, 2017
Creating offline Javadoc for the Spigot API
  • Creating offline Javadoc for Spigot


    The Spigot Javadoc can always be accessed online using the URL https://hub.spigotmc.org/javadocs/spigot/ and most modern Java based IDE's will have no problem with using this as a Javadoc resource. But using an online resource does come at the cost of efficiency, accessing a local copy is per definition a lot faster.

    So before you get any ideas of using wget to download everything I'll be showing you how you can easily make your own local copy instead.

    Prerequisites

    I'm assuming that you have installed a local copy of the Spigot server using Build Tools. If you haven't then please follow the link to learn how you can obtain it and use it to install your own copy of Spigot and the Spigot API.

    You'll also need to have the Java JDK bin folder in your searchpath,

    Creating Javadoc with Maven

    First preparations

    After you build the server you'll find the main jarfile (spigot-x.xx.jar) in the main folder while the Spigot API can be found in the Spigot/Spigot-API/target subfolder. However, we'll need to access the sourcecode, not the compiled results. So navigate to: Spigot/Spigot-API/src/main.

    Here you'll notice 2 subfolders: java and javadoc. Javadoc is merely a rough placeholder which doesn't contain anything useful yet, so remove its contents first. On Windows it's easier to remove the entire folder and then recreate it: "rmdir javadoc /S", followed by "mkdir javadoc" (use both commands without the quotes). On a Unix-like environment you could use: "rm -r javadoc/*" (also without the quotes). Of course you can also use a filemanager to do this instead of using the commandline.

    Generate the Javadoc

    You only need one single command
    Code (Text):
    javadoc -d javadoc -sourcepath ./java -encoding UTF-8 -subpackages org.bukkit:org.spigotmc
    Note: If this command does not work, navigate to Spigot-API and run
    Code (Text):
    mvn javadoc:javadoc
    The Javadoc will be in Spigot-API/target/site/apidocs

    This command ensures that the output will be placed in the javadoc subfolder, the command starts looking for sourcefiles in the java subfolder and will honor the UTF-8 encoding format. Finally it will specifically check for org/bukkit and org/spigotmc (within Java a package structure is set up using folders).

    The only caveat in using this command is that the individual packages won't be described like in the online Javadoc, instead you'll only get links which you can click to examine the package contents.

    Optional extra steps

    If you have installed the server on the same computer as where you're using your Java IDE then you could consider to simply point the IDE to your server location. Otherwise you can simply copy both the java and javadoc folders (or compress them using ZIP) and then use those in another location.

    The advantages should be obvious: this will ensure that you keep access to the Javadoc (and optionally to the sourcecode) even if you're having Internet connectivity problems.
  • Loading...
  • Loading...