創(chuàng)建Sphinx + GitHub + ReadtheDocs托管文檔

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

創(chuàng)建Sphinx + GitHub + ReadtheDocs托管文檔

Readthedocs在線電子書鏈接

image

??????????????????????????????????

Sphinx Github Readthedocs
image

|
image

|
image

|

最終效果

image

Linux配置

Win10 Ubuntu子系統(tǒng)路徑:%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs

更換Ubuntu源

step 1: 首先看看國內(nèi)有哪些源

名稱 域名
阿里 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國內(nèi)的一些鏡像

名稱 域名
阿里云 https://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/

修改 ~/.pip/pip.conf (沒有就創(chuàng)建一個), 內(nèi)容如下:

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

Github配置

克隆 一個新的公共的空白倉庫到本地 ~\Sphinx_GitHub_ReadtheDocs

目錄結(jié)構(gòu):

.
├── 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

目錄結(jié)構(gòu):

.
├── 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文件:

創(chuàng)建Sphinx + GitHub + ReadtheDocs托管文檔
=====================================================

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

   Sphinx_GitHub_ReadtheDocs

創(chuàng)建./source/Sphinx_GitHub_ReadtheDocs.md文件

# here is a test markdown file

然后同步到Github

Readthedocs配置

導入代碼庫:
image

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

image

完成

本文由Tsanfer's Blog 發(fā)布!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • # Awesome Python [![Awesome](https://cdn.rawgit.com/sindr...
    emily_007閱讀 2,336評論 0 3
  • Ubuntu系統(tǒng)自帶的源都是國外的網(wǎng)址,國內(nèi)用戶在使用的時候網(wǎng)速比較慢。一個軟件的下載是十分痛苦的,這里講解一下如...
    TechManZhang閱讀 5,142評論 0 5
  • 1.昨天和同事在樓下食堂吃飯,人多、擠,不僅要排隊打飯,還要排隊付款,高峰期要20分鐘才能吃上飯。怎么樣才能提高效...
    空靈一月閱讀 303評論 0 0
  • 錄音本來是我喜歡的事,一直以來我都在業(yè)余課外的錄音朗讀,把朗誦當做自己的愛好來做。 他們說我的音色還不錯,適合朗讀...
    常能琿閱讀 444評論 0 2
  • 《妊娠》其作品大多是描寫的是一群社會最基層的卑微的人,是一些瑣碎小事。通過農(nóng)村的日常生活充分展示了濃重的時代大背景...
    destiny書閱讀 1,242評論 0 0

友情鏈接更多精彩內(nèi)容