diff --git a/.github/workflows/main.yml b/.github/workflows/docs_build.yml similarity index 51% rename from .github/workflows/main.yml rename to .github/workflows/docs_build.yml index 86c3c9cc..71d7104c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/docs_build.yml @@ -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 diff --git a/.gitignore b/.gitignore index 737cea76..126ed01f 100644 --- a/.gitignore +++ b/.gitignore @@ -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/* \ No newline at end of file +# Docs +docs/out/** +docs/content/schemas/** diff --git a/NewHorizons/schema.json b/NewHorizons/schema.json index e12179d6..c14361aa 100644 --- a/NewHorizons/schema.json +++ b/NewHorizons/schema.json @@ -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 } diff --git a/NewHorizons/star_system_schema.json b/NewHorizons/star_system_schema.json index cf7f702c..52e6e732 100644 --- a/NewHorizons/star_system_schema.json +++ b/NewHorizons/star_system_schema.json @@ -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": { diff --git a/docs/Pipfile b/docs/Pipfile index d3679cdd..db301759 100644 --- a/docs/Pipfile +++ b/docs/Pipfile @@ -6,6 +6,7 @@ name = "pypi" [packages] jinja2 = "*" json-schema-for-humans = "*" +markdown = "*" [dev-packages] diff --git a/docs/Pipfile.lock b/docs/Pipfile.lock index 5f5f7055..5669f72f 100644 --- a/docs/Pipfile.lock +++ b/docs/Pipfile.lock @@ -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", diff --git a/docs/Setup.md b/docs/Setup.md new file mode 100644 index 00000000..74d81e77 --- /dev/null +++ b/docs/Setup.md @@ -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 diff --git a/docs/docs_templates/templates/badge_type.jinja2 b/docs/content/base/badge_type.jinja2 similarity index 100% rename from docs/docs_templates/templates/badge_type.jinja2 rename to docs/content/base/badge_type.jinja2 diff --git a/docs/docs_templates/templates/base.jinja2 b/docs/content/base/base.jinja2 similarity index 54% rename from docs/docs_templates/templates/base.jinja2 rename to docs/content/base/base.jinja2 index 45cf9546..12d603c2 100644 --- a/docs/docs_templates/templates/base.jinja2 +++ b/docs/content/base/base.jinja2 @@ -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 %} + - - - - New Horizons Documentation | {{ page.title|title }} + {% if dumb %} + {% include "meta.jinja2" %} + {% else %} + {% include "base/meta.jinja2" %} + {% endif %} @@ -18,40 +25,38 @@
-
+
{% block content %} {% endblock %}
diff --git a/docs/content/base/breadcrumbs.jinja2 b/docs/content/base/breadcrumbs.jinja2 new file mode 100644 index 00000000..c3c8a92d --- /dev/null +++ b/docs/content/base/breadcrumbs.jinja2 @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/docs/docs_templates/templates/content.jinja2 b/docs/content/base/content.jinja2 similarity index 97% rename from docs/docs_templates/templates/content.jinja2 rename to docs/content/base/content.jinja2 index 8073062d..99dc9385 100644 --- a/docs/docs_templates/templates/content.jinja2 +++ b/docs/content/base/content.jinja2 @@ -52,7 +52,7 @@ {{ content(schema.kw_any_of.array_items[0]) }} {% else %} {% if schema.explicit_no_additional_properties %} - {{ " " }}No Additional Properties + {{ " " }}No Additional Properties {% endif %} {# Combining: allOf, anyOf, oneOf, not #} diff --git a/docs/docs_templates/templates/macro_restriction.jinja2 b/docs/content/base/macro_restriction.jinja2 similarity index 100% rename from docs/docs_templates/templates/macro_restriction.jinja2 rename to docs/content/base/macro_restriction.jinja2 diff --git a/docs/content/base/macros.jinja2 b/docs/content/base/macros.jinja2 new file mode 100644 index 00000000..c6aa2e0d --- /dev/null +++ b/docs/content/base/macros.jinja2 @@ -0,0 +1,11 @@ +{% macro external_link(display_name, link, class) %} + {{ display_name|safe }} +{% endmacro %} + +{% macro is_active_page(title) %}{% if title == page.title %}active{% endif %}{% endmacro %} + +{% macro nav_item(title, href) %} + +{% endmacro %} diff --git a/docs/content/base/meta.jinja2 b/docs/content/base/meta.jinja2 new file mode 100644 index 00000000..0c8e5640 --- /dev/null +++ b/docs/content/base/meta.jinja2 @@ -0,0 +1,61 @@ +{# Macros #} +{% macro og(name, content) %}{% endmacro %} +{% macro tw(name, 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 #} + + + +{{ title }} + + + +{# 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 #} + + + + + + + + + + + + + + + + + + + diff --git a/docs/content/base/page_template.jinja2 b/docs/content/base/page_template.jinja2 new file mode 100644 index 00000000..16003242 --- /dev/null +++ b/docs/content/base/page_template.jinja2 @@ -0,0 +1,16 @@ +{% extends "base/base.jinja2" %} + +{% block resources %} + + + +{% endblock %} + +{% block content %} +
+
+ {{ content|markdown }} +
+
+{% endblock %} diff --git a/docs/docs_templates/templates/schema_base.jinja2 b/docs/content/base/schema_base.jinja2 similarity index 100% rename from docs/docs_templates/templates/schema_base.jinja2 rename to docs/content/base/schema_base.jinja2 diff --git a/docs/docs_templates/templates/schema_doc.min.js b/docs/content/base/schema_doc.min.js similarity index 100% rename from docs/docs_templates/templates/schema_doc.min.js rename to docs/content/base/schema_doc.min.js diff --git a/docs/docs_templates/templates/section_array.jinja2 b/docs/content/base/section_array.jinja2 similarity index 67% rename from docs/docs_templates/templates/section_array.jinja2 rename to docs/content/base/section_array.jinja2 index a676f0d9..ecaa218f 100644 --- a/docs/docs_templates/templates/section_array.jinja2 +++ b/docs/content/base/section_array.jinja2 @@ -1,21 +1,21 @@ -{%- if schema.kw_min_items -%} - {{ restriction("Must contain a minimum of " ~ schema.kw_min_items.literal ~ " items", "min-items", schema.kw_min_items.html_id) }} -{%- endif -%} -{%- if schema.kw_max_items -%} - {{ restriction("Must contain a maximum of " ~ schema.kw_max_items.literal ~ " 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 " ~ schema.kw_min_items.literal ~ " Items", "min-items", schema.kw_min_items.html_id) }} +{% endif %} +{% if schema.kw_max_items %} + {{ restriction("Must contain a maximum of " ~ schema.kw_max_items.literal ~ " 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 %}

Each item of this array must be:

{{ content(schema.array_items_def) }}
-{%- endif -%} -{%- if schema.tuple_validation_items -%} +{% endif %} +{% if schema.tuple_validation_items %}

Tuple Validation

{% for item in schema.tuple_validation_items %}
Item at {{ loop.index }} must be:
@@ -25,12 +25,12 @@ {% endfor %} -{%- endif -%} -{%- if schema.kw_contains and schema.kw_contains.literal != {} -%} +{% endif %} +{% if schema.kw_contains and schema.kw_contains.literal != {} %}

At least one of the items must be:

{{ content(schema.kw_contains) }}
-{%- endif -%} \ No newline at end of file +{% endif %} \ No newline at end of file diff --git a/docs/docs_templates/templates/section_conditional_subschema.jinja2 b/docs/content/base/section_conditional_subschema.jinja2 similarity index 97% rename from docs/docs_templates/templates/section_conditional_subschema.jinja2 rename to docs/content/base/section_conditional_subschema.jinja2 index e543669d..973f8cfa 100644 --- a/docs/docs_templates/templates/section_conditional_subschema.jinja2 +++ b/docs/content/base/section_conditional_subschema.jinja2 @@ -1,5 +1,5 @@

- +

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.

diff --git a/docs/docs_templates/templates/section_description.jinja2 b/docs/content/base/section_description.jinja2 similarity index 100% rename from docs/docs_templates/templates/section_description.jinja2 rename to docs/content/base/section_description.jinja2 diff --git a/docs/docs_templates/templates/section_examples.jinja2 b/docs/content/base/section_examples.jinja2 similarity index 60% rename from docs/docs_templates/templates/section_examples.jinja2 rename to docs/content/base/section_examples.jinja2 index 51675917..ffa40145 100644 --- a/docs/docs_templates/templates/section_examples.jinja2 +++ b/docs/content/base/section_examples.jinja2 @@ -2,17 +2,17 @@
Example{% if examples|length > 1 %}s{% endif %}:

-{%- 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 %} - {%- endif -%} + {% endif %}
- {%- if not examples_as_yaml -%} + {% if not examples_as_yaml %} {{ example | highlight_json_example }} - {%- else -%} + {% else %} {{ example | highlight_yaml_example }} - {%- endif -%} + {% endif %}
-{%- endfor -%} +{% endfor %} diff --git a/docs/docs_templates/templates/section_not.jinja2 b/docs/content/base/section_not.jinja2 similarity index 100% rename from docs/docs_templates/templates/section_not.jinja2 rename to docs/content/base/section_not.jinja2 diff --git a/docs/docs_templates/templates/section_properties.jinja2 b/docs/content/base/section_properties.jinja2 similarity index 97% rename from docs/docs_templates/templates/section_properties.jinja2 rename to docs/content/base/section_properties.jinja2 index 268ad902..c9c8121f 100644 --- a/docs/docs_templates/templates/section_properties.jinja2 +++ b/docs/content/base/section_properties.jinja2 @@ -13,7 +13,7 @@ {% if sub_property.is_additional_properties %} {% endif %} - {{ sub_property.property_display_name | lowerfirst | escape }} + {{ sub_property.property_display_name | upper_first | escape }} {% if sub_property.is_additional_properties %} {% endif %} diff --git a/docs/content/base/section_undocumented_required_properties.jinja2 b/docs/content/base/section_undocumented_required_properties.jinja2 new file mode 100644 index 00000000..7a2bc74f --- /dev/null +++ b/docs/content/base/section_undocumented_required_properties.jinja2 @@ -0,0 +1,11 @@ +{% set undocumented_required_properties = schema | get_undocumented_required_properties %} +{% if undocumented_required_properties %} +
+

The following properties are required:

+ +
+{% endif %} \ No newline at end of file diff --git a/docs/docs_templates/templates/tabbed_section.jinja2 b/docs/content/base/tabbed_section.jinja2 similarity index 54% rename from docs/docs_templates/templates/tabbed_section.jinja2 rename to docs/content/base/tabbed_section.jinja2 index 9cecf4c1..c4949ef4 100644 --- a/docs/docs_templates/templates/tabbed_section.jinja2 +++ b/docs/content/base/tabbed_section.jinja2 @@ -1,25 +1,25 @@

- +

-{%- set tab_label = "Option" -%} -{%- if operator == "allOf" -%} - {%- set tab_label = "Requirement" -%} -{%- endif -%} +{% set tab_label = "Option" %} +{% if operator == "allOf" %} + {% set tab_label = "Requirement" %} +{% endif %}
- {%- for node in current_node.array_items -%} -
{{ content(node) }}
- {%- endfor -%} + {% endfor %}
\ No newline at end of file diff --git a/docs/content/browserconfig.jinja2 b/docs/content/browserconfig.jinja2 new file mode 100644 index 00000000..f2c5238d --- /dev/null +++ b/docs/content/browserconfig.jinja2 @@ -0,0 +1,11 @@ + + + + + + + + #222222 + + + diff --git a/docs/content/pages/home.md b/docs/content/pages/home.md new file mode 100644 index 00000000..1c617176 --- /dev/null +++ b/docs/content/pages/home.md @@ -0,0 +1,21 @@ +Title: Home +Out-File: index +Sort-Priority: 100 + +![New Horizons Logo]({{ 'images/home/home_logo.png'|static }}) + +# 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. + +![Click the three dots in the mod manager]({{ 'images/home/mod_manager_dots.png'|static }}) + +![Create a new folder named "planets"]({{ 'images/home/create_planets.png'|static }}) diff --git a/docs/content/robots.jinja2 b/docs/content/robots.jinja2 new file mode 100644 index 00000000..1d0b0099 --- /dev/null +++ b/docs/content/robots.jinja2 @@ -0,0 +1,4 @@ +User-Agent: * +Allow: / + +Sitemap: {{ "/sitemap.xml"|full_url }} diff --git a/docs/content/sitemap.jinja2 b/docs/content/sitemap.jinja2 new file mode 100644 index 00000000..a3798539 --- /dev/null +++ b/docs/content/sitemap.jinja2 @@ -0,0 +1,11 @@ + + + {% for item in content %} + + {{ item.out_path|string|replace('\\', '/')|full_url }} + {{ item.sort_priority / 100 }} + + {% endfor %} + diff --git a/docs/content/static/fav/android-icon-144x144.png b/docs/content/static/fav/android-icon-144x144.png new file mode 100644 index 00000000..17b6fa7d Binary files /dev/null and b/docs/content/static/fav/android-icon-144x144.png differ diff --git a/docs/content/static/fav/android-icon-192x192.png b/docs/content/static/fav/android-icon-192x192.png new file mode 100644 index 00000000..8d38ba72 Binary files /dev/null and b/docs/content/static/fav/android-icon-192x192.png differ diff --git a/docs/content/static/fav/android-icon-36x36.png b/docs/content/static/fav/android-icon-36x36.png new file mode 100644 index 00000000..ff9772b6 Binary files /dev/null and b/docs/content/static/fav/android-icon-36x36.png differ diff --git a/docs/content/static/fav/android-icon-48x48.png b/docs/content/static/fav/android-icon-48x48.png new file mode 100644 index 00000000..b357eea8 Binary files /dev/null and b/docs/content/static/fav/android-icon-48x48.png differ diff --git a/docs/content/static/fav/android-icon-72x72.png b/docs/content/static/fav/android-icon-72x72.png new file mode 100644 index 00000000..003df7fd Binary files /dev/null and b/docs/content/static/fav/android-icon-72x72.png differ diff --git a/docs/content/static/fav/android-icon-96x96.png b/docs/content/static/fav/android-icon-96x96.png new file mode 100644 index 00000000..dd49d8f6 Binary files /dev/null and b/docs/content/static/fav/android-icon-96x96.png differ diff --git a/docs/content/static/fav/apple-icon-114x114.png b/docs/content/static/fav/apple-icon-114x114.png new file mode 100644 index 00000000..0f3aff02 Binary files /dev/null and b/docs/content/static/fav/apple-icon-114x114.png differ diff --git a/docs/content/static/fav/apple-icon-120x120.png b/docs/content/static/fav/apple-icon-120x120.png new file mode 100644 index 00000000..79eefd2b Binary files /dev/null and b/docs/content/static/fav/apple-icon-120x120.png differ diff --git a/docs/content/static/fav/apple-icon-144x144.png b/docs/content/static/fav/apple-icon-144x144.png new file mode 100644 index 00000000..468e9a14 Binary files /dev/null and b/docs/content/static/fav/apple-icon-144x144.png differ diff --git a/docs/content/static/fav/apple-icon-152x152.png b/docs/content/static/fav/apple-icon-152x152.png new file mode 100644 index 00000000..fe7d9574 Binary files /dev/null and b/docs/content/static/fav/apple-icon-152x152.png differ diff --git a/docs/content/static/fav/apple-icon-180x180.png b/docs/content/static/fav/apple-icon-180x180.png new file mode 100644 index 00000000..2a20d00c Binary files /dev/null and b/docs/content/static/fav/apple-icon-180x180.png differ diff --git a/docs/content/static/fav/apple-icon-57x57.png b/docs/content/static/fav/apple-icon-57x57.png new file mode 100644 index 00000000..5e53e804 Binary files /dev/null and b/docs/content/static/fav/apple-icon-57x57.png differ diff --git a/docs/content/static/fav/apple-icon-60x60.png b/docs/content/static/fav/apple-icon-60x60.png new file mode 100644 index 00000000..a9bb6896 Binary files /dev/null and b/docs/content/static/fav/apple-icon-60x60.png differ diff --git a/docs/content/static/fav/apple-icon-72x72.png b/docs/content/static/fav/apple-icon-72x72.png new file mode 100644 index 00000000..003df7fd Binary files /dev/null and b/docs/content/static/fav/apple-icon-72x72.png differ diff --git a/docs/content/static/fav/apple-icon-76x76.png b/docs/content/static/fav/apple-icon-76x76.png new file mode 100644 index 00000000..8667162a Binary files /dev/null and b/docs/content/static/fav/apple-icon-76x76.png differ diff --git a/docs/content/static/fav/apple-icon-precomposed.png b/docs/content/static/fav/apple-icon-precomposed.png new file mode 100644 index 00000000..d0ee742f Binary files /dev/null and b/docs/content/static/fav/apple-icon-precomposed.png differ diff --git a/docs/content/static/fav/apple-icon.png b/docs/content/static/fav/apple-icon.png new file mode 100644 index 00000000..d0ee742f Binary files /dev/null and b/docs/content/static/fav/apple-icon.png differ diff --git a/docs/content/static/fav/favicon-16x16.png b/docs/content/static/fav/favicon-16x16.png new file mode 100644 index 00000000..f0fb6adb Binary files /dev/null and b/docs/content/static/fav/favicon-16x16.png differ diff --git a/docs/content/static/fav/favicon-32x32.png b/docs/content/static/fav/favicon-32x32.png new file mode 100644 index 00000000..a07e2f46 Binary files /dev/null and b/docs/content/static/fav/favicon-32x32.png differ diff --git a/docs/content/static/fav/favicon-96x96.png b/docs/content/static/fav/favicon-96x96.png new file mode 100644 index 00000000..d4923279 Binary files /dev/null and b/docs/content/static/fav/favicon-96x96.png differ diff --git a/docs/content/static/fav/favicon.ico b/docs/content/static/fav/favicon.ico new file mode 100644 index 00000000..a943dc7b Binary files /dev/null and b/docs/content/static/fav/favicon.ico differ diff --git a/docs/content/static/fav/manifest.json b/docs/content/static/fav/manifest.json new file mode 100644 index 00000000..be7833ff --- /dev/null +++ b/docs/content/static/fav/manifest.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/docs/content/static/fav/ms-icon-144x144.png b/docs/content/static/fav/ms-icon-144x144.png new file mode 100644 index 00000000..468e9a14 Binary files /dev/null and b/docs/content/static/fav/ms-icon-144x144.png differ diff --git a/docs/content/static/fav/ms-icon-150x150.png b/docs/content/static/fav/ms-icon-150x150.png new file mode 100644 index 00000000..e2534568 Binary files /dev/null and b/docs/content/static/fav/ms-icon-150x150.png differ diff --git a/docs/content/static/fav/ms-icon-310x310.png b/docs/content/static/fav/ms-icon-310x310.png new file mode 100644 index 00000000..d0db66b1 Binary files /dev/null and b/docs/content/static/fav/ms-icon-310x310.png differ diff --git a/docs/content/static/fav/ms-icon-70x70.png b/docs/content/static/fav/ms-icon-70x70.png new file mode 100644 index 00000000..03d36d3d Binary files /dev/null and b/docs/content/static/fav/ms-icon-70x70.png differ diff --git a/docs/static/images/home/create_planets.png b/docs/content/static/images/home/create_planets.png similarity index 100% rename from docs/static/images/home/create_planets.png rename to docs/content/static/images/home/create_planets.png diff --git a/docs/static/images/home/home_logo.png b/docs/content/static/images/home/home_logo.png similarity index 100% rename from docs/static/images/home/home_logo.png rename to docs/content/static/images/home/home_logo.png diff --git a/docs/static/images/home/mod_manager_dots.png b/docs/content/static/images/home/mod_manager_dots.png similarity index 100% rename from docs/static/images/home/mod_manager_dots.png rename to docs/content/static/images/home/mod_manager_dots.png diff --git a/docs/docs_templates/templates/breadcrumbs.jinja2 b/docs/docs_templates/templates/breadcrumbs.jinja2 deleted file mode 100644 index 1f3e65e9..00000000 --- a/docs/docs_templates/templates/breadcrumbs.jinja2 +++ /dev/null @@ -1,17 +0,0 @@ - \ No newline at end of file diff --git a/docs/docs_templates/templates/home.jinja2 b/docs/docs_templates/templates/home.jinja2 deleted file mode 100644 index c9ee2282..00000000 --- a/docs/docs_templates/templates/home.jinja2 +++ /dev/null @@ -1,46 +0,0 @@ -{% extends "base.jinja2" %} - -{% block content %} -
-
- New Horizons Logo -
-
-
-
-

Welcome!

-
-
-
-
-

This is the official documentation for New Horizons

-
-
-
-
-

Getting Started

-
-
-
-
-

There is a template here 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 mod or the New Horizons Examples mod.

-

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).

-

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.

-
-
-
-
-
- Click the three dots in the mod manager -
Click the ⋮
-
-
-
-
- Create a new folder named "planets" -
Create a new folder named "planets"
-
-
-
-{% endblock %} - diff --git a/docs/docs_templates/templates/section_undocumented_required_properties.jinja2 b/docs/docs_templates/templates/section_undocumented_required_properties.jinja2 deleted file mode 100644 index 7e7ceaeb..00000000 --- a/docs/docs_templates/templates/section_undocumented_required_properties.jinja2 +++ /dev/null @@ -1,11 +0,0 @@ -{%- set undocumented_required_properties = schema | get_undocumented_required_properties -%} -{%- if undocumented_required_properties-%} -
-

The following properties are required:

- -
-{%- endif -%} \ No newline at end of file diff --git a/docs/generate.py b/docs/generate.py index fce37d29..4201f541 100644 --- a/docs/generate.py +++ b/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) diff --git a/docs/lib/BootstrapExtension.py b/docs/lib/BootstrapExtension.py new file mode 100644 index 00000000..0a93f093 --- /dev/null +++ b/docs/lib/BootstrapExtension.py @@ -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 + \ No newline at end of file diff --git a/docs/lib/Page.py b/docs/lib/Page.py new file mode 100644 index 00000000..8c8bd689 --- /dev/null +++ b/docs/lib/Page.py @@ -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) diff --git a/docs/lib/Schema.py b/docs/lib/Schema.py new file mode 100644 index 00000000..2b2576c2 --- /dev/null +++ b/docs/lib/Schema.py @@ -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 diff --git a/docs/docs_templates/__init__.py b/docs/lib/__init__.py similarity index 100% rename from docs/docs_templates/__init__.py rename to docs/lib/__init__.py diff --git a/docs/static/robots.txt b/docs/static/robots.txt deleted file mode 100644 index c2a49f4f..00000000 --- a/docs/static/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Allow: /