New docs structure

This commit is contained in:
Darren Eberly
2022-07-07 00:24:52 -04:00
parent 62202b300b
commit c7d5f35bd0
26 changed files with 362 additions and 144 deletions

20
docs/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

24
docs/api/common_types.rst Normal file
View File

@@ -0,0 +1,24 @@
.. _common_types_api:
Common Types
============
This module provides some common types used throughout PyTiled Parser. These are all just NamedTuple
classes provided to make sets of data more clear. As such they can be subscripted like a normal tuple
to get the same values, or you can reference them by name. The values shown here are in the order they
will be in the final tuple.
pytiled_parser.Color
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: pytiled_parser.Color
pytiled_parser.OrderedPair
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: pytiled_parser.OrderedPair
pytiled_parser.Size
^^^^^^^^^^^^^^^^^^^
.. autoclass:: pytiled_parser.Size

20
docs/api/index.rst Normal file
View File

@@ -0,0 +1,20 @@
.. _api:
API Reference
=============
This page documents the Application Programming Interface (API) for the PyTiled Parser library.
Throughout the API documentation you will see links labeled both TMX Reference and JSON Reference.
These links go to the official Tiled documentation for that specific type. Sometimes there is not a
one to one mapping, so it may lead to the closest thing in the Tiled format.
At some points certain classes modules may have links to other parts of the Tiled documentation which
cover some of the concepts surrounding that module and it's usage within Tiled.
.. toctree::
:maxdepth: 1
:caption: PyTiled Parser
common_types
properties
layer

48
docs/api/layer.rst Normal file
View File

@@ -0,0 +1,48 @@
.. _layer_api:
Layer
=====
This module provides classes for all layer types
There is the base Layer class, which TileLayer, ObjectLayer, ImageLayer,
and LayerGroup all derive from. The base Layer class is never directly used,
and serves only as an abstract base for common elements between all types.
For more information about Layers, see `Tiled's Manual <https://doc.mapeditor.org/en/stable/manual/layers/>`_
pytiled_parser.Layer
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: pytiled_parser.Layer
:members:
pytiled_parser.TileLayer
^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: pytiled_parser.TileLayer
:members:
pytiled_parser.Chunk
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: pytiled_parser.Chunk
:members:
pytiled_parser.ObjectLayer
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: pytiled_parser.ObjectLayer
:members:
pytiled_parser.ImageLayer
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: pytiled_parser.ImageLayer
:members:
pytiled_parser.LayerGroup
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: pytiled_parser.LayerGroup
:members:

27
docs/api/properties.rst Normal file
View File

@@ -0,0 +1,27 @@
.. _properties_api:
Properties
==========
This module provides some common types used throughout PyTiled Parser. These are all just NamedTuple
classes provided to make sets of data more clear. As such they can be subscripted like a normal tuple
to get the same values, or you can reference them by name. The values shown here are in the order they
will be in the final tuple.
Properties do not have a special class or anything associated with them. They are simply type aliases for
built-in Python types.
pytiled_parser.Property
^^^^^^^^^^^^^^^^^^^^^^^
The ``pytiled_parser.Property`` type is a Union of the `float`, `str`, and `bool` built-in types, as well as
`Path` class from pathlib, and the `pytiled_parser.Color` common type.
A property may be any one of these types.
pytiled_parser.Properties
^^^^^^^^^^^^^^^^^^^^^^^^^
The ``pytiled_parser.Properties`` type is a Dictionary mapping of `str` to `pytiled_parser.Property` objects.
When the map is parsed, all properties will be loaded in as a Property, and stored in a Properties dictionary
with the name being it's key in the dictionary.

52
docs/conf.py Normal file
View File

@@ -0,0 +1,52 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath(".."))
# -- Project information -----------------------------------------------------
project = "PyTiled Parser"
copyright = "2022, Benjamin Kirkbride, Darren Eberly"
author = "Benjamin Kirkbride, Darren Eberly"
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx.ext.autodoc", "sphinx.ext.coverage", "sphinx.ext.napoleon"]
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "furo"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

18
docs/guide/index.rst Normal file
View File

@@ -0,0 +1,18 @@
.. _api:
Programming Guide
=================
This section will guide you through the implementation details of using PyTiled Parser. This is not
an exact science, and will depend heavily on the library you are trying to integrate with. A lot of
the techniques here will show some general concepts and sort of pseudo code, as well as compare to the
`Arcade <https://api.arcade.academy/>`_ implementation as it is the most complete implementation of this
library to date.
Many liberties are taken when implementing with a game engine to suit that engines needs specifically. It
is a double edged sword of using Tiled, it is very flexible and can be implemented in a lot of different ways.
This comes at the cost of making a guide like this not as straight forward as it otherwise would be.
.. toctree::
:maxdepth: 1
map_loading

View File

@@ -0,0 +1,4 @@
Loading A Map
=============
Hello World

View File

@@ -1,7 +0,0 @@
# PyTiled Parser
PyTiled Parser is a Python Library for parsing maps made with the [Tiled Map Editor](https://www.mapeditor.org) for 2D games in a strictly typed fashion.
PyTiled Parser is not tied to any particular graphics library, and as such could be used with [Arcade](https://api.arcade.academy), [Pyglet](https://pyglet.readthedocs.io), [Pygame](https://www.pygame.org/news), or any other Python graphics library.
While we don't offer any direct integrations to other libraries/frameworks, [Arcade](https://api.arcade.academy) has full integration for PyTiled Parser out of the box, and would be a good resource to use as an example implementation.

42
docs/index.rst Normal file
View File

@@ -0,0 +1,42 @@
PyTiled Parser
==============
PyTiled Parser is a Python Library for parsing `Tiled Map Editor <https://www.mapeditor.org/>`_ maps and tilesets
to be used as maps and levels for 2D games in a strictly typed fashion.
PyTiled Parser is not tied to any particular graphics library or game engine. It parses map files and returns arbitrary
Python types(for example, ``Path`` objects for image files rather than a ``Sprite`` from a specific engine). This means
it can be used to aide in implementing Tiled support into a wide variety of tools.
* Documentation available at: https://pytiled-parser.readthedocs.io/
* GitHub Project: https://github.com/pythonarcade/pytiled_parser
* PyPi: https://pypi.org/project/pytiled-parser/
The `Arcade <https://api.arcade.academy/>`_ library has `supporting code <https://api.arcade.academy/en/latest/api/tilemap.html>`_
to integrate PyTiled Parser, as well as `example code <https://api.arcade.academy/en/latest/examples/index.html#using-tiled-map-editor-to-create-maps>`_
showing it's use.
Installation
^^^^^^^^^^^^
Simply install with pip::
pip install pytiled-parser
Quick Links
^^^^^^^^^^^
.. toctree::
:maxdepth: 1
guide/index
api/index
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

35
docs/make.bat Normal file
View File

@@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

View File

@@ -1,3 +0,0 @@
# Common Types
::: pytiled_parser.common_types

View File

@@ -1 +0,0 @@
# Layer

View File

@@ -1,3 +0,0 @@
# Parser
::: pytiled_parser.parser

View File

@@ -1 +0,0 @@
# Properties

View File

@@ -1,3 +0,0 @@
# tiled_map
::: pytiled_parser.tiled_map

View File

@@ -1 +0,0 @@
# Tiled Object

View File

@@ -1 +0,0 @@
# TileSet

View File

@@ -1,5 +0,0 @@
# wang_set
::: pytiled_parser.wang_set
rendering:
members_order: source

View File

@@ -1,3 +0,0 @@
# Worlds
::: pytiled_parser.world