Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds initial documentation with sphinxs. #66

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/docs_pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Publish documentation
on:
push:
tags: '*'
branches:
- main

jobs:
build-docs:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
- name: Set up python
id: setup-python
uses: actions/setup-python@v2
with:
python-version: 3.8
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --with dev --no-interaction --no-root
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
#----------------------------------------------
# build documentation
#----------------------------------------------
# Runs a set of commands using the runners shell
- name: Build documentation
run: |
mkdir gh-pages
touch gh-pages/.nojekyll
cd docs/
poetry run sphinx-build -b html ./source _build
cp -r _build/* ../gh-pages/

- name: Deploy documentation
if: ${{ github.event_name == 'push' }}
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: gh-pages
6 changes: 3 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,6 @@ valid-metaclass-classmethod-first-arg=mcs

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=StandardError,
Exception,
BaseException
overgeneral-exceptions=builtins.StandardError,
builtins.Exception,
builtins.BaseException
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -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 = source
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)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
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
18 changes: 18 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
API
========


Common
----------

.. automodule:: mpscenes.common

Obstacles
----------

.. automodule:: mpscenes.obstacles

Goals
----------

.. automodule:: mpscenes.goals
64 changes: 64 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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 = 'mpscenes'
copyright = '2022, Max Spahn'
author = 'Max Spahn'


# -- 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.duration',
'sphinx.ext.doctest',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
]

autodoc_default_options = {
'members': True,
'undoc-members': False,
'member-order': 'groupwise'}

# 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 = []


# -- 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 = 'sphinx_rtd_theme'

# 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']

149 changes: 149 additions & 0 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
Getting started
===============

This is the guide to understand how motion planning components are defined in
the package.

Pre-requisites
--------------

- Python >=3.8
- pip3

Installation from pypi
-----------------------

The package is uploaded to pypi so you can install it using

.. code:: bash

pip3 install mpscenes


Installation from source
-------------------------

You first have to download the repository

.. code:: bash

git clone [email protected]:maxspahn/motion_planning_scenes.git

Then, you can install the package using pip as:

.. code:: bash

pip3 install .

The code can be installed in editible mode using

.. code:: bash

pip3 install -e .

Note that we recommend using poetry in this case.

Optional: Installation with poetry
------------------------------------

If you want to use `poetry <https://python-poetry.org/docs/>`_, you have to install it
first. See their webpage for instructions `docs <https://python-poetry.org/docs/>`_.

.. code:: bash

poetry install

The virtual environment is entered by

.. code:: bash

poetry shell

Inside the virtual environment you can access all the examples.

Installing dependencies
-----------------------

Dependencies should be installed through pip or poetry, see below.

Using pip, you can use

.. code:: bash

pip3 install

Using poetry

.. code:: bash

poetry install


Examples
-----------

Obstacles and goals are defined as dictionaries. You could potentially also load
them in as yaml files, but the parsing is not part of this package. The examples
will be based on python dicts.


A simple spherical obstacle with radius can be constructed:

.. code:: python

config_dict = {
"type": "sphere",
"geometry": {
"position": [2.0, 2.0, 1.0],
"radius": 1.0,
},
}
obstacle_1 = SphereObstacle(
name="obstacle_1", content_dict=config_dict
)

A box (cuboid) obstacle, that can be moved by robots, can be created as shown
below. Note, that we specify the limits for randomization here.

.. code:: python

config_dict = {
'type': 'box',
'geometry': {
'position' : [2.0, 0.0, 2.0],
'width': 0.2,
'height': 0.2,
'length': 0.2,
},
'movable': True,
'high': {
'position' : [5.0, 5.0, 1.0],
'width': 0.2,
'height': 0.2,
'length': 0.2,
},
'low': {
'position' : [0.0, 0.0, 0.5],
'width': 0.2,
'height': 0.2,
'length': 0.2,
}
}
obstacle_2 = BoxObstacle(
name="obstacle_2", content_dict=config_dict
)

A dynamic obstacle can be defined as:

.. code:: python

config_dict = {
"type": "sphere",
"geometry": {
"trajectory": ["2.0 - 0.1 * t", "-0.0", "0.1"],
"radius": 0.2
},
}
obstacle_3 = DynamicSphereObstacle(
name="obstacle_3", content_dict=config_dict
)
21 changes: 21 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. mpscenes documentation master file, created by
sphinx-quickstart on Wed Dec 6 20:27:33 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to mpscenes's documentation!
====================================

.. toctree::
:maxdepth: 2
:caption: Contents:

getting_started
api



Indices and tables
==================

* :ref:`search`
2 changes: 0 additions & 2 deletions mpscenes/.__init__.py

This file was deleted.

Loading
Loading