简介
本仓库主要是一些随笔杂记,采集用 sphinx 生成静态网页。 网页文档将托官到 readTheDocs项目主页
环境安装及生成静态网页
-
克隆工程至本地目录:
git clone git@gitcode.net:TGL233/notebook.git
-
创建本地 python 虚拟环境:
python -m venv .venv
-
激活本地虚拟环境:
.venv/Scripts/Activate.ps1
-
更新 pip 库:
python -m pip install pip --upgrade
-
安装依赖库:
pip install -r .\requirements.txt
注解: 国内镜像地址:
- 清华:https://pypi.tuna.tsinghua.edu.cn/simple - 阿里云:http://mirrors.aliyun.com/pypi/simple/ - 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ - 华中理工大学:http://pypi.hustunique.com/ - 山东理工大学:http://pypi.sdutlinux.org/ - 豆瓣:http://pypi.douban.com/simple/ 可在上面命令后加上 `-i https://pypi.tuna.tsinghua.edu.cn/simple` 来提速
注意: requirements.txt 文件中如果有中文注释的话,需保存为 GBK 编码,否则在 windows 下会报编码错误 由于readthedocs 是 ubuntu 的系统环境, 所以 requirements.txt 必须以 utf-8 的编码保后才能通过 readthedocs 的编译 所以可以生将文件暂存为 GBK 编码用于搭建 windows 下的本地环境,环境搭完后恢复成 utf-8 编码
python -X utf8=1 -m pip install -r ./requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
可以解决文件编码问题 -
激活虚拟环境:
./.venv/Scripts/Activate.ps1
-
终端编译生成 html 文档:
./make.bat html
(必须在虚拟环境激活的情况下) 通过mingw32-make html
生成 (必须在虚拟环境激活的情况下) -
打开刚生成的 html 文档:
./build/html/index.html
注: 只有在 source
目录下的 .md 和.rst 文件才会编译生成网页
Vscode 编译环境搭建
安装以下插件:
-
reStructuredText
用于辅助编辑 .rst 文件 -
reStructuredText Syntax highlighting
用于 .rst 文件语法高亮 -
Esbonio
用于 sphinx 项目文件预览