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
old-commit-hash: 424b657376
pull/33314/head
Shane Smiskol 8 months ago committed by GitHub
parent 9e5fe1e5c0
commit 9b0adebec8
  1. 2
      .github/PULL_REQUEST_TEMPLATE/car_port.md
  2. 2
      .github/pull_request_template.md
  3. 5
      .importlinter
  4. 1
      pyproject.toml
  5. 21
      selfdrive/car/docs.py
  6. 19
      selfdrive/car/tests/test_docs.py
  7. 1
      selfdrive/opcar/__init__.py
  8. 21
      selfdrive/opcar/docs.py
  9. 0
      selfdrive/opcar/tests/__init__.py
  10. 26
      selfdrive/opcar/tests/test_docs.py

@ -8,7 +8,7 @@ assignees: ''
**Checklist** **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) - [ ] test route added to [routes.py](https://github.com/commaai/openpilot/blob/master/selfdrive/car/tests/routes.py)
- [ ] route with openpilot: - [ ] route with openpilot:
- [ ] route with stock system: - [ ] route with stock system:

@ -44,7 +44,7 @@ Explain how you tested this bug fix.
**Checklist** **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) - [ ] test route added to [routes.py](https://github.com/commaai/openpilot/blob/master/selfdrive/car/tests/routes.py)
- [ ] route with openpilot: - [ ] route with openpilot:
- [ ] route with stock system: - [ ] route with stock system:

@ -25,9 +25,6 @@ forbidden_modules =
openpilot.tinygrad openpilot.tinygrad
ignore_imports = ignore_imports =
# remove these # 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.gm.interface -> openpilot.common.basedir
openpilot.selfdrive.car.interfaces -> 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.params
openpilot.selfdrive.car.tests.test_models -> openpilot.common.basedir openpilot.selfdrive.car.tests.test_models -> openpilot.common.basedir
openpilot.selfdrive.car.card -> openpilot.selfdrive.pandad 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_car_interfaces -> openpilot.selfdrive.pandad
openpilot.selfdrive.car.tests.test_models -> openpilot.selfdrive.pandad openpilot.selfdrive.car.tests.test_models -> openpilot.selfdrive.pandad
openpilot.selfdrive.car.tests.test_car_interfaces -> openpilot.selfdrive.test.fuzzy_generation openpilot.selfdrive.car.tests.test_car_interfaces -> openpilot.selfdrive.test.fuzzy_generation

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

@ -1,13 +1,9 @@
#!/usr/bin/env python3
import argparse
from collections import defaultdict from collections import defaultdict
import jinja2 import jinja2
import os
from enum import Enum from enum import Enum
from natsort import natsorted from natsort import natsorted
from cereal import car from cereal import car
from openpilot.common.basedir import BASEDIR
from openpilot.selfdrive.car import gen_empty_fingerprint from openpilot.selfdrive.car import gen_empty_fingerprint
from openpilot.selfdrive.car.docs_definitions import CarDocs, Column, CommonFootnote, PartType from openpilot.selfdrive.car.docs_definitions import CarDocs, Column, CommonFootnote, PartType
from openpilot.selfdrive.car.car_helpers import interfaces, get_interface_attr 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)} 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]: def get_all_car_docs() -> list[CarDocs]:
all_car_docs: list[CarDocs] = [] all_car_docs: list[CarDocs] = []
footnotes = get_all_footnotes() 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, group_by_make=group_by_make, footnotes=footnotes,
Column=Column) Column=Column)
return cars_md 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}")

@ -1,16 +1,12 @@
from collections import defaultdict from collections import defaultdict
import os
import pytest import pytest
import re import re
from openpilot.common.basedir import BASEDIR
from openpilot.selfdrive.car.car_helpers import interfaces 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.docs_definitions import Cable, Column, PartType, Star
from openpilot.selfdrive.car.honda.values import CAR as HONDA from openpilot.selfdrive.car.honda.values import CAR as HONDA
from openpilot.selfdrive.car.values import PLATFORMS 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: class TestCarDocs:
@ -18,19 +14,6 @@ class TestCarDocs:
def setup_class(cls): def setup_class(cls):
cls.all_cars = get_all_car_docs() 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): def test_duplicate_years(self, subtests):
make_model_years = defaultdict(list) make_model_years = defaultdict(list)
for car in self.all_cars: for car in self.all_cars:

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

@ -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}")

@ -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)
Loading…
Cancel
Save