用sphinx生成rst工程文件夹(自己整理步骤)

2023-05-16

我得自己来总结一下这个步骤

 

之前在这篇博文里总结了一些

https://blog.csdn.net/sinat_16643223/article/details/110453400

确实是会给你生成一个文件夹的

https://www.ibm.com/developerworks/cn/opensource/os-sphinx-documentation/index.html

 

这里也说了会文件结构。

https://www.bilibili.com/video/BV1AC4y1a7WT?from=search&seid=4000075471295071593

 

 

 

https://blog.csdn.net/sinat_16643223/article/details/110823316

这篇文章里面也讲了建工程的步骤。

 

 

我想找一下这方面的基本资料,确定一下这方面构建起来的基本步骤。

 

首先时sphinx的官方文档,下面两个是一样的,注意百度搜sphinx  你搜RST可能搜不到什么资料的。

https://zh-sphinx-doc.readthedocs.io/en/latest/rest.html#id48

http://www.pythondoc.com/sphinx/contents.html

 

 

 

上面都说到一个命令,官网文档里也有,而且就是在定义文档结构里面。

http://www.pythondoc.com/sphinx/contents.html

http://www.pythondoc.com/sphinx/tutorial.html#id3

sphinx-quickstart

 

 

 

 

综上我觉得基本步骤就是  sphinx-quickstart  命令起来后,命令行会弹出一些配置提问,选择完后就装好了。

我就暂时先按下面的配置选项配一遍

配置提问如下所示

 

实际安装发现还是参照这个视频里面的教程来好一些,上面那个有些选项没有讲到,下面这个是真正每个都讲到了

https://www.bilibili.com/video/BV1AC4y1a7WT?from=search&seid=4000075471295071593

 

 

命令记录如下,就是在CMD上弄的

Microsoft Windows [版本 10.0.18363.1198]
(c) 2019 Microsoft Corporation。保留所有权利。

C:\Users\maxi>F:

F:\>cd 无人机

F:\无人机>cd 阿木实验室

F:\无人机\阿木实验室>cd 自己写的wiki初稿

F:\无人机\阿木实验室\自己写的wiki初稿>cd wiki_test

F:\无人机\阿木实验室\自己写的wiki初稿\wiki_test>sphinx-quickstart
Welcome to the Sphinx 1.7.4 quickstart utility.

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

Selected root path: .

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 [_]:

The project name will occur in several places in the built documentation.
> Project name: Prometheus_P300
> Author name(s): maxi
> Project release []: 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]:

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]: n
Indicate which of the following Sphinx extensions should be enabled:
> autodoc: automatically insert docstrings from modules (y/n) [n]:
> doctest: automatically test code snippets in doctest blocks (y/n) [n]:
> intersphinx: link between Sphinx documentation of different projects (y/n) [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]:
> ifconfig: conditional inclusion of content based on config values (y/n) [n]:
> viewcode: include links to the source code of documented Python objects (y/n) [n]:
> githubpages: create .nojekyll file to publish the document on GitHub pages (y/n) [n]:

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]: y
> Create Windows command file? (y/n) [y]: y

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.


F:\无人机\阿木实验室\自己写的wiki初稿\wiki_test>


弄好后生成的文件夹如下

_static和_templates都是空文件夹,build也是空文件夹。

 

没有看到docs文件夹和image文件夹,难道是要自己新建?

 

不过我看了下上面的博文说的,_static就是放图片的,可能source文件夹就是放rst文件的,比如index.rst就是放在source文件夹根目录下了。

 

这是阿木自己wiki下的source目录,我的生成的相同的地方就是都有conf.py和index.rst,也有专门放图片的文件夹,不同的地方是它自己有个专门的docs文件夹。

我生成的文件夹倒是和B站上那个视频生成的文件夹差不多,说明应该是没有问题的。makefile文件也有。

 

 

我  ./make html之后去build文件夹可以看到生成的html文件

之前build文件夹是空文件夹的

下面是打开index.html的结果

会显示我之前设定的项目名称,还有我可能 刚才设置的中文,所以这里显示的也有中文。本身上面./make html的时候我看到了

 

 

 

我把  基于prometheus的二维码降落教程.rst和对应的图片文件夹拷贝到这里,打开vscode预览没有问题,  ./make html编译后打开html,查看也是OK的。

 

所以之前图片路径  ../   这样  先跳出当前文件夹,再去其他文件夹这样的路径 之前不行可能是因为没有放在真正rst工程文件夹下面。我之前也是放在阿木的rst工程下面也是可以正常预览的,对吧,就放在自己临时建的两个文件夹这么弄行不通,这种路径预览不成。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

用sphinx生成rst工程文件夹(自己整理步骤) 的相关文章

随机推荐