Book

PaddlePaddle’s documentation includes both Chinese and English versions. The documentation is built using the cmake command to drive the sphinx compiler. The PaddlePaddle.org tool helps us to implement this compilation process and provides better preview results.

PaddlePaddle’s documentation is built in two ways: using the PaddlePaddle.org tool and without using it. Both methods have their own advantages. The former facilitates previewing, while the latter facilitates debugging by the developer. We could choose to build the documentation with Docker or without it in each of the above ways.

This is the recommended method to build documentation, because it can automatically compile the documentation and preview the documentation directly in a web page. Note that, although you can preview the documentation in other ways, its style may not be consistent with the official website. Compiling with the PaddlePaddle.org tool produces a preview that will be consistent with the official website documentation style.

The PaddlePaddle.org tool can be used with Docker and Docker needs to be installed first. Please refer to Docker’s official website on how to install Docker. After installing Docker, you may use the following commands to activate the tool

Note: PaddlePaddle.org will read the content repos specified in the -v (volume) flag of the docker run commands
Use a web browser and navigate to http://localhost:8000. Click the buttons to compile the documentation.
The compiled documentations will be stored in <paddlepaddle working directory>/.ppo_workspace/content

If you don’t wish to use Docker, you can also activate the tool through Django. Use the following the commands to set up

Specify the PaddlePaddle working directory for the environment variable CONTENT_DIR so that the tool could find where the working directory is.

Use a web browser and navigate to http://localhost:8000. Click the buttons to compile the documentation
The compiled documentations will be stored in <paddlepaddle working directory>/.ppo_workspace/content

Please click here for more information about the PaddlePaddle.org tool.

Note: The above commands maps the current directory (source root directory) to the /paddle directory in the container.

After compiling, there should be two generated directories: doc/v2 and doc/fluid, where three subdirectories cn/html/, en/html and api/en/html are generated. Please enter these directories respectively and execute the following commands:

python -m SimpleHTTPServer 8088

Use a web browser and navigate to http://localhost:8000, you could see the compiled v2 ‘s and fluid ‘s Chinese/English documents page and English APIs page.

If you do not wish to use Docker, you can also use the following commands to directly build the PaddlePaddle documentation.

git clone https://github.com/PaddlePaddle/Paddle.git
cd Paddle
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_GPU=OFF -DWITH_MKL=OFF -DWITH_DOC=ON
# If you only need to build documents, use the following commands
make -j $processors paddle_docs
# If you only need to build APIs, use the following commands
make -j $processors paddle_apis

$processors indicates that as many processes as the CPU cores are started to compile in parallel. It should be set according to the number of CPU cores of your machine.

After compiling, there also should be two generated directories: doc/v2 and doc/fluid . If you chose to build documents, two subdirectories cn/html/ and en/html will be generated in both two directories. If you chose to build APIs，a subdirectory api/en/html will be generated. Please enter these directories respectively and execute the following commands:

python -m SimpleHTTPServer 8088

Use a web browser and navigate to http://localhost:8000, you could see the compiled v2 ‘s and fluid ‘s Chinese/English documents page and English APIs page. The following figure is an example of the built v2 ‘s English documents home page. Note that due to the sphinx’s original theme used in the example, the style of the page is not consistent with the official website, but this does not affect the developer’s debugging.