Merge branch 'docs' of https://github.com/page-down/kitty
This commit is contained in:
commit
957eafbef0
@ -14,7 +14,7 @@ def find_explicit_targets(text: str) -> Iterator[str]:
|
|||||||
|
|
||||||
|
|
||||||
def main() -> Dict[str, str]:
|
def main() -> Dict[str, str]:
|
||||||
refs = {'github_discussions': 'https://github.com/kovidgoyal/kitty/discussions'}
|
refs = {}
|
||||||
base = os.path.dirname(os.path.abspath(__file__))
|
base = os.path.dirname(os.path.abspath(__file__))
|
||||||
for dirpath, dirnames, filenames in os.walk(base):
|
for dirpath, dirnames, filenames in os.walk(base):
|
||||||
if 'generated' in dirnames:
|
if 'generated' in dirnames:
|
||||||
@ -25,7 +25,17 @@ def main() -> Dict[str, str]:
|
|||||||
raw = stream.read()
|
raw = stream.read()
|
||||||
href = os.path.relpath(stream.name, base).replace(os.sep, '/')
|
href = os.path.relpath(stream.name, base).replace(os.sep, '/')
|
||||||
href = href.rpartition('.')[0] + '/'
|
href = href.rpartition('.')[0] + '/'
|
||||||
|
first_line = raw.lstrip('\n').partition('\n')[0]
|
||||||
|
first_target_added = False
|
||||||
for explicit_target in find_explicit_targets(raw):
|
for explicit_target in find_explicit_targets(raw):
|
||||||
|
# Shorten the reference link to the top of the page.
|
||||||
|
# Note that anchor links should still be used in HTML docs
|
||||||
|
# to allow jumping within the same page.
|
||||||
|
if not first_target_added:
|
||||||
|
first_target_added = True
|
||||||
|
if first_line.startswith(f'.. _{explicit_target}:'):
|
||||||
|
refs[explicit_target] = href
|
||||||
|
continue
|
||||||
refs[explicit_target] = href + f'#{explicit_target.replace("_", "-")}'
|
refs[explicit_target] = href + f'#{explicit_target.replace("_", "-")}'
|
||||||
return {'ref': refs}
|
return {'ref': refs}
|
||||||
|
|
||||||
|
|||||||
@ -193,7 +193,7 @@ The :opt:`remote_control_password` can be specified multiple times to create
|
|||||||
different passwords with different capabilities. Run the following to get a
|
different passwords with different capabilities. Run the following to get a
|
||||||
list of all action names::
|
list of all action names::
|
||||||
|
|
||||||
kitty @ -h
|
kitty @ --help
|
||||||
|
|
||||||
You can even use glob patterns to match action names, for example:
|
You can even use glob patterns to match action names, for example:
|
||||||
|
|
||||||
|
|||||||
@ -561,7 +561,7 @@ class Boss:
|
|||||||
|
|
||||||
For example::
|
For example::
|
||||||
|
|
||||||
map F1 remote_control set-spacing margin=30
|
map f1 remote_control set-spacing margin=30
|
||||||
|
|
||||||
See :ref:`rc_mapping` for details.
|
See :ref:`rc_mapping` for details.
|
||||||
''')
|
''')
|
||||||
|
|||||||
20
kitty/cli.py
20
kitty/cli.py
@ -168,7 +168,9 @@ def file(x: str) -> str:
|
|||||||
|
|
||||||
@role
|
@role
|
||||||
def doc(x: str) -> str:
|
def doc(x: str) -> str:
|
||||||
return website_url(x)
|
t, q = text_and_target(x)
|
||||||
|
url = f'kitty+doc://{hostname()}/{q.lstrip("/")}'
|
||||||
|
return hyperlink_for_url(url, t)
|
||||||
|
|
||||||
|
|
||||||
@run_once
|
@run_once
|
||||||
@ -193,6 +195,21 @@ def ac(x: str) -> str:
|
|||||||
return ref_hyperlink(x, 'action-')
|
return ref_hyperlink(x, 'action-')
|
||||||
|
|
||||||
|
|
||||||
|
@role
|
||||||
|
def iss(x: str) -> str:
|
||||||
|
return ref_hyperlink(x, 'github-issue-')
|
||||||
|
|
||||||
|
|
||||||
|
@role
|
||||||
|
def pull(x: str) -> str:
|
||||||
|
return ref_hyperlink(x, 'github-pr-')
|
||||||
|
|
||||||
|
|
||||||
|
@role
|
||||||
|
def disc(x: str) -> str:
|
||||||
|
return ref_hyperlink(x, 'github-discussion-')
|
||||||
|
|
||||||
|
|
||||||
OptionSpecSeq = List[Union[str, OptionDict]]
|
OptionSpecSeq = List[Union[str, OptionDict]]
|
||||||
|
|
||||||
|
|
||||||
@ -779,7 +796,6 @@ Output commands received from child process to STDOUT.
|
|||||||
Replay previously dumped commands. Specify the path to a dump file previously
|
Replay previously dumped commands. Specify the path to a dump file previously
|
||||||
created by :option:`{appname} --dump-commands`. You
|
created by :option:`{appname} --dump-commands`. You
|
||||||
can open a new kitty window to replay the commands with::
|
can open a new kitty window to replay the commands with::
|
||||||
|
|
||||||
{appname} sh -c "{appname} --replay-commands /path/to/dump/file; read"
|
{appname} sh -c "{appname} --replay-commands /path/to/dump/file; read"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,18 @@ def resolve_ref(ref: str, website_url: Callable[[str], str] = website_url) -> st
|
|||||||
href = f'actions/#{frag}'
|
href = f'actions/#{frag}'
|
||||||
elif ref.startswith('term-') or ref.startswith('envvar-'):
|
elif ref.startswith('term-') or ref.startswith('envvar-'):
|
||||||
href = 'glossary/#' + ref
|
href = 'glossary/#' + ref
|
||||||
return website_url(href)
|
elif ref.startswith('github-'):
|
||||||
|
href = 'https://github.com/kovidgoyal/kitty'
|
||||||
|
parts = ref.split('-')
|
||||||
|
if parts[1] == 'issue':
|
||||||
|
href = f'{href}/issues/{parts[2]}'
|
||||||
|
elif parts[1] == 'pr':
|
||||||
|
href = f'{href}/pull/{parts[2]}'
|
||||||
|
elif parts[1] == 'discussion':
|
||||||
|
href = f'{href}/discussions/{parts[2]}'
|
||||||
|
if not (href.startswith('https://') or href.startswith('http://')):
|
||||||
|
href = website_url(href)
|
||||||
|
return href
|
||||||
|
|
||||||
|
|
||||||
def remove_markup(text: str) -> str:
|
def remove_markup(text: str) -> str:
|
||||||
@ -84,27 +95,28 @@ def remove_markup(text: str) -> str:
|
|||||||
return t, q
|
return t, q
|
||||||
|
|
||||||
def sub(m: 'Match[str]') -> str:
|
def sub(m: 'Match[str]') -> str:
|
||||||
if m.group(1) == 'ref':
|
if m.group(1) in ('ref', 'iss', 'pull', 'disc'):
|
||||||
t, q = extract(m)
|
t, q = extract(m)
|
||||||
|
if m.group(1) == 'iss':
|
||||||
|
q = f'github-issue-{q}'
|
||||||
|
elif m.group(1) == 'pull':
|
||||||
|
q = f'github-pr-{q}'
|
||||||
|
elif m.group(1) == 'disc':
|
||||||
|
q = f'github-discussion-{q}'
|
||||||
url = resolve_ref(q)
|
url = resolve_ref(q)
|
||||||
if not url:
|
if not url:
|
||||||
raise KeyError(f'Failed to resolve :ref: {q}')
|
raise KeyError(f'Failed to resolve :{m.group(1)}: {q}')
|
||||||
return f'{t} <{url}>'
|
return f'{t} <{url}>'
|
||||||
if m.group(1) == 'doc':
|
if m.group(1) == 'doc':
|
||||||
t, q = extract(m)
|
t, q = extract(m)
|
||||||
return f'{t} <{website_url(q.lstrip("/"))}>'
|
return f'{t} <{website_url(q)}>'
|
||||||
if m.group(1) == 'ac':
|
if m.group(1) in ('term', 'option'):
|
||||||
q = m.group(2).split('<')[-1].rstrip('>')
|
|
||||||
return q
|
|
||||||
if m.group(1) == 'term':
|
|
||||||
t, _ = extract(m)
|
t, _ = extract(m)
|
||||||
return t
|
return t
|
||||||
if m.group(1) == 'option':
|
if m.group(1) in ('ac', 'opt'):
|
||||||
t, _ = extract(m)
|
|
||||||
return t
|
|
||||||
if m.group(1) == 'disc':
|
|
||||||
t, q = extract(m)
|
t, q = extract(m)
|
||||||
return f'{t} {resolve_ref("github_discussions")}/{q}'
|
return f'{t} {q}' if q and q != t else t
|
||||||
|
|
||||||
return str(m.group(2))
|
return str(m.group(2))
|
||||||
|
|
||||||
return re.sub(r':([a-zA-Z0-9]+):`(.+?)`', sub, text, flags=re.DOTALL)
|
return re.sub(r':([a-zA-Z0-9]+):`(.+?)`', sub, text, flags=re.DOTALL)
|
||||||
|
|||||||
@ -237,7 +237,7 @@ def website_url(doc_name: str = '', website: str = 'https://sw.kovidgoyal.net/ki
|
|||||||
if base:
|
if base:
|
||||||
base += '/'
|
base += '/'
|
||||||
doc_name = base + (f'#{frag}' if frag else '')
|
doc_name = base + (f'#{frag}' if frag else '')
|
||||||
return website + doc_name
|
return website + doc_name.lstrip('/')
|
||||||
|
|
||||||
|
|
||||||
handled_signals: Set[int] = set()
|
handled_signals: Set[int] = set()
|
||||||
|
|||||||
@ -59,24 +59,24 @@ default=window
|
|||||||
choices=window,tab,os-window,overlay,background,clipboard,primary
|
choices=window,tab,os-window,overlay,background,clipboard,primary
|
||||||
Where to launch the child process:
|
Where to launch the child process:
|
||||||
|
|
||||||
:term:`window`
|
:code:`window`
|
||||||
a new :term:`window` in the current tab,
|
A new :term:`kitty window <window>` in the current tab
|
||||||
|
|
||||||
:term:`tab`
|
:code:`tab`
|
||||||
a new tab in the current :term:`OS Window <os_window>`
|
A new :term:`tab` in the current OS window
|
||||||
|
|
||||||
:term:`os-window <os_window>`
|
:code:`os-window <os_window>`
|
||||||
a new operating system window
|
A new :term:`operating system window <os_window>`
|
||||||
|
|
||||||
:term:`overlay`
|
:code:`overlay`
|
||||||
an overlay window covering the current active window.
|
An :term:`overlay window <overlay>` covering the current active kitty window
|
||||||
|
|
||||||
:italic:`background`
|
:code:`background`
|
||||||
the process will be run in the background, without a window
|
The process will be run in the :italic:`background`, without a kitty window.
|
||||||
|
|
||||||
:italic:`clipboard` and :italic:`primary`
|
:code:`clipboard`, :code:`primary`
|
||||||
are meant to work with :option:`--stdin-source <launch --stdin-source>` to copy
|
These two are meant to work with :option:`--stdin-source <launch --stdin-source>` to copy
|
||||||
data to the system clipboard or primary selection.
|
data to the :italic:`system clipboard` or :italic:`primary selection`.
|
||||||
|
|
||||||
#placeholder_for_formatting#
|
#placeholder_for_formatting#
|
||||||
|
|
||||||
|
|||||||
@ -2711,7 +2711,7 @@ Glob patterns can be used too, for example::
|
|||||||
|
|
||||||
To get a list of available actions, run::
|
To get a list of available actions, run::
|
||||||
|
|
||||||
kitty @ -h
|
kitty @ --help
|
||||||
|
|
||||||
A set of actions to be allowed when no password is sent can be specified by using an empty
|
A set of actions to be allowed when no password is sent can be specified by using an empty
|
||||||
password, for example::
|
password, for example::
|
||||||
|
|||||||
@ -1665,7 +1665,7 @@ class Window:
|
|||||||
|
|
||||||
For example::
|
For example::
|
||||||
|
|
||||||
map F1 signal_child SIGTERM
|
map f1 signal_child SIGTERM
|
||||||
''')
|
''')
|
||||||
def signal_child(self, *signals: int) -> None:
|
def signal_child(self, *signals: int) -> None:
|
||||||
pid = self.child.pid_for_cwd
|
pid = self.child.pid_for_cwd
|
||||||
@ -1679,9 +1679,9 @@ class Window:
|
|||||||
For example::
|
For example::
|
||||||
|
|
||||||
# show the config docs
|
# show the config docs
|
||||||
map F1 show_kitty_doc conf
|
map f1 show_kitty_doc conf
|
||||||
# show the ssh kitten docs
|
# show the ssh kitten docs
|
||||||
map F1 show_kitty_doc kittens/ssh
|
map f1 show_kitty_doc kittens/ssh
|
||||||
''')
|
''')
|
||||||
def show_kitty_doc(self, which: str = '') -> None:
|
def show_kitty_doc(self, which: str = '') -> None:
|
||||||
url = docs_url(which)
|
url = docs_url(which)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user