-
Notifications
You must be signed in to change notification settings - Fork 141
/
main.py
27 lines (22 loc) · 879 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
27
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, os.path.dirname(env.page.file.src_uri))
return f"[{text}]({path})"
@env.macro
def link_ad_api(name):
return create_relative_link(name, f"design/autoware-interfaces/ad-api/list/{name}.md")
@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]
ext = "msg"
return type