From 3288400005041d6963e06cf6dd1187c115b1046f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 19 Aug 2022 12:38:10 +0530 Subject: [PATCH] Make the docs and man pages available in the macos bundle as well --- Makefile | 6 ++++++ kitty/conf/types.py | 2 +- kitty/constants.py | 19 +++++++++++++++++++ kitty_tests/check_build.py | 4 +++- setup.py | 2 ++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8b7de6dd6..5231798c5 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,12 @@ profile: app: python3 setup.py kitty.app $(VVAL) +linux-package: FORCE + rm -rf linux-package + python3 setup.py linux-package + +FORCE: + man: $(MAKE) -C docs man diff --git a/kitty/conf/types.py b/kitty/conf/types.py index f35a74602..9d98e90bc 100644 --- a/kitty/conf/types.py +++ b/kitty/conf/types.py @@ -52,7 +52,7 @@ def ref_map() -> Dict[str, Dict[str, str]]: return ans -def resolve_ref(ref: str) -> str: +def resolve_ref(ref: str, website_url: Callable[[str], str] = website_url) -> str: m = ref_map() href = m['ref'].get(ref, '') if href: diff --git a/kitty/constants.py b/kitty/constants.py index 201f4807b..e3ce0028f 100644 --- a/kitty/constants.py +++ b/kitty/constants.py @@ -249,3 +249,22 @@ def clear_handled_signals(*a: Any) -> None: signal.pthread_sigmask(signal.SIG_UNBLOCK, handled_signals) for s in handled_signals: signal.signal(s, signal.SIG_DFL) + + +@run_once +def local_docs() -> str: + d = os.path.dirname + base = d(d(kitty_exe())) + subdir = os.path.join('doc', 'kitty', 'html') + linux_ans = os.path.join(base, 'share', subdir) + if getattr(sys, 'frozen', False): + if is_macos: + return os.path.join(d(d(d(extensions_dir))), subdir) + return linux_ans + if os.path.isdir(linux_ans): + return linux_ans + for candidate in ('/usr', '/usr/local', '/opt/homebrew'): + q = os.path.join(candidate, 'share', subdir) + if os.path.isdir(q): + return q + return '' diff --git a/kitty_tests/check_build.py b/kitty_tests/check_build.py index e290cb124..741af9d2a 100644 --- a/kitty_tests/check_build.py +++ b/kitty_tests/check_build.py @@ -51,13 +51,15 @@ class TestBuild(BaseTest): def test_filesystem_locations(self) -> None: from kitty.constants import ( - logo_png_file, shell_integration_dir, terminfo_dir + local_docs, logo_png_file, shell_integration_dir, terminfo_dir ) zsh = os.path.join(shell_integration_dir, 'zsh') self.assertTrue(os.path.isdir(terminfo_dir), f'Terminfo dir: {terminfo_dir}') self.assertTrue(os.path.exists(logo_png_file), f'Logo file: {logo_png_file}') self.assertTrue(os.path.exists(zsh), f'Shell integration: {zsh}') self.assertTrue(os.access(os.path.join(shell_integration_dir, 'ssh', 'askpass.py'), os.X_OK)) + if getattr(sys, 'frozen', False): + self.assertTrue(os.path.isdir(local_docs()), f'Local docs: {local_docs()}') def test_ca_certificates(self): import ssl diff --git a/setup.py b/setup.py index bc2d2e3d8..110844bef 100755 --- a/setup.py +++ b/setup.py @@ -1280,6 +1280,8 @@ def create_macos_bundle_gunk(dest: str) -> None: os.mkdir(ddir / 'Contents') with open(ddir / 'Contents/Info.plist', 'wb') as fp: fp.write(macos_info_plist()) + copy_man_pages(str(ddir)) + copy_html_docs(str(ddir)) os.rename(ddir / 'share', ddir / 'Contents/Resources') os.rename(ddir / 'bin', ddir / 'Contents/MacOS') os.rename(ddir / 'lib', ddir / 'Contents/Frameworks')