Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Frakits committed Sep 30, 2024
2 parents cb932b8 + e0d3bdf commit b787626
Show file tree
Hide file tree
Showing 474 changed files with 20,616 additions and 15,166 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

*.md linguist-detectable -linguist-documentation linguist-language=Markdown
export/** linguist-generated
src/pages/api-docs/** linguist-generated
src/pages/api-docs/** linguist-generated
api-generator/api/** linguist-generated
15 changes: 14 additions & 1 deletion .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
with:
node-version: '20'

- name: Setting up Haxe (for api docs)
uses: krdlab/setup-haxe@v1
with:
haxe-version: 4.2.5

- name: Cache dependencies
uses: actions/cache@v3
with:
Expand All @@ -29,8 +34,16 @@ jobs:
restore-keys: |
${{ runner.os }}-node-
- name: Install Haxelib dependencies
run: |
haxelib --global install dox 1.6.0 --quiet
haxelib --global install hxtemplo 3.2.0 --quiet
haxelib --global install hxparse 4.3.0 --quiet
haxelib --global install hxargs 4.0.0 --quiet
haxelib --global install markdown 1.1.3 --quiet
- run: npm install
- run: npm run build ./
- run: npm run build:full ./

- name: Deploy
uses: peaceiris/actions-gh-pages@v4
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export/*
node_modules/*
node_modules/*
.vscode/*
2 changes: 2 additions & 0 deletions api-generator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pages/*
bin/*
37 changes: 37 additions & 0 deletions api-generator/Macro.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import haxe.io.Path;
import haxe.macro.Expr;
import sys.FileSystem;
import sys.io.Process;

using StringTools;

class Macro {
// meh...
public macro static function getDoxPath():Expr {
var output = getProcessOutput('haxelib', ['--global', 'path', 'dox']);
for (line in output.split("\n")) {
var path = Path.normalize(line.trim());
if (FileSystem.exists(path)) {
var path = Path.directory(Path.removeTrailingSlashes(path.trim()));
return macro $v{path};
}
}
throw "dox path not found";
}

static function getProcessOutput(cmd:String, ?args:Array<String>):String {
try {
var process = new Process(cmd, args);
var output = "";

try {
output = process.stdout.readAll().toString();
} catch (_:Dynamic) {}

process.close();
return output;
} catch (_:Dynamic) {
return "";
}
}
}
81 changes: 81 additions & 0 deletions api-generator/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package;

import dox.Api;
import dox.Config;
import dox.Dox;
import haxe.rtti.CType.TypeInfos;
import sys.io.File;

using StringTools;

class Main {
public static var defines:Map<String, String>;

static function main() {
/*defines = [
for (line in File.getContent("../xml/bin/defines.txt").split("\n")) {
var parts = ~/ /.split(line);
parts[0] => parts[1];
}
];*/

// Generate doc-filter.xml if it exists
if(sys.FileSystem.exists("api/doc.xml")) {
var cwd = Sys.getCwd();
Sys.setCwd(cwd + "/api");
Sys.command("python3 filter.py");
Sys.setCwd(cwd);
sys.FileSystem.rename("api/doc.xml", "api/doc-old.xml"); // so it doesnt convert it again
}

// otherwise, check if cached doc-filter.xml exists
if(!sys.FileSystem.exists("api/doc-filter.xml")) {
trace("Couldn't find doc-filter.xml");
Sys.exit(1);
}

var config = new Config(Macro.getDoxPath());
config.inputPath = "api/doc-filter.xml";
config.outputPath = "../export/api-docs";
config.rootPath = "./";
config.loadTheme("./theme");
config.pageTitle = "Codename Engine API";
config.toplevelPackage = "funkin";
//config.defines = [Version => defines["flixel"]];
config.addFilter("(__ASSET__|ApplicationMain|DocumentClass|DefaultAssetLibrary|Main|NMEPreloader|zpp_nape)", false);
config.addFilter("funkin|scripting", true);
//config.rootPath = "";

Dox.run(config, CodenameApi.new);
}
}

class CodenameApi extends Api {
override function getSourceLink(type:TypeInfos):Null<String> {
var module = type.module != null ? type.module : type.path;
var ending = ".hx";
var url = "https://github.com/FNF-CNE-Devs/CodenameEngine/blob/main/source/";

return haxe.io.Path.join([url, module.replace(".", "/") + ending]);
}

public function getSourceLinkWithLine(type:TypeInfos, line:Int):Null<String> {
var module = type.module != null ? type.module : type.path;
var ending = ".hx";
var url = "https://github.com/FNF-CNE-Devs/CodenameEngine/blob/main/source/";

return haxe.io.Path.join([url, module.replace(".", "/") + ending + "#L" + line]);
}

function isOneOf(module:String, classes:Array<String>):Bool {
for (cl in classes) {
if (module.indexOf(cl) >= 0)
return true;
}
return false;
}

override function hasSourceLink(type:TypeInfos):Bool {
return type.file != null && type.file.endsWith(".hx");
}
}
2 changes: 2 additions & 0 deletions api-generator/api/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b787626

Please sign in to comment.