mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-12-24 06:26:03 +00:00
Generate documentation stubs from Javadocs
illuaminate does not handle Java files, for obvious reasons. In order to get around that, we have a series of stub files within /doc/stub which mirrored the Java ones. While this works, it has a few problems: - The link to source code does not work - it just links to the stub file. - There's no guarantee that documentation remains consistent with the Java code. This change found several methods which were incorrectly documented beforehand. We now replace this with a custom Java doclet[1], which extracts doc comments from @LuaFunction annotated methods and generates stub-files from them. These also contain a @source annotation, which allows us to correctly link them back to the original Java code. There's some issues with this which have yet to be fixed. However, I don't think any of them are major blockers right now: - The custom doclet relies on Java 9 - I think it's /technically/ possible to do this on Java 8, but the API is significantly uglier. This means that we need to run javadoc on a separate JVM. This is possible, and it works locally and on CI, but is definitely not a nice approach. - illuaminate now requires the doc stubs to be generated in order for the linter to pass, which does make running the linter locally much harder (especially given the above bullet point). We could notionally include the generated stubs (or at least a cut down version of them) in the repo, but I'm not 100% sure about that. [1]: https://docs.oracle.com/javase/9/docs/api/jdk/javadoc/doclet/package-summary.html
This commit is contained in:
@@ -28,6 +28,11 @@ import java.util.Map;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* The FS API allows you to manipulate files and the filesystem.
|
||||
*
|
||||
* @cc.module fs
|
||||
*/
|
||||
public class FSAPI implements ILuaAPI
|
||||
{
|
||||
private final IAPIEnvironment environment;
|
||||
@@ -291,6 +296,19 @@ public class FSAPI implements ILuaAPI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a path is mounted to the parent filesystem.
|
||||
*
|
||||
* The root filesystem "/" is considered a mount, along with disk folders and the rom folder. Other programs
|
||||
* (such as network shares) can extend this to make other mount types by correctly assigning their return value for
|
||||
* getDrive.
|
||||
*
|
||||
* @param path The path of the drive to get.
|
||||
* @return The drive's capacity.
|
||||
* @throws LuaException If the capacity cannot be determined.
|
||||
* @cc.treturn number|nil This drive's capacity. This will be nil for "read-only" drives, such as the ROM or
|
||||
* treasure disks.
|
||||
*/
|
||||
@LuaFunction
|
||||
public final Object getCapacity( String path ) throws LuaException
|
||||
{
|
||||
@@ -305,6 +323,22 @@ public class FSAPI implements ILuaAPI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes about a specific file or folder.
|
||||
*
|
||||
* The returned attributes table contains information about the size of the file, whether it is a directory, and
|
||||
* when it was created and last modified.
|
||||
*
|
||||
* The creation and modification times are given as the number of milliseconds since the UNIX epoch. This may be
|
||||
* given to {@link OSAPI#date} in order to convert it to more usable form.
|
||||
*
|
||||
* @param path The path to get attributes for.
|
||||
* @return The resulting attributes.
|
||||
* @throws LuaException If the path does not exist.
|
||||
* @cc.treturn { size = number, isDir = boolean, created = number, modified = number } The resulting attributes.
|
||||
* @see #getSize If you only care about the file's size.
|
||||
* @see #isDir If you only care whether a path is a directory or not.
|
||||
*/
|
||||
@LuaFunction
|
||||
public final Map<String, Object> attributes( String path ) throws LuaException
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user