Skip to content

Commit b816b5b

Browse files
pd0wmChadBailey
andauthored
Sphinx docs generation (commaai#22697)
* add sphinx * switch theme * Experiment: sphinx docs generation updated (commaai#22708) * moved build to root gitignore, added .gitkeep * Improved makefile doc build process - Removed auto-generated docs from source control - Moved apidoc.sh into Makefile - Removed make.bat (can add back if Windows support desired) - Added sphinx viewcode and markdown extensions - Added feature to source /docs in build, so any .rst file in /docs will override the respective file during the build process - Added feature to copy all markdown/rst files from source into /build/ during build process so they can be easily referenced while writing docs (see examples in index.md) - Wrote basic starter index.md file TODO: Add new dependencies to Pipfile [dev-packages] * Revert accidental modification to Pipfile * fix command substitution * exclude xx * improve docs * dont include all docs in release build * Add dockerfile * update title * include normal readme * build container in CI * use buildkit * add login Co-authored-by: Chad Bailey <[email protected]>
1 parent efb5abe commit b816b5b

18 files changed

+387
-79
lines changed

Diff for: .github/workflows/selfdrive_tests.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,22 @@ jobs:
314314
coverage run selfdrive/test/test_models.py"
315315
- name: Upload coverage to Codecov
316316
run: bash <(curl -s https://codecov.io/bash) -v -F test_car_models
317+
318+
docs:
319+
name: build docs
320+
runs-on: ubuntu-20.04
321+
timeout-minutes: 50
322+
steps:
323+
- uses: actions/checkout@v2
324+
with:
325+
submodules: true
326+
- name: Build docker container
327+
run: |
328+
docker pull $DOCKER_REGISTRY/$BASE_IMAGE:latest || true
329+
docker pull $DOCKER_REGISTRY/openpilot-docs:latest || true
330+
DOCKER_BUILDKIT=1 docker build --cache-from $DOCKER_REGISTRY/openpilot-docs:latest -t $DOCKER_REGISTRY/openpilot-docs:latest -f docs/docker/Dockerfile .
331+
- name: Push docker container
332+
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/openpilot'
333+
run: |
334+
$DOCKER_LOGIN
335+
docker push $DOCKER_REGISTRY/openpilot-docs:latest

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@ selfdrive/modeld/thneed/compile
7878
models/*.thneed
7979

8080
*.bz2
81+
82+
build/
83+
84+
!**/.gitkeep

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Table of Contents
1717
What is openpilot?
1818
------
1919

20-
[openpilot](http://github.com/commaai/openpilot) is an open source driver assistance system. Currently, openpilot performs the functions of Adaptive Cruise Control (ACC), Automated Lane Centering (ALC), Forward Collision Warning (FCW) and Lane Departure Warning (LDW) for a growing variety of [supported car makes, models and model years](docs/CARS.md). In addition, while openpilot is engaged, a camera based Driver Monitoring (DM) feature alerts distracted and asleep drivers. See more about [the vehicle integration and limitations here](docs/INTEGRATION.md).
20+
[openpilot](http://github.com/commaai/openpilot) is an open source driver assistance system. Currently, openpilot performs the functions of Adaptive Cruise Control (ACC), Automated Lane Centering (ALC), Forward Collision Warning (FCW) and Lane Departure Warning (LDW) for a growing variety of [supported car makes, models and model years](docs/CARS.md). In addition, while openpilot is engaged, a camera based Driver Monitoring (DM) feature alerts distracted and asleep drivers. See more about [the vehicle integration](docs/INTEGRATION.md) and [limitations](docs/LIMITATIONS.md).
2121

2222
<table>
2323
<tr>

Diff for: docs/CARS.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
Supported Cars
2-
------
1+
# Supported Cars
2+
3+
## comma.ai supported cars
34

45
| Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below |
56
| ----------| ------------------------------| ------------------| -----------------| -------------------| ------------------|
@@ -74,8 +75,7 @@ Supported Cars
7475
<sup>3</sup>When disconnecting the Driver Support Unit (DSU), openpilot ACC will replace stock ACC. ***NOTE: disconnecting the DSU disables Automatic Emergency Braking (AEB).*** <br />
7576
<sup>4</sup>28mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control. <br />
7677

77-
Community Maintained Cars and Features
78-
------
78+
## Community Maintained Cars and Features
7979

8080
| Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below |
8181
| ----------| ------------------------------| ------------------| -----------------| -------------------| -------------|

Diff for: docs/INTEGRATION.md

+1-63
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Integration with Stock Features
2-
------
1+
# Integration with Stock Features
32

43
In all supported cars:
54
* Stock Lane Keep Assist (LKA) and stock ALC are replaced by openpilot ALC, which only functions when openpilot is engaged by the user.
@@ -10,64 +9,3 @@ Additionally, on specific supported cars (see ACC column in [supported cars](CAR
109
* openpilot FCW operates in addition to stock FCW.
1110

1211
openpilot should preserve all other vehicle's stock features, including, but are not limited to: FCW, Automatic Emergency Braking (AEB), auto high-beam, blind spot warning, and side collision warning.
13-
14-
Limitations of openpilot ALC and LDW
15-
------
16-
17-
openpilot ALC and openpilot LDW do not automatically drive the vehicle or reduce the amount of attention that must be paid to operate your vehicle. The driver must always keep control of the steering wheel and be ready to correct the openpilot ALC action at all times.
18-
19-
While changing lanes, openpilot is not capable of looking next to you or checking your blind spot. Only nudge the wheel to initiate a lane change after you have confirmed it's safe to do so.
20-
21-
Many factors can impact the performance of openpilot ALC and openpilot LDW, causing them to be unable to function as intended. These include, but are not limited to:
22-
23-
* Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation.
24-
* The road facing camera is obstructed, covered or damaged by mud, ice, snow, etc.
25-
* Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle.
26-
* The device is mounted incorrectly.
27-
* When in sharp curves, like on-off ramps, intersections etc...; openpilot is designed to be limited in the amount of steering torque it can produce.
28-
* In the presence of restricted lanes or construction zones.
29-
* When driving on highly banked roads or in presence of strong cross-wind.
30-
* Extremely hot or cold temperatures.
31-
* Bright light (due to oncoming headlights, direct sunlight, etc.).
32-
* Driving on hills, narrow, or winding roads.
33-
34-
The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. It is the driver's responsibility to be in control of the vehicle at all times.
35-
36-
Limitations of openpilot ACC and FCW
37-
------
38-
39-
openpilot ACC and openpilot FCW are not systems that allow careless or inattentive driving. It is still necessary for the driver to pay close attention to the vehicle’s surroundings and to be ready to re-take control of the gas and the brake at all times.
40-
41-
Many factors can impact the performance of openpilot ACC and openpilot FCW, causing them to be unable to function as intended. These include, but are not limited to:
42-
43-
* Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation.
44-
* The road facing camera or radar are obstructed, covered, or damaged by mud, ice, snow, etc.
45-
* Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle.
46-
* The device is mounted incorrectly.
47-
* Approaching a toll booth, a bridge or a large metal plate.
48-
* When driving on roads with pedestrians, cyclists, etc...
49-
* In presence of traffic signs or stop lights, which are not detected by openpilot at this time.
50-
* When the posted speed limit is below the user selected set speed. openpilot does not detect speed limits at this time.
51-
* In presence of vehicles in the same lane that are not moving.
52-
* When abrupt braking maneuvers are required. openpilot is designed to be limited in the amount of deceleration and acceleration that it can produce.
53-
* When surrounding vehicles perform close cut-ins from neighbor lanes.
54-
* Driving on hills, narrow, or winding roads.
55-
* Extremely hot or cold temperatures.
56-
* Bright light (due to oncoming headlights, direct sunlight, etc.).
57-
* Interference from other equipment that generates radar waves.
58-
59-
The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. It is the driver's responsibility to be in control of the vehicle at all times.
60-
61-
Limitations of openpilot DM
62-
------
63-
64-
openpilot DM should not be considered an exact measurement of the alertness of the driver.
65-
66-
Many factors can impact the performance of openpilot DM, causing it to be unable to function as intended. These include, but are not limited to:
67-
68-
* Low light conditions, such as driving at night or in dark tunnels.
69-
* Bright light (due to oncoming headlights, direct sunlight, etc.).
70-
* The driver's face is partially or completely outside field of view of the driver facing camera.
71-
* The driver facing camera is obstructed, covered, or damaged.
72-
73-
The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. A driver should not rely on openpilot DM to assess their level of attention.

Diff for: docs/LIMITATIONS.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Limitations
2+
## Limitations of openpilot ALC and LDW
3+
4+
openpilot ALC and openpilot LDW do not automatically drive the vehicle or reduce the amount of attention that must be paid to operate your vehicle. The driver must always keep control of the steering wheel and be ready to correct the openpilot ALC action at all times.
5+
6+
While changing lanes, openpilot is not capable of looking next to you or checking your blind spot. Only nudge the wheel to initiate a lane change after you have confirmed it's safe to do so.
7+
8+
Many factors can impact the performance of openpilot ALC and openpilot LDW, causing them to be unable to function as intended. These include, but are not limited to:
9+
10+
* Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation.
11+
* The road facing camera is obstructed, covered or damaged by mud, ice, snow, etc.
12+
* Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle.
13+
* The device is mounted incorrectly.
14+
* When in sharp curves, like on-off ramps, intersections etc...; openpilot is designed to be limited in the amount of steering torque it can produce.
15+
* In the presence of restricted lanes or construction zones.
16+
* When driving on highly banked roads or in presence of strong cross-wind.
17+
* Extremely hot or cold temperatures.
18+
* Bright light (due to oncoming headlights, direct sunlight, etc.).
19+
* Driving on hills, narrow, or winding roads.
20+
21+
The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. It is the driver's responsibility to be in control of the vehicle at all times.
22+
23+
## Limitations of openpilot ACC and FCW
24+
25+
openpilot ACC and openpilot FCW are not systems that allow careless or inattentive driving. It is still necessary for the driver to pay close attention to the vehicle’s surroundings and to be ready to re-take control of the gas and the brake at all times.
26+
27+
Many factors can impact the performance of openpilot ACC and openpilot FCW, causing them to be unable to function as intended. These include, but are not limited to:
28+
29+
* Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation.
30+
* The road facing camera or radar are obstructed, covered, or damaged by mud, ice, snow, etc.
31+
* Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle.
32+
* The device is mounted incorrectly.
33+
* Approaching a toll booth, a bridge or a large metal plate.
34+
* When driving on roads with pedestrians, cyclists, etc...
35+
* In presence of traffic signs or stop lights, which are not detected by openpilot at this time.
36+
* When the posted speed limit is below the user selected set speed. openpilot does not detect speed limits at this time.
37+
* In presence of vehicles in the same lane that are not moving.
38+
* When abrupt braking maneuvers are required. openpilot is designed to be limited in the amount of deceleration and acceleration that it can produce.
39+
* When surrounding vehicles perform close cut-ins from neighbor lanes.
40+
* Driving on hills, narrow, or winding roads.
41+
* Extremely hot or cold temperatures.
42+
* Bright light (due to oncoming headlights, direct sunlight, etc.).
43+
* Interference from other equipment that generates radar waves.
44+
45+
The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. It is the driver's responsibility to be in control of the vehicle at all times.
46+
47+
## Limitations of openpilot DM
48+
49+
openpilot DM should not be considered an exact measurement of the alertness of the driver.
50+
51+
Many factors can impact the performance of openpilot DM, causing it to be unable to function as intended. These include, but are not limited to:
52+
53+
* Low light conditions, such as driving at night or in dark tunnels.
54+
* Bright light (due to oncoming headlights, direct sunlight, etc.).
55+
* The driver's face is partially or completely outside field of view of the driver facing camera.
56+
* The driver facing camera is obstructed, covered, or damaged.
57+
58+
The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. A driver should not rely on openpilot DM to assess their level of attention.

Diff for: docs/Makefile

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
OPENPILOT_ROOT = `git rev-parse --show-toplevel`
5+
6+
# You can set these variables from the command line, and also
7+
# from the environment for the first two.
8+
SPHINXOPTS ?=
9+
SPHINXBUILD ?= sphinx-build
10+
DOCSDIR = "$(OPENPILOT_ROOT)/docs"
11+
SOURCEDIR = "$(OPENPILOT_ROOT)/build/docs"
12+
DOCSBUILDDIR = "$(OPENPILOT_ROOT)/build/docs"
13+
BUILDDIR = "$(OPENPILOT_ROOT)/build"
14+
15+
# Put it first so that "make" without argument is like "make help".
16+
help:
17+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(DOCSBUILDDIR)" $(SPHINXOPTS) $(O)
18+
19+
clean:
20+
@echo "Cleaning build folder..."
21+
rm -rf "$(BUILDDIR)"
22+
23+
.PHONY: help Makefile
24+
25+
# Catch-all target: route all unknown targets to Sphinx using the new
26+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
27+
%: Makefile
28+
@echo "Cleaning build folder..."
29+
rm -rf "$(BUILDDIR)"
30+
mkdir -p "$(DOCSBUILDDIR)"
31+
32+
@echo "Copying docs & config to build folder..."
33+
cp -a "$(DOCSDIR)" "$(BUILDDIR)"
34+
cd "$(OPENPILOT_ROOT)" && \
35+
find . -type f \( -name "*.md" -o -name "*.rst" \) \
36+
-not -path "*/.*" \
37+
-not -path "./build/*" \
38+
-not -path "./docs/*" \
39+
-not -path "./xx/*" \
40+
-exec cp --parents "{}" ./build/docs/ \;
41+
42+
@echo "Building rst files..."
43+
sphinx-apidoc -o "$(DOCSBUILDDIR)" ../ \
44+
../xx ../laika_repo ../rednose_repo ../pyextra ../notebooks ../panda_jungle \
45+
../third_party \
46+
../panda/examples \
47+
../scripts \
48+
../selfdrive/modeld \
49+
../selfdrive/debug \
50+
$(shell find .. -type d -name "*test*")
51+
52+
@echo "Building html files..."
53+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(DOCSBUILDDIR)" $(SPHINXOPTS) $(O)

Diff for: docs/SAFETY.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
openpilot Safety
2-
======
1+
# Safety
32

43
openpilot is an Adaptive Cruise Control (ACC) and Automated Lane Centering (ALC) system.
54
Like other ACC and ALC systems, openpilot is a failsafe passive system and it requires the

Diff for: docs/conf.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# type: ignore
2+
# pylint: skip-file
3+
4+
# Configuration file for the Sphinx documentation builder.
5+
#
6+
# This file only contains a selection of the most common options. For a full
7+
# list see the documentation:
8+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
9+
10+
# -- Path setup --------------------------------------------------------------
11+
12+
# If extensions (or modules to document with autodoc) are in another directory,
13+
# add these directories to sys.path here. If the directory is relative to the
14+
# documentation root, use os.path.abspath to make it absolute, like shown here.
15+
#
16+
import os
17+
import sys
18+
sys.path.insert(0, os.path.abspath('.'))
19+
sys.path.insert(0, os.path.abspath('..'))
20+
21+
22+
23+
# -- Project information -----------------------------------------------------
24+
25+
project = 'openpilot'
26+
copyright = '2021, comma.ai'
27+
author = 'comma.ai'
28+
29+
30+
# -- General configuration ---------------------------------------------------
31+
32+
# Add any Sphinx extension module names here, as strings. They can be
33+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
34+
# ones.
35+
extensions = [
36+
'sphinx.ext.autodoc', # Auto-generate docs
37+
'sphinx.ext.viewcode', # Add view code link to modules
38+
'sphinx_rtd_theme', # Read The Docs theme
39+
'myst_parser', # Markdown parsing
40+
]
41+
42+
# Add any paths that contain templates here, relative to this directory.
43+
templates_path = ['_templates']
44+
45+
# List of patterns, relative to source directory, that match files and
46+
# directories to ignore when looking for source files.
47+
# This pattern also affects html_static_path and html_extra_path.
48+
exclude_patterns = []
49+
50+
51+
# -- Options for HTML output -------------------------------------------------
52+
53+
# The theme to use for HTML and HTML Help pages. See the documentation for
54+
# a list of builtin themes.
55+
#
56+
html_theme = 'sphinx_rtd_theme'
57+
58+
# Add any paths that contain custom static files (such as style sheets) here,
59+
# relative to this directory. They are copied after the builtin static files,
60+
# so a file named "default.css" will overwrite the builtin "default.css".
61+
html_static_path = ['_static']

Diff for: docs/docker/Dockerfile

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM ghcr.io/commaai/openpilot-base:latest
2+
3+
ENV PYTHONUNBUFFERED 1
4+
5+
ENV OPENPILOT_PATH /home/batman/openpilot/
6+
ENV PYTHONPATH ${OPENPILOT_PATH}:${PYTHONPATH}
7+
8+
RUN mkdir -p ${OPENPILOT_PATH}
9+
WORKDIR ${OPENPILOT_PATH}
10+
11+
COPY Pipfile Pipfile.lock $OPENPILOT_PATH
12+
RUN pip install --no-cache-dir pipenv==2020.8.13 && \
13+
pipenv install --system --deploy --dev --clear && \
14+
pip uninstall -y pipenv
15+
16+
17+
# TODO: add to pipfile
18+
RUN pip install sphinx-rtd-theme==1.0.0 sphinx==4.2.0 myst-parser==0.15.2
19+
20+
COPY SConstruct ${OPENPILOT_PATH}
21+
22+
COPY ./pyextra ${OPENPILOT_PATH}/pyextra
23+
COPY ./third_party ${OPENPILOT_PATH}/third_party
24+
COPY ./site_scons ${OPENPILOT_PATH}/site_scons
25+
COPY ./laika ${OPENPILOT_PATH}/laika
26+
COPY ./laika_repo ${OPENPILOT_PATH}/laika_repo
27+
COPY ./rednose ${OPENPILOT_PATH}/rednose
28+
COPY ./rednose_repo ${OPENPILOT_PATH}/rednose_repo
29+
COPY ./tools ${OPENPILOT_PATH}/tools
30+
COPY ./release ${OPENPILOT_PATH}/release
31+
COPY ./common ${OPENPILOT_PATH}/common
32+
COPY ./opendbc ${OPENPILOT_PATH}/opendbc
33+
COPY ./cereal ${OPENPILOT_PATH}/cereal
34+
COPY ./panda ${OPENPILOT_PATH}/panda
35+
COPY ./selfdrive ${OPENPILOT_PATH}/selfdrive
36+
37+
RUN scons -j$(nproc)
38+
39+
COPY ./docs ${OPENPILOT_PATH}/docs
40+
RUN git init .
41+
WORKDIR ${OPENPILOT_PATH}/docs
42+
RUN make html
43+
44+
FROM nginx:1.21
45+
COPY --from=0 /home/batman/openpilot/build/docs/html /usr/share/nginx/html
46+
COPY ./docs/docker/nginx.conf /etc/nginx/conf.d/default.conf

Diff for: docs/docker/nginx.conf

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server {
2+
listen 80;
3+
listen [::]:80;
4+
server_name localhost;
5+
6+
gzip on;
7+
gzip_types text/html text/plain text/css text/xml text/javascript application/javascript application/x-javascript;
8+
gzip_min_length 1024;
9+
gzip_vary on;
10+
11+
root /usr/share/nginx/html;
12+
location / {
13+
try_files $uri $uri/ /index.html;
14+
}
15+
}

0 commit comments

Comments
 (0)