Fix resolve_ref()
This commit is contained in:
parent
ea8f223298
commit
cd35f92607
@ -57,16 +57,19 @@ def resolve_ref(ref: str, website_url: Callable[[str], str] = website_url) -> st
|
||||
href = m['ref'].get(ref, '')
|
||||
if href:
|
||||
return href
|
||||
if ref.startswith('conf-'):
|
||||
base = 'generated/' + ref.rpartition('-')[0]
|
||||
href = f'{website_url(base)}#{ref}'
|
||||
if ref.startswith('conf-kitty-'):
|
||||
href = f'{website_url("conf")}#{ref}'
|
||||
elif ref.startswith('conf-kitten-'):
|
||||
parts = ref.split('-')
|
||||
href = website_url("kittens/" + parts[2] + f'#{ref}')
|
||||
elif ref.startswith('at_'):
|
||||
href = f'{website_url("generated/cli-kitty-at")}#{ref}'
|
||||
base = ref.split('_', 1)[1]
|
||||
href = website_url("remote-control/#at_" + base.replace('_', '-'))
|
||||
elif ref.startswith('action-group-'):
|
||||
href = f'{website_url("generated/actions")}#{ref}'
|
||||
href = f'{website_url("actions")}#{ref}'
|
||||
elif ref.startswith('action-'):
|
||||
frag = ref.partition('-')[-1].replace('_', '-')
|
||||
href = f'{website_url("generated/actions")}#{frag}'
|
||||
href = f'{website_url("actions")}#{frag}'
|
||||
return href
|
||||
|
||||
|
||||
|
||||
@ -78,10 +78,17 @@ class TestBuild(BaseTest):
|
||||
def test_docs_url(self):
|
||||
from kitty.utils import docs_url
|
||||
p = partial(docs_url, local_docs_root='/docs')
|
||||
self.ae(p(), 'file:///docs/index.html')
|
||||
self.ae(p('conf'), 'file:///docs/conf.html')
|
||||
self.ae(p('kittens/ssh#frag'), 'file:///docs/kittens/ssh.html#frag')
|
||||
self.ae(p('#ref=confloc'), 'file:///docs/conf.html#confloc')
|
||||
|
||||
def t(x, e):
|
||||
self.ae(p(x), 'file:///docs/' + e)
|
||||
t('', 'index.html')
|
||||
t('conf', 'conf.html')
|
||||
t('kittens/ssh#frag', 'kittens/ssh.html#frag')
|
||||
t('#ref=confloc', 'conf.html#confloc')
|
||||
t('#ref=conf-kitty-fonts', 'conf.html#conf-kitty-fonts')
|
||||
t('#ref=conf-kitten-ssh-xxx', 'kittens/ssh.html#conf-kitten-ssh-xxx')
|
||||
t('#ref=at_close_tab', 'remote-control.html#at_close-tab')
|
||||
t('#ref=action-copy', 'actions.html#copy')
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user