Various Improvements

This commit is contained in:
Ben C 2023-11-29 21:57:04 -05:00
parent 7cbaef6fc1
commit 4204a0d653
No known key found for this signature in database
19 changed files with 94 additions and 56 deletions

View File

@ -3,7 +3,7 @@ import starlight from "@astrojs/starlight";
import rehypeExternalLinks from "rehype-external-links";
import { generateSchema } from "./src/schema_generator";
import makeSchemasPlugin from "./src/plugins/schema-plugin";
const url = "https://nh.outerwildsmods.com";
@ -17,11 +17,6 @@ const schemas = [
"shiplog_schema.xsd"
];
schemas.forEach((schema) => {
console.log(`Generating pages for ${schema}...`);
generateSchema(schema);
});
const ogMeta = (name, val) => ({
tag: "meta",
attrs: {
@ -52,6 +47,7 @@ export default defineConfig({
"Documentation on how to use the New Horizons planet creation tool for Outer Wilds.",
defaultLocale: "en-us",
favicon: "/favicon.png",
plugins: [makeSchemasPlugin({ schemas })],
components: {
PageSidebar: "/src/components/ConditionalPageSidebar.astro"
},

View File

@ -12,7 +12,7 @@
"format": "prettier --write ."
},
"dependencies": {
"@astrojs/starlight": "^0.13.1",
"@astrojs/starlight": "^0.14.0",
"astro": "3.6.3",
"rehype-external-links": "^3.0.0",
"sharp": "^0.33.0"

14
docs/pnpm-lock.yaml generated
View File

@ -6,8 +6,8 @@ settings:
dependencies:
"@astrojs/starlight":
specifier: ^0.13.1
version: 0.13.1(astro@3.6.3)
specifier: ^0.14.0
version: 0.14.0(astro@3.6.3)
astro:
specifier: 3.6.3
version: 3.6.3
@ -172,10 +172,10 @@ packages:
zod: 3.22.4
dev: false
/@astrojs/starlight@0.13.1(astro@3.6.3):
/@astrojs/starlight@0.14.0(astro@3.6.3):
resolution:
{
integrity: sha512-cJ3WQcX3KAedH1uRApxp6usacCcRd76jsWT1V2j4rqWU817PBFrhF7xAsvm4aQaWPryqmsFOmBwSg+iOLsGNew==
integrity: sha512-wrve52CIIymvntjf2QCfCFpYrmZTyD1qObkvLImeGDVAAyNdUnNlj6MU6SkqQg2fQkJcX9Kh4zkwepm79zYveQ==
}
peerDependencies:
astro: ^3.2.0
@ -2271,7 +2271,7 @@ packages:
hasBin: true
dependencies:
caniuse-lite: 1.0.30001565
electron-to-chromium: 1.4.596
electron-to-chromium: 1.4.597
node-releases: 2.0.13
update-browserslist-db: 1.0.13(browserslist@4.22.1)
dev: false
@ -2780,10 +2780,10 @@ packages:
}
dev: false
/electron-to-chromium@1.4.596:
/electron-to-chromium@1.4.597:
resolution:
{
integrity: sha512-zW3zbZ40Icb2BCWjm47nxwcFGYlIgdXkAx85XDO7cyky9J4QQfq8t0W19/TLZqq3JPQXtlv8BPIGmfa9Jb4scg==
integrity: sha512-0XOQNqHhg2YgRVRUrS4M4vWjFCFIP2ETXcXe/0KIQBjXE9Cpy+tgzzYfuq6HGai3hWq0YywtG+5XK8fyG08EjA==
}
dev: false

View File

@ -1,7 +1,7 @@
---
import type { Props } from "@astrojs/starlight/props";
import Default from "@astrojs/starlight/components/PageSidebar.astro";
import { SchemaTools } from "../schema_utils";
import { SchemaTools } from "@/util/schema_utils";
import type { MarkdownHeading } from "astro";
const isSchema = Astro.props.slug.startsWith("schemas/") && !Astro.props.slug.endsWith("/defs");
@ -29,10 +29,10 @@ function generateToC(
let props = Astro.props;
if (isSchema) {
const schemaFileName = props.entry.data.head[0]?.attrs?.fileName as string | undefined;
const schemaFileName = props.entry.data.schemaFile;
if (schemaFileName) {
let schema = SchemaTools.readSchema(schemaFileName);
const defName = props.entry.data.head[0]?.attrs?.def as string | undefined;
const defName = props.entry.data.defName;
if (defName) {
schema = SchemaTools.getDefs(schema).find(d => d.slug === defName)!;
}

View File

@ -0,0 +1,9 @@
---
import { readFileSync } from "fs";
const content = readFileSync("../NewHorizons/INewHorizons.cs");
---
{content}

View File

@ -1,6 +1,6 @@
---
import type { Schema } from "../../schema_utils";
import { SchemaTools } from "../../schema_utils";
import type { Schema } from "@/util/schema_utils";
import { SchemaTools } from "@/util/schema_utils";
export interface Props {
schema: Schema;

View File

@ -1,6 +1,6 @@
---
import { SchemaTools } from "../../schema_utils";
import type { Schema } from "../../schema_utils";
import { SchemaTools } from "@/util/schema_utils";
import type { Schema } from "@/util/schema_utils";
export interface Props {
schema: Schema;

View File

@ -1,6 +1,6 @@
---
import { SchemaTools } from '../../schema_utils';
import Breadcrumb from './Breadcrumb.astro';
import { SchemaTools } from '@/util/schema_utils';
import Breadcrumb from '@/components/Schemas/Breadcrumb.astro';
interface Props {
fileName: string;

View File

@ -1,6 +1,6 @@
---
import { SchemaTools } from '../../schema_utils';
import Content from './Content.astro';
import { SchemaTools } from '@/util/schema_utils';
import Content from '@/components/Schemas/Content.astro';
interface Props {
fileName: string;
@ -13,4 +13,3 @@ const schema = SchemaTools.readSchema(fileName);
---
<Content schema={schema} level={0} />

View File

@ -1,7 +1,7 @@
---
import { SchemaTools } from '../../schema_utils';
import Breadcrumb from './Breadcrumb.astro';
import Content from './Content.astro';
import { SchemaTools } from '@/util/schema_utils';
import Breadcrumb from '@/components/Schemas/Breadcrumb.astro';
import Content from '@/components/Schemas/Content.astro';
interface Props {
fileName: string;
@ -19,4 +19,3 @@ const targetDef = defs.find(d => d.slug === def);
<Breadcrumb schema={targetDef!} />
<Content schema={targetDef!} level={0} isDef />

View File

@ -1,7 +1,13 @@
import { defineCollection } from "astro:content";
import { docsSchema, i18nSchema } from "@astrojs/starlight/schema";
import { defineCollection, z } from "astro:content";
import { docsSchema } from "@astrojs/starlight/schema";
export const collections = {
docs: defineCollection({ schema: docsSchema() }),
i18n: defineCollection({ type: "data", schema: i18nSchema() })
docs: defineCollection({
schema: docsSchema({
extend: z.object({
schemaFile: z.string().optional(),
defName: z.string().optional()
})
})
})
};

View File

@ -85,7 +85,7 @@ Making a planet's entire surface from a Unity prefab is the exact same thing as
To add a Mars rover to the red planet in [RSS](https://github.com/xen-42/outer-wilds-real-solar-system), its model was put in an asset bundle as explained above, and then the following was put into the `Props` module:
```json
```json {5-6}
{
"Props": {
"Details": [

View File

@ -135,7 +135,7 @@ To view the options for the dialogue prop, check [the schema](/schemas/body-sche
You can set condition in dialogue with the `<SetCondition>` and `<SetPersistentCondition>` tags
```xml
```xml {3-4}
<DialogueNode>
<!-- ... -->
<SetCondition>EXAMPLE_CONDITION</SetCondition>

View File

@ -79,7 +79,7 @@ This makes the second planet a quantum state of the first, anything you specify
}
```
```json title="cool_planet_th_state.json"
```json {3} title="cool_planet_th_state.json"
{
"name": "MyPlanet",
"isQuantumState": true,
@ -94,7 +94,7 @@ This makes the second planet a quantum state of the first, anything you specify
To create a binary system of planets (like ash twin and ember twin), first create a config with `FocalPoint` set
```json title="center.json"
```json {7-10} title="center.json"
{
"name": "My Focal Point",
"Orbit": {

View File

@ -141,7 +141,7 @@ the schema file. Doing this varies per-editor, and you may also have to right-cl
You can load your XML file to your planet by doing adding the following to your planet's config
```json
```json {3}
{
"ShipLog": {
"xmlFile": "planets/example.xml"
@ -188,7 +188,7 @@ _A set of entries laid out with auto mode_
Custom entry images are a bit different from other custom images, instead of pointing to each file for each entry, you
point to a folder:
```json
```json {4}
{
"ShipLog": {
"xmlFile": "planets/example.xml",
@ -253,7 +253,7 @@ _An example system laid out with auto mode_
The `offset` option lets you adjust a planet's offset from the last planet.
```json
```json {5}
{
"ShipLog": {
"xmlFile": "planets/example.xml",
@ -276,7 +276,7 @@ Manual layout **requires** you to fill out both `manualPosition` and `manualNavi
Setting the `manualPosition` option in the `mapMode` object sets its position (if manual position isn't set, it assumes
the planet is using automatic mode)
```json
```json {5-8}
{
"ShipLog": {
"xmlFile": "planets/example.xml",
@ -297,7 +297,7 @@ This setting tells Outer Wilds how to handle navigation for this object, the x a
column of this planet. For example, the sun station is at navigationPosition (0, 1) as it is in the first column on the
second row (you can't select the sun, so it doesn't have a row or column). So, by making a navigation position of:
```json
```json {9-12}
{
"ShipLog": {
"xmlFile": "planets/example.xml",
@ -348,7 +348,7 @@ outline.
How much to scale this planet in the map mode screen (you may have to change offset to compensate)
```json
```json {5}
{
"ShipLog": {
"xmlFile": "planets/example.xml",
@ -370,7 +370,7 @@ Don't include this planet in map mode at all, simply ignore it
Details are images that go on top of a planet in map mode, and changes states with the planet (like the sand funnel
between Ash Twin and Ember Twin)
```json
```json {5-20}
{
"ShipLog": {
"xmlFile": "planets/example.xml",
@ -406,7 +406,7 @@ Of course, having a custom ship log is neat and all, but what use is it if the p
You can set facts to reveal as soon as the player enters the system by adding the `initialReveal` property
```json
```json {4}
{
"ShipLog": {
"xmlFile": "planets/example.xml",
@ -439,7 +439,7 @@ You can set a fact to reveal as soon as a signal is identified by editing the si
You can set a fact to reveal in dialogue with the `<RevealFacts>` tag
```xml
```xml {7-9}
<!-- Example Dialogue -->
<DialogueNode>
<Name>1</Name>

View File

@ -2,10 +2,7 @@
title: Celestial Body Schema
description: Describes a celestial body to generate
editUrl: false
head:
- tag: meta
attrs:
fileName: body_schema.json
schemaFile: body_schema.json
---
import Schema from "/src/components/Schemas/Schema.astro";

View File

@ -0,0 +1,28 @@
import { generateSchema } from "../util/schema_generator";
import type { StarlightPlugin } from "@astrojs/starlight/types";
export interface SchemaPluginOptions {
schemas: string[];
}
type Context = Parameters<StarlightPlugin["hooks"]["setup"]>[0];
const makePlugin = (options: SchemaPluginOptions): StarlightPlugin => {
const setup = ({ logger }: Context) => {
logger.debug("Generating schema docs");
for (const schema of options.schemas) {
logger.info(`Generating schema docs for ${schema}`);
generateSchema(schema);
}
logger.debug("Finished generating schema docs");
};
return {
name: "astro-plugin-schema",
hooks: {
setup
}
};
};
export default makePlugin;

View File

@ -32,7 +32,8 @@ const generateDef = (def: Schema) => {
title,
description,
editUrl: false,
head: `\n - tag: meta\n attrs:\n fileName: ${def.fileName}\n def: ${title}`
schemaFile: def.fileName,
defName: title
};
const content = `import SchemaDef from "/src/components/Schemas/SchemaDef.astro";\n\n<SchemaDef fileName="${def.fileName}" def="${title}" />\n`;
@ -51,7 +52,7 @@ const generateDefList = (schema: Schema) => {
title: `${SchemaTools.getTitle(schema)} definitions`,
description: "List of all definitions in the ${SchemaTools.getTitle(schema)} schema",
editUrl: false,
head: `\n - tag: meta\n attrs:\n fileName: ${schema.fileName}`
schemaFile: schema.fileName
};
const content = `import DefinitionList from "/src/components/Schemas/DefinitionList.astro";\n\n<DefinitionList fileName="${schema.fileName}" />\n`;
@ -72,7 +73,7 @@ export const generateSchema = (fileName: string) => {
title: SchemaTools.getTitle(schema) as string,
description: SchemaTools.getDescription(schema) as string,
editUrl: false,
head: `\n - tag: meta\n attrs:\n fileName: ${schema.fileName}`
schemaFile: schema.fileName
};
const content = `import Schema from "/src/components/Schemas/Schema.astro";\n\n<Schema fileName="${schema.fileName}" />\n`;

View File

@ -85,7 +85,6 @@ export const SchemaTools = {
return documentation.elements?.[0]?.text;
}
}
def: string;
}
},
@ -227,6 +226,10 @@ export const SchemaTools = {
switch (schema.internalSchema.type) {
case "JSON":
const internalSchema = schema.internalSchema.val;
let requiredList: string[] = [];
if (internalSchema.required && Array.isArray(internalSchema.required)) {
requiredList = internalSchema.required;
}
if (internalSchema.type === "object") {
return Object.entries(internalSchema.properties ?? {}).map((e) => [
e[0],
@ -236,7 +239,7 @@ export const SchemaTools = {
rootSlug: schema.rootSlug,
internalSchema: {
type: "JSON",
val: { title: e[0], ...e[1] }
val: { title: e[0], required: requiredList.includes(e[0]), ...e[1] }
}
} as Schema
]);