파이썬 문서 생성기 스핑크스 설치 First Steps with Sphinx
스핑크스 설치
1 | # pip install Sphinx | cs |
설치된 경로는 다음과 같다
/root/anaconda/envs/<가상환경명>/lib/python3.5/site-packages/sphinx
환경설정
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # sphinx-quickstart Welcome to the Sphinx 1.4.9 quickstart utility. Please enter values for the following settings (just press Enter to accept a default value, if one is given in brackets). ...... 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 sphinx-build command to build the docs, like so: sphinx-build -b builder ./source ./build where "builder" is one of the supported builders, e.g. html, latex or linkcheck. | cs |
버전에 따라 질문은 다름 (아래는 본 포스팅에 사용된 값임)
# |
항목 |
입력값 |
1 |
> Root path for the documentation [.]: Enter the root path for documentation. |
<ENTER> |
2 |
> Separate source and build directories (y/n) [n]: You have two options for placing the build directory for Sphinx output. | y |
3 |
> Name prefix for templates and static dir [_]: 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. |
<ENTER> |
4 |
> Project name: |
sample |
5 |
> Author name(s): |
alex |
6 |
> Project version: 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. | 0.01 |
7 |
> Project release [0.0.1]: |
<ENTER> |
8 |
> Project language [en]: 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. |
<ENTER> |
9 |
> Source file suffix [.rst]: |
<ENTER> |
10 |
> Name of your master document (without suffix) [index]: 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. | <ENTER> |
11 |
> Do you want to use the epub builder (y/n) [n]: Sphinx can also add configuration for epub output |
y |
12 |
> doctest: automatically test code snippets in doctest blocks (y/n) [n]: |
n |
13 |
> intersphinx: link between Sphinx documentation of different projects (y/n) [n]: |
y |
14 |
> todo: write "todo" entries that can be shown or hidden on build (y/n) [n]: |
n |
15 |
> coverage: checks for documentation coverage (y/n) [n]: |
n |
16 |
> imgmath: include math, rendered as PNG or SVG images (y/n) [n]: |
n |
17 |
> mathjax: include math, rendered in the browser by MathJax (y/n) [n]: |
n |
18 |
> ifconfig: conditional inclusion of content based on config values (y/n) [n]: |
y |
19 |
> viewcode: include links to the source code of documented Python objects (y/n) [n]: |
y |
20 |
> githubpages: create .nojekyll file to publish the document on GitHub pages (y/n) [n]: |
y |
21 |
> Create Makefile? (y/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. |
n |
22 |
> Create Windows command file? (y/n) [y]: |
n |
conf.py 와 마스터 문서인 index.rst 를 포함한 소스 디렉토리가 생성된다. 여기서 마스터 문서는 웰컴 페이지의 역할을 하게 되고, “table of contents tree” (or toctree) 라고 불리는 루트를 포함한다. 스핑크스가 하는 주된 기능 중 하나인 하나의 문서 체계에서 다수의 파일을 연결하는 방법인 reStructuredText 이다. 아래는 index.rst 파일의 모습이다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | .. projectVikander documentation master file, created by sphinx-quickstart on Mon Dec 5 18:35:52 2016. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Welcome to projectVikander's documentation! =========================================== Contents: .. toctree:: :maxdepth: 2 Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` | cs |
아래와 같이 directive 의 컨텐츠에 문서 리스트를 추가할 수 있다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | .. projectVikander documentation master file, created by sphinx-quickstart on Mon Dec 5 18:35:52 2016. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Welcome to projectVikander's documentation! =========================================== Contents: .. toctree:: :maxdepth: 2 intro tutorial Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` | cs |
빌드하기
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # sphinx-build -b html source build Running Sphinx v1.4.9 loading pickled environment... done building [mo]: targets for 0 po files that are out of date building [html]: targets for 1 source files that are out of date updating environment: 0 added, 1 changed, 0 removed reading sources... [100%] index looking for now-outdated files... none found pickling environment... done checking consistency... done preparing documents... done writing output... [100%] index generating indices... genindex writing additional pages... search copying static files... done copying extra files... done dumping search index in English (code: en) ... done dumping object inventory... done build succeeded. | cs |
First Steps with Sphinx http://www.sphinx-doc.org/en/1.4.8/tutorial.html