Skip to content

Commit

Permalink
Add readthedocs (#18)
Browse files Browse the repository at this point in the history
* add doc files
* action to trigger rtd build

---------

Signed-off-by: Christian Henkel <[email protected]>
  • Loading branch information
ct2034 authored Aug 13, 2024
1 parent c43aaa5 commit 7c32eb5
Show file tree
Hide file tree
Showing 26 changed files with 180 additions and 33 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/rtd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Workflow to trigger ReadTheDocs build on every push to main branch

name: rtd

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Trigger RTDs build
run: |
curl
-X POST "https://readthedocs.org/api/v3/projects/bt_tools/versions/latest/builds/" \
-H "Authorization: Token ${{ secrets.RTD_API_TOKEN }}"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__pycache__/
*.py[cod]
.tmp_imgs/
.tmp_imgs/
docs/build/
docs/source/apidocs/
13 changes: 13 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "2"

build:
os: "ubuntu-22.04"
tools:
python: "3.10"

python:
install:
- requirements: docs/requirements.txt

sphinx:
configuration: docs/source/conf.py
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
[![python](https://img.shields.io/github/languages/top/boschresearch/bt_tools.svg?style=flat-square)](https://github.com/boschresearch/bt_tools/search?l=python)
[![License](https://img.shields.io/badge/license-Apache%202-blue.svg?style=flat-square)](https://github.com/boschresearch/bt_tools/blob/main/LICENSE)

<img src="bt_tools_common/doc/logo.png" alt="bt_tools logo" width="200"/>
<img src="imgs/logo.png" alt="bt_tools logo" width="200"/>

__bt_tools__ is a collection of software for working with behavior trees (BTs) in ROS. It contains means for interpreting, visualizing and introspecting BTs.

![bt_tools](bt_tools_common/doc/overview.drawio.svg)
![bt_tools](imgs/overview.drawio.svg)

## btlib

Expand All @@ -38,7 +38,7 @@ ros2 run bt_live bt_live --ros-args -p fbl_file:=<path_to_fbl_log>
Then open a browser at <http://localhost:8000> to see the visualization.
It should look a little something like this:

<img src="bt_live/doc/bt_live_browser.png" width="600" />
<img src="imgs/bt_live_browser.png" width="600" />

## bt_view

Expand All @@ -58,7 +58,7 @@ to the same folder that the `fbl` log is in.

For example, the `_states.png` file will look like this:

<img src="bt_view/test/_test_data/reference/bt_trace_other_fbl_log_states.png" width="600" />
<img src="imgs/bt_trace_other_fbl_log_states.png" width="600" />

### Calculate coverage

Expand Down
3 changes: 3 additions & 0 deletions bt_live/src/bt_live/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Visualize behavior tree in real-time.
"""
8 changes: 0 additions & 8 deletions bt_tools_common/CMakeLists.txt

This file was deleted.

16 changes: 0 additions & 16 deletions bt_tools_common/package.xml

This file was deleted.

3 changes: 3 additions & 0 deletions bt_view/src/bt_view/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Render behavior trees to images files.
"""
Empty file added btlib/log/COLCON_IGNORE
Empty file.
1 change: 1 addition & 0 deletions btlib/log/latest
1 change: 1 addition & 0 deletions btlib/log/latest_list
4 changes: 4 additions & 0 deletions btlib/src/btlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Module to visualize behavior trees.
"""

from typing import Dict, List, Optional

from bs4 import BeautifulSoup
Expand Down
11 changes: 7 additions & 4 deletions btlib/src/btlib/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ def read_log_fbl(fname: str,
:param g: Graph representing the behavior tree.
:return: Tuple of
values_count: How often a node was executed.
values_success: How often a node was successful
(positive value) vs failed (negative value)
`values_count`: How often a node was executed.
`values_success`: How often a node was successful (positive value) vs failed (negative value).
"""
with open(fname, 'rb') as file_b:
buf = bytearray(file_b.read())
Expand All @@ -79,7 +78,11 @@ def merge_values(
values1: Optional[Union[VALUE_MAP, VALUE_MAP_RETURN_STATES]],
values2: Optional[Union[VALUE_MAP, VALUE_MAP_RETURN_STATES]]) -> \
Union[VALUE_MAP, VALUE_MAP_RETURN_STATES]:
"""Merge values."""
"""
Merge values of two value maps.
On the lowest level this will add the two values if they are present.
"""
if values1 is None:
assert values2 is not None, 'At least one values must not be None'
return values2
Expand Down
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

if "%1" == "" goto help

%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.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
6 changes: 6 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sphinx<8.0.0
sphinx-rtd-theme==2.0.0

sphinx-autodoc2==0.5.0
myst-parser==4.0.0
sphinx-mdinclude==0.6.2
35 changes: 35 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Configuration file for the Sphinx documentation builder.

# -- Project information
project = 'bt_tools'
copyright = '2024, Robert Bosch GmbH'
author = 'Christian Henkel'

release = '0.1'
version = '0.1.0'

# -- General configuration
extensions = [
'autodoc2',
'sphinx_mdinclude',
]
templates_path = ['_templates']

# -- HTML Theming
html_theme = 'sphinx_rtd_theme'
html_theme_options = {
'logo_only': True,
'display_version': False,
'style_nav_header_background': '#364C3B' # Dark contrast to the logo
}
html_logo = 'logo.png'
html_extra_path = ['../../']

# -- Options for EPUB output
epub_show_urls = 'footnote'

autodoc2_packages = [
"../../btlib/src/btlib",
"../../bt_view/src/bt_view",
"../../bt_live/src/bt_live",
]
12 changes: 12 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Welcome to my RTD demo
======================

.. mdinclude:: ../../README.md

Contents
--------

.. toctree::

tutorials
apidocs/index
File renamed without changes
15 changes: 15 additions & 0 deletions docs/source/tutorials.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Tutorials
=========

How to model check your robot
-----------------------------

1. Install the necessary packages:
```
sudo apt install THAT
```

2. Run the model checker:
```
convince_toolchain -i model.scxml -o results.json
```
File renamed without changes
Binary file added imgs/bt_trace_other_fbl_log_states.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 7c32eb5

Please sign in to comment.