Within our TeaVM code we currently do some class rewriting magic to replace individual classes, such as ComputerThread. However, all our code is written to allow changing these implementations already, it's just TeaVM isn't smart enough to look through our builder and realise it's dead code! We now make the ComputerContext's constructor public (though deprecated), which allows our TeaVM code to call it directly.
2.4 KiB
Architecture
As mentioned in the main architecture guide, the web subproject is responsible for building CC: Tweaked's documentation website. This is surprisingly more complex than one might initially assume, hence the need for this document at all!
Web-based emulator
Most of the complexity comes from the web-based emulator we embed in our documentation. This uses TeaVM to compile CC: Tweaked's core to Javascript, and then call out to it in the main site.
The code for this is split into three separate components:
-
src/main: This holds the emulator itself: this is a basic Java project which depends on CC:T's core, and exposes an interface for Javascript code.Some of our code (or dependencies) cannot be compiled to Javascript, for instance
Unsafe-using parts of Netty. In theses cases, we provide a replacement class. These classes start withT(for instanceTASsciiString), which are specially handled in the next step. -
src/builder: This module consumes the above code and compiles everything to Javascript using TeaVM. There's a couple of places where we need to patch the bytecode before compiling it, so this also includes a basic ASM rewriting system. -
src/frontend: This consumes the interface exposed by the main emulator, and actually embeds the emulator in the website.
Static content
Rendering the static portion of the website is fortunately much simpler.
-
Doc generation: This is mostly handled in various Gradle files. The
commonproject uses cct-javadoc to convert Javadoc on our peripherals and APIs to LDoc/illuaminate compatible documentation. This is then fed into illuaminate which spits out HTML. -
src/htmlTransform: We do a small amount of post-processing on the HTML, which is performed by this tool. This includes syntax highlighting of non-Lua code blocks, and replacing special<mc-recipe>tags with a rendered view of a given Minecraft recipe.