mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 23:33:13 +09:00
Fix documentation
Fix missing module declarations, broken lings, broken formating and incorrect scopes in the documentation. For modules split over several files it appears the only viable option is to use the memberof directive on each documented member and only declare the index file as a module.
This commit is contained in:
1 parent
7a9b6592e6
commit
b151dd8469
22 files changed
+318
-56
No files matched your search
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Library for interfacing with Factorio Servers and saves.
|
||||
* @module lib/factorio
|
||||
* @author Hornwitser
|
||||
*/
|
||||
module.exports = {
|
||||
...require('lib/factorio/locale'),
|
||||
...require('lib/factorio/patch'),
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
/**
|
||||
* Function for parsing factorio locale from a local factorio install
|
||||
*/
|
||||
|
||||
// Function for parsing factorio locale from a local factorio install
|
||||
"use strict";
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
@@ -13,6 +10,7 @@ const ini = require("ini");
|
||||
* @param {string} factorioDirectory
|
||||
* @param {string} languageCode
|
||||
* @param {function} callback
|
||||
* @memberof module:lib/factorio
|
||||
*/
|
||||
async function getLocale(dataDir, languageCode) {
|
||||
if (typeof dataDir !== "string") throw new TypeError("dataDir must be a string");
|
||||
|
||||
+11
-4
@@ -1,7 +1,4 @@
|
||||
/**
|
||||
* Library for patching Factorio saves with scenario code.
|
||||
* @author Hornwitser
|
||||
*/
|
||||
// Library for patching Factorio saves with scenario code.
|
||||
|
||||
"use strict";
|
||||
const events = require("events");
|
||||
@@ -31,6 +28,9 @@ const knownScenarios = {
|
||||
* contained in. Throws an error if there are multiple such folders.
|
||||
*
|
||||
* @returns {string} name of the root folder.
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
function findRoot(zip) {
|
||||
let root = null;
|
||||
@@ -60,6 +60,9 @@ function findRoot(zip) {
|
||||
* Generates control.lua code for loading the Clusterio modules
|
||||
*
|
||||
* @param {Object} patchInfo - The patch info files's json content
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
function generateLoader(patchInfo) {
|
||||
let lines = [
|
||||
@@ -107,6 +110,9 @@ function generateLoader(patchInfo) {
|
||||
* their dependents. Throws an error if this is not possible.
|
||||
*
|
||||
* @param {Array<Object>} modules - Array of modules to reorder
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
function reorderDependencies(modules) {
|
||||
let index = 0;
|
||||
@@ -202,6 +208,7 @@ function reorderDependencies(modules) {
|
||||
*
|
||||
* @param {string} savePath - Path to the Factorio save to patch.
|
||||
* @param {Array<Object>} modules - Description of the modules to patch.
|
||||
* @memberof module:lib/factorio
|
||||
*/
|
||||
async function patch(savePath, modules) {
|
||||
let zip = await jszip.loadAsync(await fs.readFile(savePath));
|
||||
|
||||
+50
-16
@@ -1,9 +1,4 @@
|
||||
/**
|
||||
* Factorio interfaces
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
|
||||
// Factorio Server interface
|
||||
"use strict";
|
||||
const fs = require("fs-extra");
|
||||
const child_process = require("child_process");
|
||||
@@ -20,6 +15,10 @@ const errors = require("lib/errors");
|
||||
/**
|
||||
* Determines the version of Factorio the datadir is pointing to by
|
||||
* reading the changelog.txt in it.
|
||||
*
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
async function getVersion(changelogPath) {
|
||||
let changelog;
|
||||
@@ -47,6 +46,10 @@ async function getVersion(changelogPath) {
|
||||
|
||||
/**
|
||||
* Comparison function for sorting Factorio version strings
|
||||
*
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
function versionOrder(a, b) {
|
||||
let aParts = a.split(".").map(s => Number.parseInt(s, 10));
|
||||
@@ -70,6 +73,10 @@ function versionOrder(a, b) {
|
||||
*
|
||||
* Searches the given factorio dir for an installation of Factorio of
|
||||
* the target version.
|
||||
*
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
async function findVersion(factorioDir, targetVersion) {
|
||||
|
||||
@@ -125,6 +132,9 @@ async function findVersion(factorioDir, targetVersion) {
|
||||
* RFC 6335.
|
||||
*
|
||||
* @return {number} a number in the range 49152 to 65535.
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
function randomDynamicPort() {
|
||||
const start = 49152;
|
||||
@@ -141,6 +151,9 @@ function randomDynamicPort() {
|
||||
*
|
||||
* @param {number} length - the length of the password to generate.
|
||||
* @return {string} password of the given length
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
async function generatePassword(length) {
|
||||
function validChar(byte) {
|
||||
@@ -179,6 +192,10 @@ async function generatePassword(length) {
|
||||
* Data is streamed via the data method, and once the stream ends the
|
||||
* end method should be called. This ensures an unterminated line at
|
||||
* the end of the stream is passed to the callback.
|
||||
*
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
class LineSplitter {
|
||||
|
||||
@@ -253,6 +270,9 @@ class LineSplitter {
|
||||
* @param {string} source - Passed into the output structure as source
|
||||
*
|
||||
* @returns {object} - An object with interpeted data.
|
||||
* @memberof module:lib/factorio
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
function parseOutput(line, source) {
|
||||
let output = {
|
||||
@@ -425,15 +445,17 @@ const outputHeuristics = [
|
||||
* stopping and sending commands to the server. It does not deal with
|
||||
* creating or managing servers, or downloading Factorio.
|
||||
*
|
||||
* This is an events emitter with the following events:
|
||||
* stdout - invoked when Factorio outputs a line to stdout
|
||||
* stderr - invoked when Factorio outputs a line to stderr
|
||||
* output - invoked with parsed output from Factorio
|
||||
* rcon-ready - invoked when the RCON client has connected
|
||||
* game-ready - invoked when the server is finished starting up
|
||||
* autosave-start - invoked when the server starts an autosave
|
||||
* autosave-fnished - invoked when the autosave finished
|
||||
* exit - invoked when the sterver has exited
|
||||
* This is an EventEmitter with the following events:
|
||||
* - stdout - invoked when Factorio outputs a line to stdout
|
||||
* - stderr - invoked when Factorio outputs a line to stderr
|
||||
* - output - invoked with parsed output from Factorio
|
||||
* - rcon-ready - invoked when the RCON client has connected
|
||||
* - game-ready - invoked when the server is finished starting up
|
||||
* - autosave-start - invoked when the server starts an autosave
|
||||
* - autosave-fnished - invoked when the autosave finished
|
||||
* - exit - invoked when the sterver has exited
|
||||
* @extends events.EventEmitter
|
||||
* @memberof module:lib/factorio
|
||||
*/
|
||||
class FactorioServer extends events.EventEmitter {
|
||||
/**
|
||||
@@ -442,6 +464,12 @@ class FactorioServer extends events.EventEmitter {
|
||||
* @param {string} factorioDir - Directory of the Factorio install(s).
|
||||
* @param {string} writeDir - Directory to write runtime data to.
|
||||
* @param {object} options - Optional parameters.
|
||||
* @param {string} options.version -
|
||||
* Version of Factorio to use. Can also be the string "latest" to
|
||||
* use the latest version found in `factorioDir`.
|
||||
* @param {number} options.gamePort - UDP port to host game on.
|
||||
* @param {number} options.rconPort - TCP port to use for RCON.
|
||||
* @param {string} options.rconPassword - Password use for RCON.
|
||||
*/
|
||||
constructor(factorioDir, writeDir, options) {
|
||||
super();
|
||||
@@ -454,8 +482,11 @@ class FactorioServer extends events.EventEmitter {
|
||||
this._dataDir = null;
|
||||
|
||||
this._targetVersion = options.version || "latest";
|
||||
/** UDP port used for hosting the Factorio game server on */
|
||||
this.gamePort = options.gamePort || randomDynamicPort();
|
||||
/** TCP port used for RCON on the Factorio game server */
|
||||
this.rconPort = options.rconPort || randomDynamicPort();
|
||||
/** Password used for RCON on the Factorio game server */
|
||||
this.rconPassword = options.rconPassword;
|
||||
this._state = "new";
|
||||
this._server = null;
|
||||
@@ -603,6 +634,7 @@ class FactorioServer extends events.EventEmitter {
|
||||
* Initialize class instance
|
||||
*
|
||||
* Must be called before instances of this class can be used.
|
||||
* @throws {Error} if the requested version of Factorio was not found.
|
||||
*/
|
||||
async init() {
|
||||
this._check(["new"]);
|
||||
@@ -612,7 +644,9 @@ class FactorioServer extends events.EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* The version of Factorio that was detected
|
||||
* The version of Factorio in use. This will be the actual version if
|
||||
* "latest" (the default) was specified as `factorioVersion` to the
|
||||
* constructor.
|
||||
*/
|
||||
get version() {
|
||||
return this._version;
|
||||
|
||||
Reference in new issue
Block a user