Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Strata Wiki
# Strata Source Wiki Software

[![Strata Source](https://branding.stratasource.org/i/strata/logo/ondark/color.svg)](https://stratasource.org)

Welcome to the Strata Wiki!
Welcome to the Strata Source Wiki Software repository!

This is the custom wiki software that powers the Wiki for most of our games. If you're looking to edit the contents of the Wiki or to build and run local instances of the Wiki, check out [the documentation Wiki repository](https://github.com/StrataSource/wiki/).
This is the custom software that powers the Wiki for most of our games. If you're looking to edit the contents of the Wiki or to build and run local instances of the Wiki, check out [the documentation Wiki repository](https://github.com/StrataSource/wiki/).
64 changes: 43 additions & 21 deletions src/lib/parsers/angelscript.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { parseMarkdown } from "./markdown.server";
import { reportLint } from "$lib/linter.server";
import { urlifyString } from "$lib/util";

type ASScope =
type ASScope =
| "server"
| "client";
| "client"
| "hammer";

interface ASNamed {
namespace: string|undefined;
Expand Down Expand Up @@ -79,8 +80,18 @@ function getASArticleScope(o: {scope?: ASScope[];}): ArticleScope|undefined

const server = o.scope.includes("server");
const client = o.scope.includes("client");

return server && client ? "shared" : ( server ? "server" : (client ? "client" : undefined))
const hammer = o.scope.includes("hammer");

if (server && client)
return "shared";
else if (server)
return "server";
else if (client)
return "client";
else if (hammer)
return "hammer";

return undefined;
}

function compareScope(a: {scope?: ASScope[];}, b: {scope?: ASScope[];})
Expand All @@ -89,7 +100,7 @@ function compareScope(a: {scope?: ASScope[];}, b: {scope?: ASScope[];})
return getASArticleScope(a) === getASArticleScope(b);
}

let angelscriptDump: ASDump = { namespace: [], enum: [], property: [], function: [], type: [] };
const angelscriptDump: ASDump = { namespace: [], enum: [], property: [], function: [], type: [] };

function isValidTypeName(type: string) {
if(baseTypeNames.includes(type)) {
Expand Down Expand Up @@ -176,7 +187,7 @@ function mergeDump(scope: ASScope, dump: ASDump)
} else {
ft.scope?.push(scope);
}

// TODO: Combine mismatches!
if((ot.base_type ? getASName(ot.base_type) : undefined) != (ft.base_type ? getASName(ft.base_type) : undefined) || ot.template_parameter?.length != ft.template_parameter?.length) {
console.log(ot);
Expand Down Expand Up @@ -213,15 +224,19 @@ function compareNamed(a: ASNamed, b: ASNamed): number {
}

function parseJSON() {
let server: ASDump = JSON.parse(
const server: ASDump = JSON.parse(
fs.readFileSync(`../dumps/angelscript_server_p2ce.json`, "utf-8")
);
let client: ASDump = JSON.parse(
const client: ASDump = JSON.parse(
fs.readFileSync(`../dumps/angelscript_client_p2ce.json`, "utf-8")
);

const hammer: ASDump = JSON.parse(
fs.readFileSync(`../dumps/angelscript_hammer_p2ce.json`, "utf-8")
);

mergeDump("server", server);
mergeDump("client", client);
mergeDump("hammer", hammer);

// Sort everything
angelscriptDump.enum.sort((a, b) => compareNamed(a, b));
Expand All @@ -235,12 +250,14 @@ function getScopeString(o: ASNamed): string {

const scope = getASArticleScope(o);

if(scope === "shared") {
if (scope === "shared") {
return "Server & Client";
} else if(scope === "server") {
} else if (scope === "server") {
return "Server Only";
} else if(scope === "client") {
} else if (scope === "client") {
return "Client Only";
} else if (scope === "hammer") {
return "Hammer";
}

return "Unknown";
Expand Down Expand Up @@ -291,7 +308,7 @@ function renderFunctionPages(name: string, p: string, functions: ASFunction[]):
for( const asFunc of asFuncs )
{
out.push(getScopeString(asFunc));

if (asFunc.documentation) {
out.push(asFunc.documentation);
}
Expand Down Expand Up @@ -332,19 +349,24 @@ function renderPropertyPage(p: string, properties: ASProperty[], subtext?: boole
const server: ASProperty[] = properties.filter(o => getASArticleScope(o) === "server");
const client: ASProperty[] = properties.filter(o => getASArticleScope(o) === "client");
const shared: ASProperty[] = properties.filter(o => getASArticleScope(o) === "shared");
const hammer: ASProperty[] = properties.filter(o => getASArticleScope(o) === "hammer");

if(shared.length > 0) {
if (shared.length > 0) {
out.push(...renderPropertyPageInternal(p, shared, header + " - Shared"));
}

if(server.length > 0) {
if (server.length > 0) {
out.push(...renderPropertyPageInternal(p, server, header + " - Server"));
}

if(client.length > 0) {
if (client.length > 0) {
out.push(...renderPropertyPageInternal(p, client, header + " - Client"));
}

if (hammer.length > 0) {
out.push(...renderPropertyPageInternal(p, hammer, header + " - Hammer"));
}

return out;
}

Expand All @@ -354,9 +376,9 @@ function renderMethods(parent: ASNamed, methods: ASFunction[])
for(const asMethod of methods) {

const scopeSuffix = compareScope(parent, asMethod) ? "" : ` (${getScopeString(asMethod)})`;

out.push(`### ${asMethod.name}${scopeSuffix}`);

if (asMethod.documentation) {
out.push(asMethod.documentation);
}
Expand Down Expand Up @@ -449,7 +471,7 @@ function renderTypePages(name: string, p: string): string[] {
out.push(`### Inherited From ${name}`);
out.push(...renderMethods(asBaseType, asBaseType.method));
}

base = asBaseType.base_type;
}

Expand Down Expand Up @@ -508,7 +530,7 @@ function getAngelScriptIndex(p: string): PageGeneratorIndex {
});
}
index.topics.push(enumTopic);

const funcTopic: MenuTopic = {
type: "angelscript",
id: `${p}/function`,
Expand All @@ -518,7 +540,7 @@ function getAngelScriptIndex(p: string): PageGeneratorIndex {
subtopics: [],
};
for (const o of angelscriptDump.function) {

// Gross... Need to not emit overloads
const f = funcTopic.articles.find((a) => a.id === urlifyString(getASName(o)));
if (f) {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ interface BasePageMeta {
weight?: number;
}

type ArticleScope =
type ArticleScope =
| "server"
| "client"
| "shared";
| "shared"
| "hammer";

// Articles are the pages you read
interface ArticleMeta extends BasePageMeta {
Expand Down
Loading