install sphinx to ubuntu on WSL(Windows Subsystem for Linux)

## setting WSL(Windows Subsystem for Linux)
+ open 'PowerShell' as Administrator, then input command below.

```shell:PowerShell
> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
```
+ if display "reboot is required", then restart your PC

## download ubuntu to your home directory '~'
1. [Manually download Windows Subsystem for Linux distro packages](https://docs.microsoft.com/en-us/windows/wsl/install-manual)
1. Windows10 build lower than 1804
   + [Ubuntu 16.04](https://aka.ms/wsl-ubuntu-1604)
      + Ubuntu.1604.2017.711.0_v1.appx
2. Windows10 build upper over and include 1804
   + [Ubuntu 18.04](https://aka.ms/wsl-ubuntu-1804) 
      + CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2018.817.0_x64__79rhkp1fndgsc.Appx
1. rename downloaded '.appx' file to 'Ubuntu.zip' and move some directory as you like. 

+ case Ubuntu 16.04

```shell:PowerShell
> Rename-Item ~/Ubuntu.1604.2017.711.0_v1.appx ~/Ubuntu.zip
> Expand-Archive ~/Ubuntu.zip ~/Ubuntu
```

+ case Ubuntu 18.04

```shell:PowerShell
> Rename-Item ~/CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2018.817.0_x64__79rhkp1fndgsc.Appx ~/Ubuntu.zip
> Expand-Archive ~/Ubuntu.zip ~/Ubuntu
```

## run 'ubuntu'

```shell:PowerShell
> ~/Ubuntu/ubuntu.exe
```

then show 'ubuntu' shell prompt below

```shell:PowerShell
teruroom@TeruroomPC01:~$
```

## comfirm version of Python

```shell:PowerShell
$ python --version
```
or

```shell:PowerShell
$ python3 --version
```
if you want version up Python then see [install Python3.6.8 to ubuntu](https://qiita.com/teruroom/items/4957258784f9182df04f)

## install 'sphinx'

```shell:PowerShell
$ sudo pip install sphinx
```
if your PC via proxy to internet, then input command below.

```shell:PowerShell
$ pip install sphinx --proxy=user:password@proxy.domein.co.jp:portno
```
then output below, you must root password

```shell:PowerShell
[sudo] password for teruroom:
```

then output below

```shell:PowerShell
The directory '/home/teruroom/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/teruroom/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting sphinx
  Downloading https://files.pythonhosted.org/packages/7d/66/a4af242b4348b729b9d46ce5db23943ce9bca7da9bbe2ece60dc27f26420/Sphinx-1.8.5-py2.py3-none-any.whl (3.1MB)
    100% |████████████████████████████████| 3.1MB 5.9MB/s
Collecting imagesize (from sphinx)
  Downloading https://files.pythonhosted.org/packages/fc/b6/aef66b4c52a6ad6ac18cf6ebc5731ed06d8c9ae4d3b2d9951f261150be67/imagesize-1.1.0-py2.py3-none-any.whl
Collecting Pygments>=2.0 (from sphinx)
  Downloading https://files.pythonhosted.org/packages/13/e5/6d710c9cf96c31ac82657bcfb441df328b22df8564d58d0c4cd62612674c/Pygments-2.3.1-py2.py3-none-any.whl (849kB)
    100% |████████████████████████████████| 849kB 8.0MB/s
Collecting snowballstemmer>=1.1 (from sphinx)
  Downloading https://files.pythonhosted.org/packages/d4/6c/8a935e2c7b54a37714656d753e4187ee0631988184ed50c0cf6476858566/snowballstemmer-1.2.1-py2.py3-none-any.whl (64kB)
    100% |████████████████████████████████| 71kB 7.6MB/s
Collecting Jinja2>=2.3 (from sphinx)
  Downloading https://files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl (126kB)
    100% |████████████████████████████████| 133kB 18.1MB/s
Collecting babel!=2.0,>=1.3 (from sphinx)
  Downloading https://files.pythonhosted.org/packages/b8/ad/c6f60602d3ee3d92fbed87675b6fb6a6f9a38c223343ababdb44ba201f10/Babel-2.6.0-py2.py3-none-any.whl (8.1MB)
    100% |████████████████████████████████| 8.1MB 3.4MB/s
Collecting six>=1.5 (from sphinx)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /opt/python3.6.8/lib/python3.6/site-packages (from sphinx) (40.6.2)
Collecting alabaster<0.8,>=0.7 (from sphinx)
  Downloading https://files.pythonhosted.org/packages/10/ad/00b090d23a222943eb0eda509720a404f531a439e803f6538f35136cae9e/alabaster-0.7.12-py2.py3-none-any.whl
Collecting docutils>=0.11 (from sphinx)
  Downloading https://files.pythonhosted.org/packages/36/fa/08e9e6e0e3cbd1d362c3bbee8d01d0aedb2155c4ac112b19ef3cae8eed8d/docutils-0.14-py3-none-any.whl (543kB)
    100% |████████████████████████████████| 552kB 14.3MB/s
Collecting requests>=2.0.0 (from sphinx)
  Downloading https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl (57kB)
    100% |████████████████████████████████| 61kB 11.1MB/s
Collecting packaging (from sphinx)
  Downloading https://files.pythonhosted.org/packages/91/32/58bc30e646e55eab8b21abf89e353f59c0cc02c417e42929f4a9546e1b1d/packaging-19.0-py2.py3-none-any.whl
Collecting sphinxcontrib-websupport (from sphinx)
  Downloading https://files.pythonhosted.org/packages/52/69/3c2fbdc3702358c5b34ee25e387b24838597ef099761fc9a42c166796e8f/sphinxcontrib_websupport-1.1.0-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from Jinja2>=2.3->sphinx)
  Downloading https://files.pythonhosted.org/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Collecting pytz>=0a (from babel!=2.0,>=1.3->sphinx)
  Downloading https://files.pythonhosted.org/packages/61/28/1d3920e4d1d50b19bc5d24398a7cd85cc7b9a75a490570d5a30c57622d34/pytz-2018.9-py2.py3-none-any.whl (510kB)
    100% |████████████████████████████████| 512kB 12.2MB/s
Collecting idna<2.9,>=2.5 (from requests>=2.0.0->sphinx)
  Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 11.8MB/s
Collecting urllib3<1.25,>=1.21.1 (from requests>=2.0.0->sphinx)
  Downloading https://files.pythonhosted.org/packages/62/00/ee1d7de624db8ba7090d1226aebefab96a2c71cd5cfa7629d6ad3f61b79e/urllib3-1.24.1-py2.py3-none-any.whl (118kB)
    100% |████████████████████████████████| 122kB 12.9MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.0.0->sphinx)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 11.7MB/s
Collecting certifi>=2017.4.17 (from requests>=2.0.0->sphinx)
  Downloading https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl (158kB)
    100% |████████████████████████████████| 163kB 13.0MB/s
Collecting pyparsing>=2.0.2 (from packaging->sphinx)
  Downloading https://files.pythonhosted.org/packages/de/0a/001be530836743d8be6c2d85069f46fecf84ac6c18c7f5fb8125ee11d854/pyparsing-2.3.1-py2.py3-none-any.whl (61kB)
    100% |████████████████████████████████| 71kB 12.5MB/s
Installing collected packages: imagesize, Pygments, snowballstemmer, MarkupSafe, Jinja2, pytz, babel, six, alabaster, docutils, idna, urllib3, chardet, certifi, requests, pyparsing, packaging, sphinxcontrib-websupport, sphinx
Successfully installed Jinja2-2.10 MarkupSafe-1.1.1 Pygments-2.3.1 alabaster-0.7.12 babel-2.6.0 certifi-2019.3.9 chardet-3.0.4 docutils-0.14 idna-2.8 imagesize-1.1.0 packaging-19.0 pyparsing-2.3.1 pytz-2018.9 requests-2.21.0 six-1.12.0 snowballstemmer-1.2.1 sphinx-1.8.5 sphinxcontrib-websupport-1.1.0 urllib3-1.24.1
You are using pip version 18.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
```
## create project root directory

```shell:PowerShell
$ mkdir sphinx_doc
$ cd sphinx_doc
```

## create symbolic link for 'sphinx' command

```shell:PowerShell
$ sudo ln -s /opt/python3.6.8/bin/sphinx-apidoc /usr/local/bin/sphinx-apidoc
$ sudo ln -s /opt/python3.6.8/bin/sphinx-autogen /usr/local/bin/sphinx-autogen
$ sudo ln -s /opt/python3.6.8/bin/sphinx-build /usr/local/bin/sphinx-build
$ sudo ln -s /opt/python3.6.8/bin/sphinx-quickstart /usr/local/bin/sphinx-quickstart
```

## create template

```shell:PowerShell
$ sphinx-quickstart
```

then show terminal below, and enter answer your option.
if only [enter] key input, then select default option.

|question|answer|
|--------|------|
|Separate source and build directories (y/n) [n]|y|
|Name prefix for templates and static dir [_]||
|Project name|teruproject|
|Author name(s)|teruroom|
|Project release []|0.0.1|
|Project language [en]|ja|
|Source file suffix [.rst]||
|Name of your master document (without suffix) [index]||
|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]||
|Create Makefile? (y/n) [y]|y|
|Create Windows command file? (y/n) [y]|y|

```shell:PowerShell
Welcome to the Sphinx 1.8.5 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: teruproject
> Author name(s): teruroom
> Project release []: 0.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]: ja

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]:
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.
```
## show directory structure
+ install 'tree' command, if not installed.

```shell:PowerShell
$ sudo apt install tree
```

then display terminal below, you must input root password. 

```shell:PowerShell
[sudo] password for teruroom:
```
then show below.

```shell:PowerShell
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  tree
0 upgraded, 1 newly installed, 0 to remove and 153 not upgraded.
Need to get 40.7 kB of archives.
After this operation, 105 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/universe amd64 tree amd64 1.7.0-5 [40.7 kB]
Fetched 40.7 kB in 2s (23.9 kB/s)
Selecting previously unselected package tree.
(Reading database ... 41339 files and directories currently installed.)
Preparing to unpack .../tree_1.7.0-5_amd64.deb ...
Unpacking tree (1.7.0-5) ...
Setting up tree (1.7.0-5) ...
Processing triggers for man-db (2.8.3-2) ...
```

+ then show directory tree structure

```shell:PowerShell
$ tree
```

+ show below

```shell:PowerShell
.
├── Makefile
├── build
├── make.bat
└── source
    ├── _static
    ├── _templates
    ├── conf.py
    └── index.rst

4 directories, 4 files
```