From b55a67ba34b3798f2a7a3dfa34409f6626371895 Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Mon, 26 Feb 2024 00:08:45 +0800 Subject: [PATCH] docs: improve docs for Magika deps Signed-off-by: Jack Cherng --- CHANGELOG.md | 2 +- docs/src/_snippets/links.md | 1 + .../experimental/dl-based-syntax-detection.md | 40 ++++++++++++++++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb8500c..9b8d1223 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 3.1.0 -- feat: configurable debounce time via `debound` setting +- feat: configurable debounce time via `debounce` setting ## 3.0.2 diff --git a/docs/src/_snippets/links.md b/docs/src/_snippets/links.md index dd5b1e56..5b994da7 100644 --- a/docs/src/_snippets/links.md +++ b/docs/src/_snippets/links.md @@ -12,6 +12,7 @@ [pc-lsp-json]: https://packagecontrol.io/packages/LSP-json [pc-lsp]: https://packagecontrol.io/packages/LSP [plugin-constraints-dir]: https://github.com/jfcherng-sublime/ST-AutoSetSyntax/tree/st4/plugin/rules/constraints +[plugin-dependencies-dir]: https://github.com/jfcherng-sublime/ST-AutoSetSyntax/tree/dependencies [plugin-matches-dir]: https://github.com/jfcherng-sublime/ST-AutoSetSyntax/tree/st4/plugin/rules/matches [python-regex-flags]: https://docs.python.org/3.8/library/re.html#re.A [python-regex-inline-flags]: https://docs.python.org/3.8/library/re.html#index-16 diff --git a/docs/src/experimental/dl-based-syntax-detection.md b/docs/src/experimental/dl-based-syntax-detection.md index bf2bcfc7..8327e692 100644 --- a/docs/src/experimental/dl-based-syntax-detection.md +++ b/docs/src/experimental/dl-based-syntax-detection.md @@ -15,14 +15,50 @@ It uses Google's [Magika](https://github.com/google/magika) library to detect th 1. Install dependencies. Run `AutoSetSyntax: Download Dependencies` from the command palette. - The dependencies can be up to 50 MB in size, so it may take a while. + The dependencies can be up to \~50 MB in size, so it may take a while. When it's done, there will be a popup dialogue. + !!! tip "If your machine have no access to GitHub..." + + You can download the dependencies on [GitHub][plugin-dependencies-dir] + basing on your machine's OS and CPU architecture by any means. + If you don't know which one to download, run the following command in Sublime Text's console: + + ```python + import AutoSetSyntax; AutoSetSyntax.plugin.constants.PLUGIN_PY_LIBS_URL + ``` + + Decompress the downloaded ZIP file into `Package Storage/AutoSetSyntax/` + so that the directory structure looks like the following: + + ```text + Package Storage + └─ AutoSetSyntax + └─ libs-py38@linux_x64 + ├── click + ├── click-8.1.7.dist-info + ├── colorama + ├── colorama-0.4.6.dist-info + ├── coloredlogs + ├── coloredlogs.pth + ├── coloredlogs-15.0.1.dist-info + ... + ``` + + You can open `Package Storage/AutoSetSyntax/` directory by running + the following Python code in Sublime Text's console: + + ```python + import AutoSetSyntax; (d := AutoSetSyntax.plugin.constants.PLUGIN_STORAGE_DIR).mkdir(parents=True, exist_ok=True); window.run_command("open_dir", {"dir": str(d)}) + ``` + 1. Enable the feature. Set `"magika.enabled"` to `true` in AutoSetSyntax's settings. -After you've done all steps above, it should just work without restarting Sublime Text. +After finishing all steps above, it should just work without restarting Sublime Text. +You may go [here](https://doc.rust-lang.org/rust-by-example/hello.html) to copy some Rust codes +and paste them into Sublime Text to test whether this feature works. ## Demo