docs: remove common import (#33310)

* add opcar

* fix references

* actually better to split this so opendbc will test docs conventions, and openpilot will test diffing

* not exe

* clean up
This commit is contained in:
Shane Smiskol 2024-08-14 20:29:14 -07:00 committed by GitHub
parent 9d0180ca97
commit 424b657376
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 52 additions and 46 deletions

View File

@ -8,7 +8,7 @@ assignees: ''
**Checklist**
- [ ] added entry to CAR in selfdrive/car/*/values.py and ran `selfdrive/car/docs.py` to generate new docs
- [ ] added entry to CAR in selfdrive/car/*/values.py and ran `selfdrive/opcar/docs.py` to generate new docs
- [ ] test route added to [routes.py](https://github.com/commaai/openpilot/blob/master/selfdrive/car/tests/routes.py)
- [ ] route with openpilot:
- [ ] route with stock system:

View File

@ -44,7 +44,7 @@ Explain how you tested this bug fix.
**Checklist**
- [ ] added entry to CAR in selfdrive/car/*/values.py and ran `selfdrive/car/docs.py` to generate new docs
- [ ] added entry to CAR in selfdrive/car/*/values.py and ran `selfdrive/opcar/docs.py` to generate new docs
- [ ] test route added to [routes.py](https://github.com/commaai/openpilot/blob/master/selfdrive/car/tests/routes.py)
- [ ] route with openpilot:
- [ ] route with stock system:

View File

@ -25,9 +25,6 @@ forbidden_modules =
openpilot.tinygrad
ignore_imports =
# remove these
openpilot.selfdrive.car.tests.test_docs -> openpilot.common.basedir
openpilot.selfdrive.car.docs -> openpilot.common.basedir
openpilot.selfdrive.car.gm.interface -> openpilot.common.basedir
openpilot.selfdrive.car.interfaces -> openpilot.common.basedir
@ -48,8 +45,6 @@ ignore_imports =
openpilot.selfdrive.car.tests.test_models -> openpilot.common.params
openpilot.selfdrive.car.tests.test_models -> openpilot.common.basedir
openpilot.selfdrive.car.card -> openpilot.selfdrive.pandad
openpilot.selfdrive.car.tests.test_docs -> openpilot.selfdrive.debug.dump_car_docs
openpilot.selfdrive.car.tests.test_docs -> openpilot.selfdrive.debug.print_docs_diff
openpilot.selfdrive.car.tests.test_car_interfaces -> openpilot.selfdrive.pandad
openpilot.selfdrive.car.tests.test_models -> openpilot.selfdrive.pandad
openpilot.selfdrive.car.tests.test_car_interfaces -> openpilot.selfdrive.test.fuzzy_generation

View File

@ -145,6 +145,7 @@ testpaths = [
"common",
"selfdrive/pandad",
"selfdrive/car",
"selfdrive/opcar",
"selfdrive/controls",
"selfdrive/locationd",
"selfdrive/monitoring",

21
selfdrive/car/docs.py Executable file → Normal file
View File

@ -1,13 +1,9 @@
#!/usr/bin/env python3
import argparse
from collections import defaultdict
import jinja2
import os
from enum import Enum
from natsort import natsorted
from cereal import car
from openpilot.common.basedir import BASEDIR
from openpilot.selfdrive.car import gen_empty_fingerprint
from openpilot.selfdrive.car.docs_definitions import CarDocs, Column, CommonFootnote, PartType
from openpilot.selfdrive.car.car_helpers import interfaces, get_interface_attr
@ -21,10 +17,6 @@ def get_all_footnotes() -> dict[Enum, int]:
return {fn: idx + 1 for idx, fn in enumerate(all_footnotes)}
CARS_MD_OUT = os.path.join(BASEDIR, "docs", "CARS.md")
CARS_MD_TEMPLATE = os.path.join(BASEDIR, "selfdrive", "car", "CARS_template.md")
def get_all_car_docs() -> list[CarDocs]:
all_car_docs: list[CarDocs] = []
footnotes = get_all_footnotes()
@ -65,16 +57,3 @@ def generate_cars_md(all_car_docs: list[CarDocs], template_fn: str) -> str:
group_by_make=group_by_make, footnotes=footnotes,
Column=Column)
return cars_md
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Auto generates supported cars documentation",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--template", default=CARS_MD_TEMPLATE, help="Override default template filename")
parser.add_argument("--out", default=CARS_MD_OUT, help="Override default generated filename")
args = parser.parse_args()
with open(args.out, 'w') as f:
f.write(generate_cars_md(get_all_car_docs(), args.template))
print(f"Generated and written to {args.out}")

View File

@ -1,16 +1,12 @@
from collections import defaultdict
import os
import pytest
import re
from openpilot.common.basedir import BASEDIR
from openpilot.selfdrive.car.car_helpers import interfaces
from openpilot.selfdrive.car.docs import CARS_MD_OUT, CARS_MD_TEMPLATE, generate_cars_md, get_all_car_docs
from openpilot.selfdrive.car.docs import get_all_car_docs
from openpilot.selfdrive.car.docs_definitions import Cable, Column, PartType, Star
from openpilot.selfdrive.car.honda.values import CAR as HONDA
from openpilot.selfdrive.car.values import PLATFORMS
from openpilot.selfdrive.debug.dump_car_docs import dump_car_docs
from openpilot.selfdrive.debug.print_docs_diff import print_car_docs_diff
class TestCarDocs:
@ -18,19 +14,6 @@ class TestCarDocs:
def setup_class(cls):
cls.all_cars = get_all_car_docs()
def test_generator(self):
generated_cars_md = generate_cars_md(self.all_cars, CARS_MD_TEMPLATE)
with open(CARS_MD_OUT) as f:
current_cars_md = f.read()
assert generated_cars_md == current_cars_md, "Run selfdrive/car/docs.py to update the compatibility documentation"
def test_docs_diff(self):
dump_path = os.path.join(BASEDIR, "selfdrive", "car", "tests", "cars_dump")
dump_car_docs(dump_path)
print_car_docs_diff(dump_path)
os.remove(dump_path)
def test_duplicate_years(self, subtests):
make_model_years = defaultdict(list)
for car in self.all_cars:

View File

@ -0,0 +1 @@
# This folder will be renamed back to car after the opendbc car split

21
selfdrive/opcar/docs.py Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python3
import argparse
import os
from openpilot.common.basedir import BASEDIR
from openpilot.selfdrive.car.docs import get_all_car_docs, generate_cars_md
CARS_MD_OUT = os.path.join(BASEDIR, "docs", "CARS.md")
CARS_MD_TEMPLATE = os.path.join(BASEDIR, "selfdrive", "car", "CARS_template.md")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Auto generates supported cars documentation",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--template", default=CARS_MD_TEMPLATE, help="Override default template filename")
parser.add_argument("--out", default=CARS_MD_OUT, help="Override default generated filename")
args = parser.parse_args()
with open(args.out, 'w') as f:
f.write(generate_cars_md(get_all_car_docs(), args.template))
print(f"Generated and written to {args.out}")

View File

View File

@ -0,0 +1,26 @@
import os
from openpilot.common.basedir import BASEDIR
from openpilot.selfdrive.car.docs import generate_cars_md, get_all_car_docs
from openpilot.selfdrive.debug.dump_car_docs import dump_car_docs
from openpilot.selfdrive.debug.print_docs_diff import print_car_docs_diff
from openpilot.selfdrive.opcar.docs import CARS_MD_OUT, CARS_MD_TEMPLATE
class TestCarDocs:
@classmethod
def setup_class(cls):
cls.all_cars = get_all_car_docs()
def test_generator(self):
generated_cars_md = generate_cars_md(self.all_cars, CARS_MD_TEMPLATE)
with open(CARS_MD_OUT) as f:
current_cars_md = f.read()
assert generated_cars_md == current_cars_md, "Run selfdrive/opcar/docs.py to update the compatibility documentation"
def test_docs_diff(self):
dump_path = os.path.join(BASEDIR, "selfdrive", "car", "tests", "cars_dump")
dump_car_docs(dump_path)
print_car_docs_diff(dump_path)
os.remove(dump_path)