forked from autowarefoundation/autoware-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
26 lines (21 loc) · 826 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os # for relpath, cannot use pathlib
import urllib
def define_env(env):
@env.filter
def drawio(image_path):
image_url = urllib.parse.quote(f"{env.conf['site_url']}{image_path}", "")
return f"https://app.diagrams.net/?lightbox=1#U{image_url}"
@env.macro
def create_relative_link(text, root_path):
path = os.path.relpath(root_path, env.page.url)
return f"[{text}]({path})"
@env.macro
def link_ad_api(name):
return create_relative_link(name, f"design/autoware-interfaces/ad-api/list/{name}")
@env.macro
def resolve_msg_field(type, name, ext):
specs = env.variables["autoware_interfaces"]["types"]
for field in name.split("."):
type = type.split("[")[0]
type = specs[type][ext][field]
return type