Skip to content

Commit

Permalink
Automate schema building
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Feb 22, 2022
1 parent 8353a4c commit 03f8cb4
Show file tree
Hide file tree
Showing 7 changed files with 17,737 additions and 5,304 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,36 @@ jobs:
coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# see https://github.com/ad-m/github-push-action
jsonschemas:
name: Update JSONSchemas in docs
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install project and dependencies
run: |
pip install .
- name: Create local changes
run: |
mappyfile schema docs/schemas/mapfile-latest.json
mappyfile schema docs/schemas/mapfile-schema-7-6.json --version=7.6
mappyfile schema docs/schemas/mapfile-schema-8-0.json --version=8.0
- name: Commit files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" # user id of the Github Actions account/bot
git config --local user.name "github-actions[bot]"
git commit -m "Update schemas" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
17 changes: 0 additions & 17 deletions docs/schema.txt

This file was deleted.

29 changes: 22 additions & 7 deletions docs/schemas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
Mapfile Schema
==============

The full Mapfile schema is shown below. It can also be downloaded directly from this link - :download:`mapfile.json <schemas/mapfile.json>`.
The full Mapfile schema can be downloaded directly from this link - :download:`mapfile.json <schemas/mapfile-latest.json>`.
The schema stores ``minVersion`` and ``maxVersion`` properties in a ``metadata`` object for each keyword. This allow Mapfiles to be validated against
older or newer releases of MapServer to see if they are still valid.

Other versions available online are:

+ :download:`mapfile.json <schemas/mapfile-schema-8-0.json>`
+ :download:`mapfile.json <schemas/mapfile-schema-7-6.json>`

The Mapfile schema shown below is planned to be proposed as an official Mapfile language schema, subject to voting by the MapServer
PSC (Project Steering Committee). Further details on the schema are outlined in the draft RFC (Request for Comment) at :ref:`rfc123`.

Expand All @@ -33,6 +38,10 @@ The schema can be exported using Python, as shown in the example below:
Creating a Mappyfile Object with Defaults
+++++++++++++++++++++++++++++++++++++++++

If MapServer uses default values for an object, the `create` function can be used to create
a new object using these defaults. For example to output a `MAP` object with default settings
run the following code:

.. code-block:: python
import json
Expand All @@ -42,14 +51,20 @@ Creating a Mappyfile Object with Defaults
print(json.dumps(m, indent=4, sort_keys=True))
mappyfile.dumps(m)
This outputs the following:

.. literalinclude:: schemas/mapfile.json
:language: json

..
.. include:: schemas/map.rst
.. code-block:: mapfile
.. include:: schemas/layer.rst
MAP
ANGLE 0
DEBUG 0
DEFRESOLUTION 72
IMAGETYPE "png"
MAXSIZE 4096
NAME "MS"
RESOLUTION 72
SIZE -1 -1
END
Notes
-----
Expand Down
Loading

0 comments on commit 03f8cb4

Please sign in to comment.