Ubuntu sphinx-doc install
sphinx 의 경우 Python 문서를 위해 만들어졌으며 소프트웨어 문서화를 위한 좋은 기능을 가지고 있습니다.
sphinx-doc : http://www.sphinx-doc.org/en/1.6/index.html
설치참고: https://docs-korean-sphinx.readthedocs.io/ko/docs-korean/tutorial_ko.html
ubuntu sphinx-doc 설치
test@ubuntu-docs:~$ sudo apt-get install python-sphinx python-pip make
apt-get 으로 인스톨 했다면 pip install sphinx 를 하실 필요가 없습니다.
pip list 명령어로 확인가능
Python 이 설치 되어 있으면 pip 명령어로 손쉽게 설치를 진행 할수 있습니다.
pip 는 파이썬 으로 작성된 패키지 소프트웨어를 설치 , 관리 하는 패키지 관리 시스템 입니다.
자세한 내용은 https://pypi.org/project/pip/ 에서 확인 가능합니다.
test@ubuntu-docs:~$ pip install sphinx
sphinx 문서 환경설정
문서 작성시 해당 디렉토리에 설정 파일을 생성 합니다.
shinx-quickstart 명령어를 통하여 환경을 설정 할수 있습니다.
대략적으로 필요 한 부분만 y를 입력 하여 설정을 진행 합니다.
test@ubuntu-docs:~$ mkdir -p Workspace/docs test@ubuntu-docs:~$ sphinx-quickstart test@ubuntu-docs:~$ sphinx-quickstart Welcome to the Sphinx 1.3.6 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/test/Workspace/docs 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]: 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: opensource docs > Author name(s): user01 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 > Project release [1.0]: 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]: ko 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]: 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]: > 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]: > coverage: checks for documentation coverage (y/n) [n]: > pngmath: include math, rendered as PNG 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]: 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]: > Create Windows command file? (y/n) [y]: n Creating file /home/test/Workspace/docs/conf.py. Creating file /home/test/Workspace/docs/index.rst. Creating file /home/test/Workspace/docs/Makefile. Finished: An initial directory structure has been created. You should now populate your master file /home/test/Workspace/docs/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. test@ubuntu-docs:~$
shinx-quickstart 에서 설정한 문서 위치로 이동 합니다.
test@ubuntu-docs:~$ cd Workspace/docs/ test@ubuntu-docs:~/Workspace/docs$ ls -al total 44 drwxrwxr-x 5 test test 4096 Sep 30 19:56 . drwxrwxr-x 3 test test 4096 Sep 30 19:44 .. drwxrwxr-x 2 test test 4096 Sep 30 19:56 _build -rw-rw-r-- 1 test test 9445 Sep 30 19:56 conf.py -rw-rw-r-- 1 test test 450 Sep 30 19:56 index.rst -rw-rw-r-- 1 test test 7688 Sep 30 19:56 Makefile drwxrwxr-x 2 test test 4096 Sep 30 19:56 _static drwxrwxr-x 2 test test 4096 Sep 30 19:56 _templates test@ubuntu-docs:~/Workspace/docs$
make html
test@ubuntu-docs:~/Workspace/docs$ make html sphinx-build -b html -d _build/doctrees . _build/html Running Sphinx v1.3.6 making output directory... loading translations [ko]... done loading pickled environment... not yet created loading intersphinx inventory from https://docs.python.org/objects.inv... 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: 1 added, 0 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. Build finished. The HTML pages are in _build/html. test@ubuntu-docs:~/Workspace/docs$
make html 동작 확인
리눅스 Desktop 을 사용한다면 /home/test/Workspace/docs/_build/html/index.html 을 확인 하시면 됩니다.
</html>test@ubuntu-docs:~/Workspace/docs$ cat _build/html/index.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome to opensource docs’s documentation! — opensource docs 1.0 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: './', VERSION: '1.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="_static/translations.js"></script> <link rel="top" title="opensource docs 1.0 documentation" href="#" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> ~중략
설치는 위에 까지 하여 마무리 되었습니다.
간략하게 정리해본 sphinx-doc 설치법 이며 Nginx or Apache Web Site 와 같이 사용하면 좋을것으로 보입니다.
sphinx-autobuild 패키지 설치시 http://127.0.0.1:8000 접속으로도 확인 가능합니다.
sphinx-autobuild 패키지 설치
test@ubuntu-docs:~/Workspace/web-docs/docs$ pip install sphinx sphinx-autobuild --user test@ubuntu-docs:~/Workspace/web-docs$ sphinx-autobuild . _build/html +--------- manually triggered build --------------------------------------------- Error: Config directory doesn't contain a conf.py file. +-------------------------------------------------------------------------------- [I 181001 00:22:43 server:292] Serving on http://127.0.0.1:8000 [I 181001 00:22:43 handlers:59] Start watching changes [I 181001 00:22:43 handlers:61] Start detecting changes