Instalando Sphinx¶
Visão Geral¶
Sphinx is written in Python and supports Python 3.6+. It builds upon the shoulders of many third-party libraries such as Docutils and Jinja, which are installed when Sphinx is installed.
Linux¶
Debian/Ubuntu¶
Install either python3-sphinx
using apt-get:
$ apt-get install python3-sphinx
Se Python não estiver presente, este também será automaticamente instalado.
RHEL, CentOS¶
Instalar python-sphinx
usando yum:
$ yum install python-sphinx
Se Python não estiver presente, este também será automaticamente instalado.
Outras distribuições¶
Muitas distribuições Linux possuem Sphinx em seus repositórios. Normalmente o pacote tem o nome python3-sphinx
, python-sphinx
ou sphinx
. Preste atenção pois existem ao menos dois outros pacotes com sphinx
em seus nomes: uma ferramente de reconhecimento voz (CMU Sphinx) e outra mecanismo banco de dados texto completo (Sphinx search).
macOS¶
O Sphinx
pode ser instalado usando Homebrew, MacPorts ou como parte de uma distribuição do Python, como Anaconda.
Homebrew¶
$ brew install sphinx-doc
Para mais informações, consulte package overview.
MacPorts¶
Install either python3x-sphinx
using port:
$ sudo port install py38-sphinx
Para configurar os caminhos dos executáveis, use o comando port select
:
$ sudo port select --set python python38
$ sudo port select --set sphinx py38-sphinx
Para mais informações, consulte package overview.
Anaconda¶
$ conda install sphinx
Windows¶
Sphinx can be install using Chocolatey or installed manually.
Chocolatey¶
$ choco install sphinx
You would need to install Chocolatey before running this.
For more information, refer to the chocolatey page.
Other Methods¶
Most Windows users do not have Python installed by default, so we begin with the installation of Python itself. To check if you already have Python installed, open the Command Prompt (⊞Win-r and type cmd). Once the command prompt is open, type python --version and press Enter. If Python is installed, you will see the version of Python printed to the screen. If you do not have Python installed, refer to the Hitchhikers Guide to Python’s Python on Windows installation guides. You must install Python 3.
Quando Python estiver instalado, poderá instalar Sphinx usando pip. Consulte pip como instalar abaixo para mais informação.
Instalar a partir do PyPI¶
Os pacotes Sphinx
são publicados no Python Package Index. A ferramenta preferida para instalar pacotes do PyPI é pip. Esta ferramenta é fornecida com todas as versões modernas do Python.
Em Linux ou MacOS, abra seu terminal e execute o seguinte comando.
$ pip install -U sphinx
No Windows, você deve abrir o Prompt de Comando (⊞Win-r e digitar cmd) e executar o mesmo comando.
C:\> pip install -U sphinx
Após instalação, digitar sphinx-build --version Para saber se tudo funcionou bem, confirme o número da versão instalada do pacote Sphinx.
Instalação a partir de PyPI também permite instalar a última versão ainda em desenvolvimento. Geralmente não é necessário fazer isso, mas pode ser útil para confirmar se ainda há erro na última versão do release estábel. Para instalar use o flag --pre
.
$ pip install -U --pre sphinx
Docker¶
Docker images for Sphinx are published on the Docker Hub. There are two kind of images:
Former one is used for standard usage of Sphinx, and latter one is mainly used for PDF builds using LaTeX. Please choose one for your purpose.
Nota
sphinxdoc/sphinx-latexpdf contains TeXLive packages. So the image is very large (over 2GB!).
Dica
When using docker images, please use docker run
command to invoke sphinx
commands. For example, you can use following command to create a Sphinx
project:
$ docker run -it --rm -v /path/to/document:/docs sphinxdoc/sphinx sphinx-quickstart
And you can following command this to build HTML document:
$ docker run --rm -v /path/to/document:/docs sphinxdoc/sphinx make html
For more details, please read README file of docker images.
Instalar a partir dos fontes¶
Para instalar Sphinx diretamente dos fontes, clone um Git repository. Isso pode ser feito clonando o repositório e instalando a partir de um clone local, ou simplesmente instalando diretamente a partir do git.
$ git clone https://github.com/sphinx-doc/sphinx
$ cd sphinx
$ pip install .
$ pip install git+https://github.com/sphinx-doc/sphinx
Também pode baixar um snapshot do repo Git em formato tar.gz ou zip . Quando baixado e descompactado esses podem sem instalados com pip como acima.