IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> Sphinx+Read the Docs文档编辑器 -> 正文阅读

[开发工具]Sphinx+Read the Docs文档编辑器

建议Python3.6 官方虽然说支持python2.x 但是在 Python2.x下是安装不成功的(多次尝试之后发现是不成功的)

Sphinx

将标记语言转化为html页面。

标记语言默认支持:reStructuredText,可选:markdown

read the docs

免费的文档托管服务器。

安装

首先安装Sphinx

pip install sphinx

创建文档目录(mkdir docs),根据提示输入文档的标题还有版权信息等等,指定的目录就是工作目录

?  docs sphinx-quickstart
Welcome to the Sphinx 1.4.5 quickstart utility.

Please enter values for the following settings (just press Enter to
accept a default value, if one is given in brackets).

Enter the root path for documentation.
> Root path for the documentation [.]:   # 配置document路径,默认当前

You have two options for placing the build directory for Sphinx output.
Either, you use a directory "_build" within the root path, or you separate
"source" and "build" directories within the root path.
> Separate source and build directories (y/n) [n]:y    # 将原文件和编译文件分开

Inside the root directory, two more directories will be created; "_templates"
for custom HTML templates and "_static" for custom stylesheets and other static
files. You can enter another prefix (such as ".") to replace the underscore.
> Name prefix for templates and static dir [_]:    # 配置template,static路径名称

The project name will occur in several places in the built documentation.
> Project name: crwy    # 配置项目名,比如什么什么的帮助文档
> Author name(s): wuyue    # 配置作者名称,比如哪个作者或者团队维护

Sphinx has the notion of a "version" and a "release" for the
software. Each version can have multiple releases. For example, for
Python the version is something like 2.5 or 3.0, while the release is
something like 2.5.1 or 3.0a1.  If you don't need this dual structure,
just set both to the same value.
> Project version: 1.0.1    # 配置项目版本,比如大版本还有小版本
> Project release [1.0.1]:

If the documents are to be written in a language other than English,
you can select a language here by its language code. Sphinx will then
translate text that it generates into that language.

For a list of supported codes, see
http://sphinx-doc.org/config.html#confval-language.
> Project language [en]: zh_CN   # 配置项目语言,建议写中文

The file name suffix for source files. Commonly, this is either ".txt"
or ".rst".  Only files with this suffix are considered documents.
> Source file suffix [.rst]:    # 配置标记语言,默认.rst

One document is special in that it is considered the top node of the
"contents tree", that is, it is the root of the hierarchical structure
of the documents. Normally, this is "index", but if your "index"
document is a custom template, you can also set this to another filename.
> Name of your master document (without suffix) [index]:

Sphinx can also add configuration for epub output:
> Do you want to use the epub builder (y/n) [n]:

Please indicate if you want to use one of the following Sphinx extensions:
> autodoc: automatically insert docstrings from modules (y/n) [n]:
> doctest: automatically test code snippets in doctest blocks (y/n) [n]:
) [n]: sphinx: link between Sphinx documentation of different projects (y/n)
: todo: write "todo" entries that can be shown or hidden on build (y/n) [n]:
> coverage: checks for documentation coverage (y/n) [n]:
> imgmath: include math, rendered as PNG or SVG images (y/n) [n]:
> mathjax: include math, rendered in the browser by MathJax (y/n) [n]:
n]: config: conditional inclusion of content based on config values (y/n) [n
y/n) [n]: : include links to the source code of documented Python objects (y
s (y/n) [n]: : create .nojekyll file to publish the document on GitHub pages

A Makefile and a Windows command file can be generated for you so that you
only have to run e.g. `make html' instead of invoking sphinx-build
directly.
> Create Makefile? (y/n) [y]:    # 生成Makefile
> Create Windows command file? (y/n) [y]:    # 生成windows make脚本

Creating file ./source/conf.py.    #文档的编辑目录
Creating file ./source/index.rst.
Creating file ./Makefile.
Creating file ./make.bat.

Finished: An initial directory structure has been created.

You should now populate your master file ./source/index.rst. and create other documentation
source files. Use the Makefile to build the docs, like so:
   make builder
where "builder" is one of the supported builders, e.g. html, latex or linkcheck.

安装sphinx-rtd-theme主题,默认的主题是很不友好的,要换一下

pip install sphinx-rtd-theme

安装完毕主题之后修改config.py配置文件主题的配置如下

html_theme = 'sphinx_rtd_theme'

操作介绍(我这里安装的目录是/html/)

1、编辑/html/source下的.rst开头的文件

# tree  -L 1  (查看文件目录结构)
.
├── conf.py
├── fulu_01.rst
├── fulu_02.rst
├── fulu_03.rst
├── fulu_04.rst
├── fulu_05.rst
├── images
├── index.rst
├── _static
├── step_01.rst
├── step_02.rst
├── step_03.rst
├── step_04.rst
├── step_05.rst
├── step_06.rst
├── step_07.rst
└── _templates
3 directories, 14 files

2、看看导引文件

# cat index.rst
.. xxxxxxxxxx documentation master file, created by
   sphinx-quickstart on Tue Jan 12 01:38:29 2021.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.
Welcome to xxxxxxx's documentation!
======================================================
.. toctree::
   :maxdepth: 2
   :caption: Contents:
   step_01
   step_02
   step_03
   step_04
   step_05
   step_06
   step_07
   fulu_01
   fulu_02
   fulu_03
   fulu_04
   fulu_05
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

3、make操作

编辑完成之后在/html目录下 make html即可

# make  html
Running Sphinx v4.2.0
loading translations [zh-cn]... not available for built-in messages
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: 0 added, 2 changed, 0 removed
reading sources... [100%] step_02
/html/source/step_02.rst:6: WARNING: Unexpected indentation.
/html/source/step_02.rst:10: WARNING: Unexpected indentation.
/html/source/step_02.rst:14: WARNING: Unexpected indentation.
/html/source/step_02.rst:18: WARNING: Unexpected indentation.
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] step_02
generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 4 warnings.
The HTML pages are in build/html.

每次编辑维护都需要make html一下 才可以生效

  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2022-01-30 19:08:14  更:2022-01-30 19:09:12 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/15 10:11:58-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码