创建Sphinx + GitHub + ReadtheDocs托管文档

最新博客链接 "Tsanfer's Blog"

创建Sphinx + GitHub + ReadtheDocs托管文档

Readthedocs在线电子书链接

image

🎵🎵🎵🎵🎼🎼🎼🎼🎧🎼🎼🎼🎼🎵🎵🎵🎵

Sphinx Github Readthedocs
image

|
image

|
image

|

最终效果

image

Linux配置

Win10 Ubuntu子系统路径:%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs

更换Ubuntu源

step 1: 首先看看国内有哪些源

名称 域名
阿里 http://mirrors.aliyun.com/ubuntu/
163 http://mirrors.163.com/ubuntu/
中科大 https://mirrors.ustc.edu.cn/ubuntu/
清华 http://mirrors.tuna.tsinghua.edu.cn/ubuntu/
电子科大 http://ubuntu.dormforce.net/ubuntu/

step 2: 获取 Ubuntu 代号

lsb_release -a

Ubuntu 18.04.1,查出来的代号就是 bionic.

step 3: 编辑源

image

红色边框:服务器地址

紫色边框:Ubuntu 的代号(Codename)

step 4: 修改源文件 sources.list

先备份

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bcakup

再修改(如改为163源)

#163源
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse

##測試版源
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

# 源碼
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse

##測試版源
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

step 5: 更新软件列表和升级

更新软件列表(检测出可更新的软件):

sudo apt update

更新软件:

sudo apt upgrade

安装Python3、pip

# 安装python3
sudo apt install python3
# 安装pip
sudo apt install python3-pip

更换pip源

pip国内的一些镜像

名称 域名
阿里云 https://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host=mirrors.aliyun.com

Github配置

克隆 一个新的公共的空白仓库到本地 ~\Sphinx_GitHub_ReadtheDocs

目录结构:

.
├── LICENSE
└── README.md

Sphinx配置

安装Sphinx、及其插件

pip3 install sphinx sphinx_rtd_theme recommonmark sphinx-markdown-tables sphinxemoji

初始化Sphinx

# 进入Git根目录
cd ~/Sphinx_GitHub_ReadtheDocs
# 开始快速配置sphinx
sphinx-quickstart

# 选择把源文件和删除文件分开(y)
> Separate source and build directories (y/n) [n]:y
# 项目名称
> Project name: Sphinx_GitHub_ReadtheDocs
# 作者姓名
> Author name(s): Tsanfer
# 版本号
> Project release []: 0.2
# 语言
> Project language [en]: zh_CN

目录结构:

.
├── LICENSE
├── Makefile
├── README.md
├── make.bat
└── source
    ├── _static
    ├── _templates
    ├── conf.py
    └── index.rst

验证配置是否正确:

cd ~/Sphinx_GitHub_ReadtheDocs
make html

浏览器打开./build/index.html查看

配置Sphinx主题,插件

配置./source/conf.py配置文件:

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.

extensions = [
        'recommonmark',
        'sphinx_markdown_tables',
        'sphinxemoji.sphinxemoji',
]

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# The master toctree document.
master_doc = 'index'

添加./requirements.txt pip要求文件(Readthedocs配置时需要用到)

# markdown suport
recommonmark
# markdown table suport
sphinx-markdown-tables
#emoji
sphinxemoji

# theme default rtd

# crate-docs-theme
sphinx-rtd-theme

更改标题,添加目录,添加文件

配置./source/index.rst文件:

创建Sphinx + GitHub + ReadtheDocs托管文档
=====================================================

.. toctree::
   :maxdepth: 2
   :numbered:

   Sphinx_GitHub_ReadtheDocs

创建./source/Sphinx_GitHub_ReadtheDocs.md文件

# here is a test markdown file

然后同步到Github

Readthedocs配置

导入代码库:
image

指定pip要求文件: ./requirements.txt

image

完成

本文由Tsanfer's Blog 发布!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • # Awesome Python [![Awesome](https://cdn.rawgit.com/sindr...
    emily_007阅读 6,595评论 0 3
  • Ubuntu系统自带的源都是国外的网址,国内用户在使用的时候网速比较慢。一个软件的下载是十分痛苦的,这里讲解一下如...
    TechManZhang阅读 10,426评论 0 5
  • 1.昨天和同事在楼下食堂吃饭,人多、挤,不仅要排队打饭,还要排队付款,高峰期要20分钟才能吃上饭。怎么样才能提高效...
    空灵一月阅读 1,774评论 0 0
  • 录音本来是我喜欢的事,一直以来我都在业余课外的录音朗读,把朗诵当做自己的爱好来做。 他们说我的音色还不错,适合朗读...
    常能珲阅读 3,064评论 0 2
  • 《妊娠》其作品大多是描写的是一群社会最基层的卑微的人,是一些琐碎小事。通过农村的日常生活充分展示了浓重的时代大背景...
    destiny书阅读 4,719评论 0 0