Merge branch 'master' of https://github.com/xen-42/outer-wilds-new-horizons
@ -8,6 +8,15 @@ on:
|
||||
- NewHorizons/*schema*.json
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
relative_path:
|
||||
description: "Path to set for relative files, set to a blank string for local builds"
|
||||
required: false
|
||||
default: "/"
|
||||
|
||||
env:
|
||||
OUT_DIR: ${{ github.events.inputs.relative_path }}
|
||||
BASE_URL: https://nh.outerwildsmods.com/
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -17,6 +26,10 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cp -r docs/** .
|
||||
|
||||
- if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
echo "OUT_DIR=/" >> $GITHUB_ENV
|
||||
|
||||
- name: Install dependecies
|
||||
uses: VaultVulp/action-pipenv@v2.0.1
|
||||
@ -25,10 +38,10 @@ jobs:
|
||||
|
||||
- name: Copy Schemas
|
||||
run: |
|
||||
mkdir schemas/
|
||||
cp NewHorizons/schema.json schemas/
|
||||
cp NewHorizons/star_system_schema.json schemas/
|
||||
cp NewHorizons/translation_schema.json schemas/
|
||||
mkdir content/schemas/
|
||||
cp NewHorizons/schema.json content/schemas/
|
||||
cp NewHorizons/star_system_schema.json content/schemas/
|
||||
cp NewHorizons/translation_schema.json content/schemas/
|
||||
|
||||
- name: Create Output Dir
|
||||
run: |
|
||||
@ -40,7 +53,14 @@ jobs:
|
||||
with:
|
||||
command: run python generate.py
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Built-Docs
|
||||
path: out/
|
||||
|
||||
- name: Deploy To Pages
|
||||
if: success() && github.ref == 'refs/heads/master'
|
||||
uses: JamesIves/github-pages-deploy-action@4.1.5
|
||||
with:
|
||||
branch: gh-pages
|
||||
12
.gitignore
vendored
@ -396,7 +396,7 @@ FodyWeavers.xsd
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
.idea
|
||||
.idea/
|
||||
|
||||
packages
|
||||
.vs
|
||||
@ -405,9 +405,9 @@ obj
|
||||
zip
|
||||
*.zip
|
||||
|
||||
*/Build/*
|
||||
.idea/
|
||||
docs/out/*
|
||||
docs/schemas/*
|
||||
*/Build/**
|
||||
NewHorizons/Properties/**
|
||||
|
||||
NewHorizons/Properties/*
|
||||
# Docs
|
||||
docs/out/**
|
||||
docs/content/schemas/**
|
||||
|
||||
@ -70,8 +70,8 @@
|
||||
"angle": {
|
||||
"type": "number",
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": 360
|
||||
"minimum": 0,
|
||||
"maximum": 360
|
||||
},
|
||||
"curve": {
|
||||
"type": "array",
|
||||
@ -104,7 +104,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"title": "Planet",
|
||||
"title": "Body",
|
||||
"description": "A planet or body to generate",
|
||||
"type": "object",
|
||||
"required": [
|
||||
@ -627,7 +627,7 @@
|
||||
"shipSpawnPoint": {
|
||||
"$ref": "#/$defs/vector3"
|
||||
},
|
||||
"starWithSuit": {
|
||||
"startWithSuit": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
"title": "Star System",
|
||||
"description": "Configuration for a specific star system",
|
||||
"properties": {
|
||||
"canEnterViaWarpDrive": {
|
||||
|
||||
@ -6,6 +6,7 @@ name = "pypi"
|
||||
[packages]
|
||||
jinja2 = "*"
|
||||
json-schema-for-humans = "*"
|
||||
markdown = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
|
||||
10
docs/Pipfile.lock
generated
@ -1,7 +1,7 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "b4acdc18f2bf25fdf7a2448229884300b7e3ec47731a49ad482b21d32c627370"
|
||||
"sha256": "600dddfc39d9e9ca825fd1870bfa2094e3124c7d1759be513936f1d0d842cd5c"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
@ -85,6 +85,14 @@
|
||||
"index": "pypi",
|
||||
"version": "==0.40"
|
||||
},
|
||||
"markdown": {
|
||||
"hashes": [
|
||||
"sha256:76df8ae32294ec39dcf89340382882dfa12975f87f45c3ed1ecdb1e8cefc7006",
|
||||
"sha256:9923332318f843411e9932237530df53162e29dc7a4e2b91e35764583c46c9a3"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==3.3.6"
|
||||
},
|
||||
"markdown2": {
|
||||
"hashes": [
|
||||
"sha256:8f4ac8d9a124ab408c67361090ed512deda746c04362c36c2ec16190c720c2b0",
|
||||
|
||||
47
docs/Setup.md
Normal file
@ -0,0 +1,47 @@
|
||||
# Setup to build docs
|
||||
|
||||
## Requirements
|
||||
- Python 3.10
|
||||
|
||||
## Clone the repo
|
||||
Clone the entire repo and navigate to the docs folder
|
||||
```shell
|
||||
git clone https://github.com/xen-42/outer-wilds-new-horizons
|
||||
cd outer-wilds-new-horizons/docs
|
||||
```
|
||||
|
||||
## Setup Pipenv
|
||||
Install pipenv if you haven't already
|
||||
```shell
|
||||
pip install --user pipenv
|
||||
```
|
||||
Install dependencies
|
||||
```shell
|
||||
pipenv install
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
- OUT_DIR: Path to put before all links and static files, see below for recommended values
|
||||
- Production: "/"
|
||||
- Local Build: "" (set as empty string)
|
||||
- PyCharm Development Server: "/outer-wilds-new-horizons/docs/out/"
|
||||
- BASE_URL: Base url of the website we're hosting on
|
||||
- Local: Leave blank
|
||||
- Local (but wanting to test open-graph/twitter): "https://nh.outerwildsmods.com/"
|
||||
- Production: "https://nh.outerwildsmods.com/"
|
||||
|
||||
|
||||
## Copy Schemas
|
||||
Create a folder called `schemas` in the content folder and copy all schemas to generate into it, make sure not to add this folder to git.
|
||||
Production build automatically copies over schemas.
|
||||
|
||||
## Generating
|
||||
Run `generate.py` with pipenv
|
||||
```shell
|
||||
pipenv run python generate.py
|
||||
```
|
||||
|
||||
## Opening
|
||||
- Production: Go to the site
|
||||
- Local: Open `out/index.html`
|
||||
- PyCharm Development Server: Right click `out/index.html` -> Open In -> Browser -> Default
|
||||
@ -1,10 +1,17 @@
|
||||
{% if dumb %}
|
||||
{% from 'macros.jinja2' import external_link, is_active_page, nav_item with context %}
|
||||
{% else %}
|
||||
{% from 'base/macros.jinja2' import external_link, is_active_page, nav_item with context %}
|
||||
{% endif %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>New Horizons Documentation | {{ page.title|title }}</title>
|
||||
{% if dumb %}
|
||||
{% include "meta.jinja2" %}
|
||||
{% else %}
|
||||
{% include "base/meta.jinja2" %}
|
||||
{% endif %}
|
||||
<link href="https://bootswatch.com/5/darkly/bootstrap.min.css"
|
||||
crossorigin="anonymous" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
|
||||
@ -18,40 +25,38 @@
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-2">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">New Horizons</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
|
||||
<a class="navbar-brand" href="{{ 'home'|route }}" aria-label="Home">
|
||||
<img width="29" height="29" src="{{ "fav/favicon-96x96.png"|static }}" alt="New Horizons Logo" class="d-inline-block align-text-top me-2"/>
|
||||
New Horizons</a>
|
||||
<button class="navbar-toggler align-text-middle" type="button" data-bs-toggle="collapse"
|
||||
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="/">Home</a>
|
||||
</li>
|
||||
{% for nav_page in pages %}
|
||||
{{ nav_item(nav_page.title|title, nav_page.title|route) }}
|
||||
{% endfor %}
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
|
||||
<a class="nav-link {% if page in schemas %}active{% endif %} dropdown-toggle" {% if page in schemas %}aria-current="page"{% endif %} href="#" id="navbarDropdown" role="button"
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Schemas
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
{% for schema in schemas %}
|
||||
<li><a class="dropdown-item"
|
||||
href="/schemas/{{ schema.out_name }}.html">{{ schema.title|title }}</a></li>
|
||||
href="{{ schema.title|route }}">{{ schema.title|title }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav mb-2 mb-lg-0">
|
||||
<ul class="navbar-nav mb-2 ms-md-auto mb-lg-0">
|
||||
<li class="nav-item me-2">
|
||||
<a class="link-light" href="https://github.com/xen-42/outer-wilds-new-horizons">
|
||||
<i class="bi-github"></i>
|
||||
</a>
|
||||
{{ external_link("<i class=\"bi-github\"></i><small class=\"d-lg-none ms-2\">GitHub</small>", "https://github.com/xen-42/outer-wilds-new-horizons", "nav-link p-2 fs-5") }}
|
||||
</li>
|
||||
<li class="nav-item me-2">
|
||||
<a class="link-light" href="https://github.com/xen-42/outer-wilds-new-horizons">
|
||||
<i class="bi-discord"></i>
|
||||
</a>
|
||||
{{ external_link("<i class=\"bi-discord\"></i><small class=\"d-lg-none ms-2\">Discord</small>", "https://discord.gg/9vE5aHxcF9", "nav-link p-2 fs-5") }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -59,7 +64,7 @@
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
<div class="container-fluid">
|
||||
<div class="container-lg">
|
||||
{% block content %} {% endblock %}
|
||||
</div>
|
||||
</main>
|
||||
13
docs/content/base/breadcrumbs.jinja2
Normal file
@ -0,0 +1,13 @@
|
||||
<div class="breadcrumbs">
|
||||
{% for node in schema.nodes_from_root %}
|
||||
{% if loop.first %}
|
||||
Root
|
||||
{% else %}
|
||||
<a href="#{{ node.html_id }}"
|
||||
onclick="anchorLink('{{ node.html_id }}')">{{ node.name_for_breadcrumbs | upper_first }}</a>
|
||||
{% endif %}
|
||||
{% if not loop.last %}
|
||||
<i class="bi-arrow-right-short"></i>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -52,7 +52,7 @@
|
||||
{{ content(schema.kw_any_of.array_items[0]) }}
|
||||
{% else %}
|
||||
{% if schema.explicit_no_additional_properties %}
|
||||
{{ " " }}<span class="badge badge-info no-additional">No Additional Properties</span>
|
||||
{{ " " }}<span class="badge bg-info no-additional">No Additional Properties</span>
|
||||
{% endif %}
|
||||
|
||||
{# Combining: allOf, anyOf, oneOf, not #}
|
||||
11
docs/content/base/macros.jinja2
Normal file
@ -0,0 +1,11 @@
|
||||
{% macro external_link(display_name, link, class) %}
|
||||
<a class="{{ class|default("") }}" target="_blank" rel="noopener" href="{{ link }}">{{ display_name|safe }}</a>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro is_active_page(title) %}{% if title == page.title %}active{% endif %}{% endmacro %}
|
||||
|
||||
{% macro nav_item(title, href) %}
|
||||
<li class="nav-item">
|
||||
<a href="{{ href }}" class="nav-link {% if title == page.title %}active{% endif %}" {% if title == page.title %}aria-current="page"{% endif %}>{{ title|title }}</a>
|
||||
</li>
|
||||
{% endmacro %}
|
||||
61
docs/content/base/meta.jinja2
Normal file
@ -0,0 +1,61 @@
|
||||
{# Macros #}
|
||||
{% macro og(name, content) %}<meta property="og:{{ name }}" content="{{ content }}"/>{% endmacro %}
|
||||
{% macro tw(name, content) %}<meta name="twitter:{{ name }}" content="{{ content }}"/>{% endmacro %}
|
||||
{% macro fav(filename) %}{{ ("fav/" + filename)|static }}{% endmacro %}
|
||||
|
||||
{# Variable Declarations #}
|
||||
{% if page.title|lower == 'home' %}
|
||||
{% set title="New Horizons Documentation" %}
|
||||
{% else %}
|
||||
{% set title="New Horizons Documentation | " + page.title|title %}
|
||||
{% endif %}
|
||||
{% set desc="Documentation for creating planets with the New Horizons mod for Outer Wilds" %}
|
||||
{% if page.description %}
|
||||
{% set desc=page.description %}
|
||||
{% endif %}
|
||||
{% set img="images/home/home_logo.png"|static|full_url %}
|
||||
{% set theme_color="#222222" %}
|
||||
|
||||
{# Meta Info #}
|
||||
<meta charset="UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>{{ title }}</title>
|
||||
<meta name="keywords" content="New Horizons, Outer Wilds, Modding, C#, Unity" />
|
||||
<meta name="description" content="{{ desc }}"/>
|
||||
|
||||
{# OpenGraph Info #}
|
||||
{{ og("type", "website") }}
|
||||
{{ og("title", title) }}
|
||||
{{ og("description", desc) }}
|
||||
{{ og("url", page.title|route|full_url) }}
|
||||
{{ og("image", img) }}
|
||||
{{ og("image:alt", desc) }}
|
||||
|
||||
{# Twitter Info #}
|
||||
{{ tw("title", title) }}
|
||||
{{ tw("description", desc) }}
|
||||
{{ tw("card", "summary_large_image") }}
|
||||
{{ tw("image", img) }}
|
||||
|
||||
|
||||
{# Favicons #}
|
||||
<link rel="apple-touch-icon" sizes="57x57" href="{{ fav('apple-icon-57x57.png') }}">
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="{{ fav('apple-icon-60x60.png') }}">
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="{{ fav('apple-icon-72x72.png') }}">
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="{{ fav('apple-icon-76x76.png') }}">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="{{ fav("apple-icon-114x114.png") }}">
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="{{ fav("apple-icon-120x120.png") }}">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="{{ fav("apple-icon-144x144.png") }}">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="{{ fav("apple-icon-152x152.png") }}">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="{{ fav("apple-icon-180x180.png") }}">
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="{{ fav("android-icon-192x192.png") }}">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="{{ fav("favicon-32x32.png") }}">
|
||||
<link rel="icon" type="image/png" sizes="96x96" href="{{ fav("favicon-96x96.png") }}">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="{{ fav("favicon-16x16.png") }}">
|
||||
<link rel="manifest" href="{{ "manifest.json"|static }}">
|
||||
<meta name="msapplication-config" content="{{ "fav/browserconfig.xml"|static }}" />
|
||||
<meta name="msapplication-TileColor" content="{{ theme_color }}">
|
||||
<meta name="msapplication-TileImage" content="{{ fav("ms-icon-144x144.png") }}">
|
||||
<meta name="theme-color" data-react-helmet="true" content="{{ theme_color }}">
|
||||
|
||||
16
docs/content/base/page_template.jinja2
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends "base/base.jinja2" %}
|
||||
|
||||
{% block resources %}
|
||||
<link rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/styles/github-dark-dimmed.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script>
|
||||
<script>hljs.highlightAll();</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{{ content|markdown }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -1,21 +1,21 @@
|
||||
{%- if schema.kw_min_items -%}
|
||||
{{ restriction("Must contain a minimum of <code>" ~ schema.kw_min_items.literal ~ "</code> items", "min-items", schema.kw_min_items.html_id) }}
|
||||
{%- endif -%}
|
||||
{%- if schema.kw_max_items -%}
|
||||
{{ restriction("Must contain a maximum of <code>" ~ schema.kw_max_items.literal ~ "</code> items", "max-items", schema.kw_max_items.html_id) }}
|
||||
{%- endif -%}
|
||||
{%- if schema.kw_unique_items and schema.kw_unique_items.literal == True -%}
|
||||
{% if schema.kw_min_items %}
|
||||
{{ restriction("Must contain a minimum of <code>" ~ schema.kw_min_items.literal ~ "</code> Items", "min-items", schema.kw_min_items.html_id) }}
|
||||
{% endif %}
|
||||
{% if schema.kw_max_items %}
|
||||
{{ restriction("Must contain a maximum of <code>" ~ schema.kw_max_items.literal ~ "</code> Items", "max-items", schema.kw_max_items.html_id) }}
|
||||
{% endif %}
|
||||
{% if schema.kw_unique_items and schema.kw_unique_items.literal == True %}
|
||||
{{ restriction("All items must be unique", "unique-items", schema.kw_unique_items.html_id) }}
|
||||
{%- endif -%}
|
||||
{%- if schema.array_items_def -%}
|
||||
{% endif %}
|
||||
{% if schema.array_items_def %}
|
||||
<h4>Each item of this array must be:</h4>
|
||||
<div class="card">
|
||||
<div class="card-body items-definition" id="{{ schema.array_items_def.html_id }}">
|
||||
{{ content(schema.array_items_def) }}
|
||||
</div>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{%- if schema.tuple_validation_items -%}
|
||||
{% endif %}
|
||||
{% if schema.tuple_validation_items %}
|
||||
<h4>Tuple Validation</h4>
|
||||
{% for item in schema.tuple_validation_items %}
|
||||
<h5>Item at {{ loop.index }} must be:</h5>
|
||||
@ -25,12 +25,12 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{%- endif -%}
|
||||
{%- if schema.kw_contains and schema.kw_contains.literal != {} -%}
|
||||
{% endif %}
|
||||
{% if schema.kw_contains and schema.kw_contains.literal != {} %}
|
||||
<h4>At least one of the items must be:</h4>
|
||||
<div class="card">
|
||||
<div class="card-body items-contain-definition" id="{{ schema.kw_contains.html_id }}">
|
||||
{{ content(schema.kw_contains) }}
|
||||
</div>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{% endif %}
|
||||
@ -1,5 +1,5 @@
|
||||
<h2 class="handle">
|
||||
<label>Conditional Subschema</label>
|
||||
<label>Conditional Sub-schema</label>
|
||||
</h2>
|
||||
<p>If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected.
|
||||
Otherwise, the conditions in the "Else" tab should be respected.</p>
|
||||
@ -2,17 +2,17 @@
|
||||
<div class="badge badge-secondary">Example{% if examples|length > 1 %}s{% endif %}:</div>
|
||||
<br/>
|
||||
|
||||
{%- for example in examples -%}
|
||||
{%- set example_id = schema.html_id ~ "_ex" ~ loop.index -%}
|
||||
{%- set example_is_long = example is not description_short -%}
|
||||
{%- if example_is_long -%}
|
||||
{% for example in examples %}
|
||||
{% set example_id = schema.html_id ~ "_ex" ~ loop.index %}
|
||||
{% set example_is_long = example is not description_short %}
|
||||
{% if example_is_long %}
|
||||
<button class="btn btn-light example-show collapsed" data-toggle="collapse" data-target="#{{ example_id }}" aria-controls="{{ example_id }}"></button>
|
||||
{%- endif -%}
|
||||
{% endif %}
|
||||
<div id="{{ example_id }}" class="{% if example_is_long %}collapse {% endif %}jumbotron examples">
|
||||
{%- if not examples_as_yaml -%}
|
||||
{% if not examples_as_yaml %}
|
||||
{{ example | highlight_json_example }}
|
||||
{%- else -%}
|
||||
{% else %}
|
||||
{{ example | highlight_yaml_example }}
|
||||
{%- endif -%}
|
||||
{% endif %}
|
||||
</div>
|
||||
{%- endfor -%}
|
||||
{% endfor %}
|
||||
@ -13,7 +13,7 @@
|
||||
{% if sub_property.is_additional_properties %}
|
||||
<em>
|
||||
{% endif %}
|
||||
<span class="property-nam align-middle pb-1">{{ sub_property.property_display_name | lowerfirst | escape }}</span>
|
||||
<span class="property-nam align-middle pb-1">{{ sub_property.property_display_name | upper_first | escape }}</span>
|
||||
{% if sub_property.is_additional_properties %}
|
||||
</em>
|
||||
{% endif %}
|
||||
@ -0,0 +1,11 @@
|
||||
{% set undocumented_required_properties = schema | get_undocumented_required_properties %}
|
||||
{% if undocumented_required_properties %}
|
||||
<div class="enum-value">
|
||||
<h4>The following properties are required:</h4>
|
||||
<ul class="list-group">
|
||||
{% for required_property in undocumented_required_properties %}
|
||||
<li class="list-group-item required-property">{{ required_property }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
@ -1,25 +1,25 @@
|
||||
<h2 class="handle">
|
||||
<label>{% if operator == "allOf" -%}All of{% elif operator == "anyOf" -%}Any of{% elif operator == "oneOf" -%}One of{% endif -%}</label>
|
||||
<label>{% if operator == "allOf" %}All of{% elif operator == "anyOf" %}Any of{% elif operator == "oneOf" %}One of{% endif %}</label>
|
||||
</h2>
|
||||
{%- set tab_label = "Option" -%}
|
||||
{%- if operator == "allOf" -%}
|
||||
{%- set tab_label = "Requirement" -%}
|
||||
{%- endif -%}
|
||||
{% set tab_label = "Option" %}
|
||||
{% if operator == "allOf" %}
|
||||
{% set tab_label = "Requirement" %}
|
||||
{% endif %}
|
||||
<ul class="nav nav-tabs" id="tabs{{ current_node.html_id }}_{{ operator }}" role="tablist">
|
||||
{%- for node in current_node.array_items -%}
|
||||
{% for node in current_node.array_items %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if loop.index == 1 -%}active {% endif -%} {{ operator }}-option"
|
||||
<a class="nav-link {% if loop.index == 1 %}active {% endif %} {{ operator }}-option"
|
||||
id="{{ node.html_id }}" data-toggle="tab" href="#tab-pane_{{ node.html_id }}" role="tab"
|
||||
onclick="setAnchor('#{{ node.html_id }}')"
|
||||
>{{ node.definition_name or tab_label ~ " " ~ loop.index }}</a>
|
||||
</li>
|
||||
{%- endfor -%}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="tab-content card">
|
||||
{%- for node in current_node.array_items -%}
|
||||
<div class="tab-pane fade card-body {% if loop.index == 1 -%}active show{% endif -%}"
|
||||
{% for node in current_node.array_items %}
|
||||
<div class="tab-pane fade card-body {% if loop.index == 1 %}active show{% endif %}"
|
||||
id="tab-pane_{{ node.html_id }}" role="tabpanel">
|
||||
{{ content(node) }}
|
||||
</div>
|
||||
{%- endfor -%}
|
||||
{% endfor %}
|
||||
</div>
|
||||
11
docs/content/browserconfig.jinja2
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<browserconfig>
|
||||
<msapplication>
|
||||
<tile>
|
||||
<square70x70logo src="{{ "fav/ms-icon-70x70.png"|static }}"/>
|
||||
<square150x150logo src="{{ "fav/ms-icon-150x150.png"|static }}"/>
|
||||
<square310x310logo src="{{ "fav/ms-icon-70x70.png"|static }}"/>
|
||||
<TileColor>#222222</TileColor>
|
||||
</tile>
|
||||
</msapplication>
|
||||
</browserconfig>
|
||||
21
docs/content/pages/home.md
Normal file
@ -0,0 +1,21 @@
|
||||
Title: Home
|
||||
Out-File: index
|
||||
Sort-Priority: 100
|
||||
|
||||

|
||||
|
||||
# Welcome!
|
||||
|
||||
This is the official documentation for [New Horizons](https://github.com/xen-42/outer-wilds-new-horizons)
|
||||
|
||||
## Getting Started
|
||||
|
||||
There is a template [here](https://github.com/xen-42/ow-new-horizons-config-template) if you want to release your own planet mod using configs. You can learn how the configs work by picking apart the [Real Solar System](https://github.com/xen-42/outer-wilds-real-solar-system) mod or the [New Horizons Examples](https://github.com/xen-42/ow-new-horizons-examples) mod.
|
||||
|
||||
Planets are created using a JSON file format structure, and placed in a folder called planets (or in any subdirectory of it) in the location where New Horizons is installed (by default this folder doesn't exist, you have to create it within the xen.NewHorizons directory).
|
||||
|
||||
To locate this directory, click the "⋮" symbol next to "New Horizons" in the Outer Wilds Mod Manager and then click "show in explorer" in the pop-up.
|
||||
|
||||

|
||||
|
||||

|
||||
4
docs/content/robots.jinja2
Normal file
@ -0,0 +1,4 @@
|
||||
User-Agent: *
|
||||
Allow: /
|
||||
|
||||
Sitemap: {{ "/sitemap.xml"|full_url }}
|
||||
11
docs/content/sitemap.jinja2
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
||||
{% for item in content %}
|
||||
<url>
|
||||
<loc>{{ item.out_path|string|replace('\\', '/')|full_url }}</loc>
|
||||
<priority>{{ item.sort_priority / 100 }}</priority>
|
||||
</url>
|
||||
{% endfor %}
|
||||
</urlset>
|
||||
BIN
docs/content/static/fav/android-icon-144x144.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
docs/content/static/fav/android-icon-192x192.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
docs/content/static/fav/android-icon-36x36.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
docs/content/static/fav/android-icon-48x48.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
docs/content/static/fav/android-icon-72x72.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
docs/content/static/fav/android-icon-96x96.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
docs/content/static/fav/apple-icon-114x114.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
docs/content/static/fav/apple-icon-120x120.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
docs/content/static/fav/apple-icon-144x144.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
docs/content/static/fav/apple-icon-152x152.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
docs/content/static/fav/apple-icon-180x180.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
docs/content/static/fav/apple-icon-57x57.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
docs/content/static/fav/apple-icon-60x60.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
docs/content/static/fav/apple-icon-72x72.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
docs/content/static/fav/apple-icon-76x76.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
docs/content/static/fav/apple-icon-precomposed.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
docs/content/static/fav/apple-icon.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
docs/content/static/fav/favicon-16x16.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
docs/content/static/fav/favicon-32x32.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
docs/content/static/fav/favicon-96x96.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
docs/content/static/fav/favicon.ico
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
49
docs/content/static/fav/manifest.json
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/web-manifest-combined.json",
|
||||
"name": "New Horizons Docs",
|
||||
"short_name": "NH Docs",
|
||||
"categories": ["games", "utilities"],
|
||||
"start_url": ".",
|
||||
"theme_color": "#333333",
|
||||
"background_color": "#222222",
|
||||
"lang": "en-US",
|
||||
"description": "Documentation for creating planets with the New Horizons mod for Outer Wilds",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/fav/android-icon-36x36.png",
|
||||
"sizes": "36x36",
|
||||
"type": "image/png",
|
||||
"density": "0.75"
|
||||
},
|
||||
{
|
||||
"src": "/fav/android-icon-48x58.png",
|
||||
"sizes": "48x48",
|
||||
"type": "image/png",
|
||||
"density": "1.0"
|
||||
},
|
||||
{
|
||||
"src": "/fav/android-icon-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png",
|
||||
"density": "1.5"
|
||||
},
|
||||
{
|
||||
"src": "/fav/android-icon-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png",
|
||||
"density": "2.0"
|
||||
},
|
||||
{
|
||||
"src": "/fav/android-icon-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png",
|
||||
"density": "3.0"
|
||||
},
|
||||
{
|
||||
"src": "/fav/android-icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"density": "4.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
docs/content/static/fav/ms-icon-144x144.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
docs/content/static/fav/ms-icon-150x150.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
docs/content/static/fav/ms-icon-310x310.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
docs/content/static/fav/ms-icon-70x70.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 558 KiB After Width: | Height: | Size: 558 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@ -1,17 +0,0 @@
|
||||
<div class="breadcrumbs">
|
||||
{%- for node in schema.nodes_from_root -%}
|
||||
{%- if loop.first -%}
|
||||
root
|
||||
{%- else -%}
|
||||
<a href="#{{ node.html_id }}" onclick="anchorLink('{{ node.html_id }}')">{{ node.name_for_breadcrumbs | lowerfirst }}</a>
|
||||
{%- endif -%}
|
||||
{%- if not loop.last %}
|
||||
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-right-short" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8z"
|
||||
/>
|
||||
</svg>
|
||||
{% endif -%}
|
||||
{%- endfor -%}
|
||||
</div>
|
||||
@ -1,46 +0,0 @@
|
||||
{% extends "base.jinja2" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row mb-3">
|
||||
<div class="col text-center">
|
||||
<img class="img-fluid" src="/images/home/home_logo.png" alt="New Horizons Logo"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h1>Welcome!</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p>This is the official documentation for <a target="_blank" rel="noopener" href="https://github.com/xen-42/outer-wilds-new-horizons">New Horizons</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h2>Getting Started</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p>There is a template <a href="https://github.com/xen-42/ow-new-horizons-config-template" rel="noopener" target="_blank">here</a> if you want to release your own planet mod using configs. You can learn how the configs work by picking apart the <a href="https://github.com/xen-42/outer-wilds-real-solar-system" rel="noopener" target="_blank">Real Solar System</a> mod or the <a href="https://github.com/xen-42/ow-new-horizons-examples" rel="noopener" target="_blank">New Horizons Examples mod</a>.</p>
|
||||
<p>Planets are created using a JSON file format structure, and placed in a folder called planets (or in any sub-directory of it) in the location where New Horizons is installed (by default this folder doesn't exist, you have to create it within the xen.NewHorizons directory).</p>
|
||||
<p>To locate this directory, click the "⋮" symbol next to "New Horizons" in the Outer Wilds Mod Manager and then click "show in explorer" in the pop-up.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<figure class="figure">
|
||||
<img src="/images/home/mod_manager_dots.png" class="figure-img img-fluid rounded" alt="Click the three dots in the mod manager">
|
||||
<figcaption class="figure-caption text-end">Click the ⋮</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
<div class="col">
|
||||
<figure class="figure">
|
||||
<img src="/images/home/create_planets.png" class="figure-img img-fluid rounded" alt="Create a new folder named "planets"">
|
||||
<figcaption class="figure-caption text-end">Create a new folder named "planets"</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
{%- set undocumented_required_properties = schema | get_undocumented_required_properties -%}
|
||||
{%- if undocumented_required_properties-%}
|
||||
<div class="enum-value">
|
||||
<h4>The following properties are required:</h4>
|
||||
<ul class="list-group">
|
||||
{%- for required_property in undocumented_required_properties -%}
|
||||
<li class="list-group-item required-property">{{ required_property }}</li>
|
||||
{%- endfor -%}
|
||||
</ul>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
144
docs/generate.py
@ -1,88 +1,90 @@
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from shutil import copytree, rmtree
|
||||
|
||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
||||
from json_schema_for_humans.schema.schema_importer import get_schemas_to_render
|
||||
from json_schema_for_humans.generate import generate_from_filename, GenerationConfiguration, generate_schemas_doc, \
|
||||
copy_additional_files_to_target
|
||||
from json_schema_for_humans.template_renderer import TemplateRenderer, _minify
|
||||
from jinja2 import Environment, select_autoescape, FileSystemLoader
|
||||
from markupsafe import Markup
|
||||
from json_schema_for_humans.generate import GenerationConfiguration
|
||||
from markdown import Markdown
|
||||
|
||||
from lib.BootstrapExtension import BootstrapExtension
|
||||
from lib.Schema import Schema
|
||||
from lib.Page import Page
|
||||
|
||||
OUT_DIR = os.getenv("OUT_DIR", "/")
|
||||
BASE_URL = os.getenv("BASE_URL", "")
|
||||
|
||||
if Path("out/").exists():
|
||||
rmtree("out/", ignore_errors=True)
|
||||
|
||||
copytree("content/static", "out")
|
||||
os.makedirs("out/schemas", exist_ok=True)
|
||||
|
||||
env = Environment(
|
||||
loader=PackageLoader('docs_templates', 'templates'),
|
||||
loader=FileSystemLoader("content"),
|
||||
autoescape=select_autoescape(['jinja2'])
|
||||
)
|
||||
|
||||
env.filters["lowerfirst"] = lambda x: x[0].lower() + x[1:]
|
||||
markdown_settings = {
|
||||
'extensions': ['extra', 'meta', BootstrapExtension()]
|
||||
}
|
||||
|
||||
home = env.get_template("base.jinja2")
|
||||
schema_settings = GenerationConfiguration(custom_template_path="content/base/schema_base.jinja2")
|
||||
schema_settings.link_to_reused_ref = False
|
||||
|
||||
md = Markdown(**markdown_settings)
|
||||
|
||||
env.filters["upper_first"] = lambda x: x[0].upper() + x[1:]
|
||||
env.filters["markdown"] = lambda text: Markup(md.convert(text))
|
||||
env.filters["static"] = lambda path: str(Path(OUT_DIR, path).as_posix())
|
||||
|
||||
pages_paths = Path("content/pages").glob("**/*.md")
|
||||
schemas_paths = Path("content/schemas").glob("**/*.json")
|
||||
|
||||
router = {}
|
||||
|
||||
env.filters['route'] = lambda title: router.get(title.lower(), "#")
|
||||
env.filters['full_url'] = lambda relative: BASE_URL + (relative[1:] if relative[0] == "/" else relative)
|
||||
|
||||
pages = []
|
||||
schemas = []
|
||||
|
||||
for page_path in pages_paths:
|
||||
new_page = Page(page_path, env, markdown_settings)
|
||||
router[new_page.title.lower()] = OUT_DIR + str(new_page.out_path.relative_to('out/'))
|
||||
pages.append(new_page)
|
||||
|
||||
for schema_path in schemas_paths:
|
||||
new_schema = Schema(schema_path, env, schema_settings)
|
||||
router[new_schema.title.lower()] = OUT_DIR + "schemas/" + str(new_schema.out_path.relative_to("out/schemas/"))
|
||||
schemas.append(new_schema)
|
||||
|
||||
content = pages + schemas
|
||||
|
||||
if OUT_DIR != "":
|
||||
router['home'] = OUT_DIR
|
||||
|
||||
pages.sort(key=lambda p: p.sort_priority, reverse=True)
|
||||
schemas.sort(key=lambda s: s.title)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Page:
|
||||
in_name: str
|
||||
out_name: str
|
||||
title: str
|
||||
|
||||
def render(self, **options):
|
||||
template = env.get_template(self.in_name + ".jinja2")
|
||||
options.update({'page': self})
|
||||
rendered_string = template.render(**options)
|
||||
with open("out/" + self.out_name + ".html", 'w+', encoding="utf-8") as file:
|
||||
file.write(rendered_string)
|
||||
def log_build(in_path, out_path):
|
||||
print("Building:", str(in_path), "->", str(out_path))
|
||||
|
||||
|
||||
config = GenerationConfiguration(custom_template_path="docs_templates/templates/schema_base.jinja2")
|
||||
config.link_to_reused_ref = False
|
||||
def build_meta(in_path, out_path):
|
||||
log_build(in_path, out_path)
|
||||
meta_template = env.get_template(str(in_path.relative_to("content/")))
|
||||
with Path("out/", out_path).open(mode="w+", encoding="utf-8") as file:
|
||||
file.write(meta_template.render(content=content))
|
||||
|
||||
|
||||
@dataclass
|
||||
class Schema(Page):
|
||||
print("Building Meta Files")
|
||||
build_meta(Path("content/sitemap.jinja2"), Path("sitemap.xml"))
|
||||
build_meta(Path("content/robots.jinja2"), Path("robots.txt"))
|
||||
build_meta(Path("content/browserconfig.jinja2"), Path("fav/browserconfig.xml"))
|
||||
|
||||
def render(self, **options):
|
||||
schemas = get_schemas_to_render("schemas/" + self.in_name + ".json", Path("out/schemas/" + self.out_name + ".html"), ".html")
|
||||
template_renderer = TemplateRenderer(config)
|
||||
template_renderer.render = lambda inter: template_override(template_renderer, inter, self)
|
||||
generate_schemas_doc(schemas, template_renderer)
|
||||
copy_additional_files_to_target(schemas, config)
|
||||
|
||||
|
||||
pages = (
|
||||
Page(in_name="home", out_name="index", title="Home"),
|
||||
Schema(in_name="schema", out_name="body_schema", title="Body"),
|
||||
Schema(in_name="star_system_schema", out_name="star_system_schema", title="Star System"),
|
||||
Schema(in_name="translation_schema", out_name="translation_schema", title="Translation")
|
||||
)
|
||||
|
||||
schemas = [s for s in pages if s.__class__.__name__ == "Schema"]
|
||||
|
||||
|
||||
def template_override(template, intermediate_schema, inter_page):
|
||||
template.template.environment.filters["lowerfirst"] = env.filters["lowerfirst"]
|
||||
rendered = template.template.render(schema=intermediate_schema, config=config, schemas=schemas, page=inter_page, title=inter_page.title + " Schema")
|
||||
|
||||
if template.config.minify:
|
||||
rendered = _minify(rendered, template.config.template_is_markdown, template.config.template_is_html)
|
||||
|
||||
return rendered
|
||||
|
||||
|
||||
print("Initializing")
|
||||
|
||||
|
||||
if os.path.exists("out"):
|
||||
rmtree("out")
|
||||
|
||||
print("Copying Static")
|
||||
|
||||
copytree("static", "out")
|
||||
|
||||
os.makedirs("out/schemas")
|
||||
|
||||
print("Rendering Pages")
|
||||
|
||||
for page in pages:
|
||||
page.render(schemas=schemas)
|
||||
|
||||
print("Done")
|
||||
print ("Building Pages")
|
||||
for item in content:
|
||||
log_build(item.in_path, item.out_path)
|
||||
item.render(page=item, pages=pages, schemas=schemas)
|
||||
|
||||
33
docs/lib/BootstrapExtension.py
Normal file
@ -0,0 +1,33 @@
|
||||
from markdown import Extension
|
||||
from markdown.treeprocessors import Treeprocessor
|
||||
|
||||
class BootstrapExtension(Extension):
|
||||
def extendMarkdown(self, md, md_globals):
|
||||
md.registerExtension(self)
|
||||
self.processor = BootstrapTreeProcessor()
|
||||
self.processor.md = md
|
||||
self.processor.config = self.getConfigs()
|
||||
md.treeprocessors.add('bootstrap', self.processor, '_end')
|
||||
|
||||
|
||||
classes = {
|
||||
'img': "img-fluid rounded mx-auto d-flex",
|
||||
'table': "table-striped"
|
||||
}
|
||||
|
||||
|
||||
def process(node):
|
||||
if node.tag in classes.keys():
|
||||
node.set("class", classes[node.tag])
|
||||
for child in node:
|
||||
process(child)
|
||||
|
||||
|
||||
|
||||
class BootstrapTreeProcessor(Treeprocessor):
|
||||
|
||||
def run(self, node):
|
||||
for child in node:
|
||||
process(child)
|
||||
return node
|
||||
|
||||
42
docs/lib/Page.py
Normal file
@ -0,0 +1,42 @@
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from jinja2 import Environment
|
||||
from markdown import Markdown
|
||||
|
||||
|
||||
@dataclass
|
||||
class Page:
|
||||
sort_priority: int
|
||||
in_path: Path
|
||||
out_path: Path
|
||||
title: str
|
||||
description: str | None
|
||||
env: Environment
|
||||
|
||||
def __init__(self, path, environment, options):
|
||||
self.in_path = path
|
||||
self.env = environment
|
||||
md = Markdown(**options)
|
||||
with path.open() as file:
|
||||
md.convert(file.read())
|
||||
self.sort_priority = int(md.Meta.get('sort-priority', '20')[0])
|
||||
self.title = md.Meta.get('title', (path.stem,))[0]
|
||||
self.description = md.Meta.get('description', None)
|
||||
outfile: Path
|
||||
try:
|
||||
outfile = Path("out/", path.relative_to(Path("content/pages/")).parent,
|
||||
md.Meta['out-file'][0] + '.html')
|
||||
except KeyError:
|
||||
outfile = Path("out/", path.relative_to(Path("content/pages/"))).with_suffix('.html')
|
||||
self.out_path = outfile
|
||||
|
||||
def render(self, **options):
|
||||
template = self.env.get_template(str(self.in_path.relative_to(Path("content/")).as_posix()))
|
||||
page_template = self.env.get_template("base/page_template.jinja2")
|
||||
rendered_string = page_template.render(content=template.render(**options), **options)
|
||||
|
||||
self.out_path.parent.mkdir(mode=511, parents=True, exist_ok=True)
|
||||
|
||||
with self.out_path.open(mode='w+', encoding='utf-8') as file:
|
||||
file.write(rendered_string)
|
||||
43
docs/lib/Schema.py
Normal file
@ -0,0 +1,43 @@
|
||||
import json
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from json_schema_for_humans.generate import generate_schemas_doc, copy_additional_files_to_target
|
||||
from json_schema_for_humans.schema.schema_importer import get_schemas_to_render
|
||||
from json_schema_for_humans.template_renderer import TemplateRenderer, _minify
|
||||
from json_schema_for_humans.generation_configuration import GenerationConfiguration
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from lib.Page import Page
|
||||
|
||||
|
||||
@dataclass
|
||||
class Schema(Page):
|
||||
|
||||
config: GenerationConfiguration
|
||||
|
||||
def __init__(self, path, env, options):
|
||||
self.sort_priority = 10
|
||||
self.in_path = path
|
||||
self.config = options
|
||||
self.env = env
|
||||
with path.open() as file:
|
||||
self.title = json.load(file).get('title', path.stem)
|
||||
self.description = "Schema for a " + self.title + " in New Horizons"
|
||||
self.out_path = Path('out/schemas/', self.in_path.relative_to(Path("content/schemas/")).with_name(self.title.replace(" ", "_").lower()).with_suffix(".html"))
|
||||
|
||||
def render(self, **options):
|
||||
schemas = get_schemas_to_render(self.in_path, self.out_path, ".html")
|
||||
template_renderer = TemplateRenderer(self.config)
|
||||
template_renderer.render = lambda inter: self.template_override(template_renderer, inter, **options)
|
||||
generate_schemas_doc(schemas, template_renderer)
|
||||
copy_additional_files_to_target(schemas, self.config)
|
||||
|
||||
def template_override(self, template, intermediate_schema, **options):
|
||||
template.template.environment.filters.update(self.env.filters)
|
||||
rendered = template.template.render(schema=intermediate_schema, dumb=True, config=self.config, title=self.title + " Schema", **options)
|
||||
|
||||
if template.config.minify:
|
||||
rendered = _minify(rendered, template.config.template_is_markdown, template.config.template_is_html)
|
||||
|
||||
return rendered
|
||||
2
docs/static/robots.txt
vendored
@ -1,2 +0,0 @@
|
||||
User-agent: *
|
||||
Allow: /
|
||||