From 77c216570de68c77bb58bbfebb2a7f48c8f54de8 Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Sat, 24 Feb 2024 18:18:48 +0800 Subject: [PATCH] copy requirements.txt to site root, so users can get and install them in one command --- docs/build_hooks.py | 11 +++++++++++ docs/quick_start.md | 8 +++++++- docs/quick_start.zh.md | 10 ++++++++-- docs/requirements.txt | 2 ++ mkdocs.yml | 6 +++++- 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 docs/build_hooks.py diff --git a/docs/build_hooks.py b/docs/build_hooks.py new file mode 100644 index 0000000..97d1b03 --- /dev/null +++ b/docs/build_hooks.py @@ -0,0 +1,11 @@ +import shutil +from pathlib import Path + +HERE = Path(__file__).parent +REPOS_ROOT = HERE.parent + + +def on_post_build(config, **kwargs): + site_dir = Path(config['site_dir']) + for file in ['requirements.txt', 'requirements.optional.txt']: + shutil.copy(REPOS_ROOT / file, site_dir) diff --git a/docs/quick_start.md b/docs/quick_start.md index 0d1845b..1ac44d2 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -28,6 +28,12 @@ Prime Backup requires a few python libraries to run, they are all listed in the Use command `pip3 install -r requirements.txt` to install all required Python requirements +You can also use the following command to install all required python packages for the latest Prime Backup in one step + +```shell +pip3 install -r {{ config.site_url }}requirements.txt +``` + ### Optional requirements Some Prime Backup features requires python libraries that does not listed in the requirements.txt, @@ -36,7 +42,7 @@ because it might [take you some effort](https://github.com/oconnor663/blake3-py/ If you want to have full features of Prime Backup, you can use the following command in advanced: ```bash -pip3 install blake3 lz4 +pip3 install -r {{ config.site_url }}requirements.optional.txt ``` These optional requirements are also stored in the [requirements.optional.txt](https://github.com/TISUnion/PrimeBackup/blob/master/requirements.optional.txt) diff --git a/docs/quick_start.zh.md b/docs/quick_start.zh.md index dcd96d0..c572c9e 100644 --- a/docs/quick_start.zh.md +++ b/docs/quick_start.zh.md @@ -28,15 +28,21 @@ Prime Backup 需要一些 python 库才能运行,它们都被列在了 使用命令 `pip3 install -r requirements.txt` 即可安装所有需要的 Python 依赖 +除此之外,你也可以使用以下指令一键安装所有需要的 Python 依赖 + +```shell +pip3 install -r {{ config.site_url }}requirements.txt +``` + ### 可选依赖 一些 Prime Backup 功能所需要的 Python 库并没有在 requirements.txt 中列出, 因为在某些环境下安装这些依赖库可能会 [花不少功夫](https://github.com/oconnor663/blake3-py/issues/41) -如果你想解锁 Prime Backup 的全部功能选项,你可以使用以下命令: +如果你想解锁 Prime Backup 的全部功能特性,你可以使用以下命令: ```bash -pip3 install blake3 lz4 +pip3 install -r {{ config.site_url }}requirements.optional.txt ``` 这些可选的依赖也被列在了 [requirements.optional.txt](https://github.com/TISUnion/PrimeBackup/blob/master/requirements.optional.txt) 里 diff --git a/docs/requirements.txt b/docs/requirements.txt index 1672fd9..d7b5899 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,7 @@ mkdocs +mkdocs-macros-plugin mkdocs-material mkdocs-mermaid2-plugin +mkdocs-simple-hooks mkdocs-static-i18n[material] pymdown-extensions diff --git a/mkdocs.yml b/mkdocs.yml index 67968bf..e827cde 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -64,7 +64,6 @@ theme: name: Switch to system preference plugins: - - search - i18n: # https://ultrabug.github.io/mkdocs-static-i18n/getting-started/quick-start/#configure-the-plugin-in-your-mkdocsyml docs_structure: suffix @@ -80,9 +79,14 @@ plugins: site_name: Prime Backup 文档 nav_translations: Reference: 参考 + - macros # https://mkdocs-mermaid2.readthedocs.io/ - mermaid2: javascript: js/mermaid-10.8.0.min.js + - mkdocs-simple-hooks: + hooks: + on_post_build: docs.build_hooks:on_post_build + - search nav: - index.md