sphinx http://sphinx-doc.org 是用python写的一个写文档的工具,阿铭的linux入门教程就是用该工具写出来的 http://study.lishiming.net 它不仅可以生成html网页还可以生成pdf电子书。
在CentOS上如何安装 sphinx?
首先sphinx新版本对python版本有要求,首先需要是python-2.6 所以如果您的centos是5.x版本是安装不了较新版本的。
1. 下载sphinx http://pypi.python.org/packages/ ... e2a76ebedc76d8f71a3 如果该地址失效,请到官网 https://pypi.python.org/pypi/Sphinx#downloads
2. 安装 sphinx
tar zxvf Sphinx-1.2b1.tar.gz
cd Sphinx-1.2b1
python setup.py build
python setup.py install
3. 生成自己的第一个文档
sphinx-quickstart
根据自己需求填写相应项,y/n 都选y. 其中
Source file suffix [.rst]:
这一项要写成 .txt4. 写文档
进入 Root path for the documentation [.]: 定义的项目主目录,比如我的主目录为 /home/sphinx
cd /home/sphinx
vim source/index.txt
编辑索引页:然后编辑 test1.txt test2.txt ....
vim source/test1.txt
vim source/test2.txt
编辑好所有文章后,生成 html 网页
make html (需要在 /home/sphinx/) 执行
在CentOS上如何安装 sphinx?
首先sphinx新版本对python版本有要求,首先需要是python-2.6 所以如果您的centos是5.x版本是安装不了较新版本的。
1. 下载sphinx http://pypi.python.org/packages/ ... e2a76ebedc76d8f71a3 如果该地址失效,请到官网 https://pypi.python.org/pypi/Sphinx#downloads
2. 安装 sphinx
tar zxvf Sphinx-1.2b1.tar.gz
cd Sphinx-1.2b1
python setup.py build
python setup.py install
3. 生成自己的第一个文档
sphinx-quickstart
根据自己需求填写相应项,y/n 都选y. 其中
Source file suffix [.rst]:
这一项要写成 .txt
- Welcome to the Sphinx 1.2b1 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 [.]: /home/sphinx
- 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: 跟阿铭学Linux
- > Author name(s): Aming
- 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: 2
- > Project release [2]: 2
- 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]: .txt
- 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]: index
- Sphinx can also add configuration for epub output:
- > Do you want to use the epub builder (y/N) [n]: y
- Please indicate if you want to use one of the following Sphinx extensions:
- > autodoc: automatically insert docstrings from modules (y/N) [n]: y
- > doctest: automatically test code snippets in doctest blocks (y/N) [n]: y
- > intersphinx: link between Sphinx documentation of different projects (y/N) [n]: y
- > todo: write "todo" entries that can be shown or hidden on build (y/N) [n]: y
- > coverage: checks for documentation coverage (y/N) [n]: y
- > pngmath: include math, rendered as PNG images (y/N) [n]: y
- > mathjax: include math, rendered in the browser by MathJax (y/N) [n]: y
- Note: pngmath and mathjax cannot be enabled at the same time.
- pngmath has been deselected.
- > ifconfig: conditional inclusion of content based on config values (y/N) [n]: y
- > viewcode: include links to the source code of documented Python objects (y/N) [n]: y
- 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
进入 Root path for the documentation [.]: 定义的项目主目录,比如我的主目录为 /home/sphinx
cd /home/sphinx
vim source/index.txt
编辑索引页:
- .. toctree::
- :maxdepth: 2
- tets1
- test2
- test3
- test4
vim source/test1.txt
vim source/test2.txt
编辑好所有文章后,生成 html 网页
make html (需要在 /home/sphinx/) 执行
0
先安装texlive 用yum安装的版本较低,生成中文的pdf有问题,所以需要下载最新版本。
http://www.tug.org/texlive/acquire-netinstall.html
生成 pdf
make latex
make latexpdf
目前找了很多关于中文pdf的资料, 都试过,可就是不成功,所以目前暂时放弃了,以后有机会再来研究。
http://www.tug.org/texlive/acquire-netinstall.html
生成 pdf
make latex
make latexpdf
目前找了很多关于中文pdf的资料, 都试过,可就是不成功,所以目前暂时放弃了,以后有机会再来研究。
编辑回复