11
11
from opendbc .car .common .basedir import BASEDIR
12
12
from opendbc .car import gen_empty_fingerprint
13
13
from opendbc .car .structs import CarParams
14
- from opendbc .car .docs_definitions import CarDocs , Device , ExtraCarDocs , Column , ExtraCarsColumn , CommonFootnote , PartType
15
- from opendbc .car .car_helpers import interfaces , get_interface_attr
16
- from opendbc .car .values import Platform , PLATFORMS
14
+ from opendbc .car .docs_definitions import BaseCarHarness , CarDocs , Device , ExtraCarDocs , Column , ExtraCarsColumn , CommonFootnote , PartType , SupportType
15
+ from opendbc .car .car_helpers import interfaces
16
+ from opendbc .car .interfaces import get_interface_attr
17
+ from opendbc .car .values import Platform
17
18
from opendbc .car .mock .values import CAR as MOCK
18
19
from opendbc .car .extra_cars import CAR as EXTRA
19
20
20
21
21
22
EXTRA_CARS_MD_OUT = os .path .join (BASEDIR , "../" , "../" , "docs" , "CARS.md" )
22
23
EXTRA_CARS_MD_TEMPLATE = os .path .join (BASEDIR , "CARS_template.md" )
23
24
25
+ # TODO: merge these platforms into normal car ports with SupportType flag
24
26
ExtraPlatform = Platform | EXTRA
25
27
EXTRA_BRANDS = get_args (ExtraPlatform )
26
28
EXTRA_PLATFORMS : dict [str , ExtraPlatform ] = {str (platform ): platform for brand in EXTRA_BRANDS for platform in brand }
27
29
28
30
29
- def get_params_for_docs (model , platform ) -> CarParams :
30
- cp_model , cp_platform = ( model , platform ) if model in interfaces else ( " MOCK" , MOCK .MOCK )
31
- CP : CarParams = interfaces [cp_model ][0 ].get_params (cp_platform , fingerprint = gen_empty_fingerprint (),
32
- car_fw = [CarParams .CarFw (ecu = CarParams .Ecu .unknown )],
33
- experimental_long = True , docs = True )
31
+ def get_params_for_docs (platform ) -> CarParams :
32
+ cp_platform = platform if platform in interfaces else MOCK .MOCK
33
+ CP : CarParams = interfaces [cp_platform ][0 ].get_params (cp_platform , fingerprint = gen_empty_fingerprint (),
34
+ car_fw = [CarParams .CarFw (ecu = CarParams .Ecu .unknown )],
35
+ experimental_long = True , docs = True )
34
36
return CP
35
37
36
38
@@ -41,13 +43,13 @@ def get_all_footnotes() -> dict[Enum, int]:
41
43
return {fn : idx + 1 for idx , fn in enumerate (all_footnotes )}
42
44
43
45
44
- def build_sorted_car_docs_list (platforms , footnotes = None , include_dashcam = False ):
46
+ def build_sorted_car_docs_list (platforms , footnotes = None ):
45
47
collected_car_docs : list [CarDocs | ExtraCarDocs ] = []
46
- for model , platform in platforms .items ():
48
+ for platform in platforms .values ():
47
49
car_docs = platform .config .car_docs
48
- CP = get_params_for_docs (model , platform )
50
+ CP = get_params_for_docs (platform )
49
51
50
- if ( CP . dashcamOnly and not include_dashcam ) or not len (car_docs ):
52
+ if not len (car_docs ):
51
53
continue
52
54
53
55
# A platform can include multiple car models
@@ -65,12 +67,7 @@ def build_sorted_car_docs_list(platforms, footnotes=None, include_dashcam=False)
65
67
# CAUTION: This function is imported by shop.comma.ai and comma.ai/vehicles, test changes carefully
66
68
def get_all_car_docs () -> list [CarDocs ]:
67
69
collected_footnotes = get_all_footnotes ()
68
- sorted_list : list [CarDocs ] = build_sorted_car_docs_list (PLATFORMS , footnotes = collected_footnotes )
69
- return sorted_list
70
-
71
-
72
- def get_car_docs_with_extras () -> list [CarDocs | ExtraCarDocs ]:
73
- sorted_list : list [CarDocs ] = build_sorted_car_docs_list (EXTRA_PLATFORMS , include_dashcam = True )
70
+ sorted_list : list [CarDocs ] = build_sorted_car_docs_list (EXTRA_PLATFORMS , footnotes = collected_footnotes )
74
71
return sorted_list
75
72
76
73
@@ -89,16 +86,8 @@ def generate_cars_md(all_car_docs: list[CarDocs], template_fn: str) -> str:
89
86
footnotes = [fn .value .text for fn in get_all_footnotes ()]
90
87
cars_md : str = template .render (all_car_docs = all_car_docs , PartType = PartType ,
91
88
group_by_make = group_by_make , footnotes = footnotes ,
92
- Device = Device , Column = Column )
93
- return cars_md
94
-
95
-
96
- def generate_cars_md_with_extras (car_docs_with_extras : list [CarDocs | ExtraCarDocs ], template_fn : str ) -> str :
97
- with open (template_fn ) as f :
98
- template = jinja2 .Template (f .read (), trim_blocks = True , lstrip_blocks = True )
99
-
100
- cars_md : str = template .render (car_docs_with_extras = car_docs_with_extras , PartType = PartType ,
101
- group_by_make = group_by_make , ExtraCarsColumn = ExtraCarsColumn )
89
+ Device = Device , Column = Column , ExtraCarsColumn = ExtraCarsColumn ,
90
+ BaseCarHarness = BaseCarHarness , SupportType = SupportType )
102
91
return cars_md
103
92
104
93
@@ -111,5 +100,5 @@ def generate_cars_md_with_extras(car_docs_with_extras: list[CarDocs | ExtraCarDo
111
100
args = parser .parse_args ()
112
101
113
102
with open (args .out , 'w' ) as f :
114
- f .write (generate_cars_md_with_extras ( get_car_docs_with_extras (), args .template ))
103
+ f .write (generate_cars_md ( get_all_car_docs (), args .template ))
115
104
print (f"Generated and written to { args .out } " )
0 commit comments