title | summary |
---|---|
TiDB Documentation PDF Generation Tutorial |
Learn how to locally customize the PDF output of TiDB Documentation to meet the needs of specific scenarios. |
This tutorial provides a method to generate TiDB documentation in PDF format. With this method, you can flexibly sort or delete certain contents in TiDB Documentation locally, and customize the PDF output to meet the needs of specific scenarios.
The following preparation steps only need to be performed once when you generate a PDF file for the first time and can be skipped directly for future PDF generation.
Estimated time: 30 minutes.
The following steps take macOS or Windows as an example for Docker Desktop installation.
-
Install Docker Desktop.
-
Run the
docker --version
command in macOS Terminal or Windows PowerShell.If you see the Docker version information, the installation is successful.
-
Configure Docker resources.
-
Launch the Docker application and click the gear icon in the upper-right corner.
-
Click Resources and set Memory to
8.00 GB
.
-
-
Run the following command in macOS Terminal or Windows PowerShell to pull the Docker image used for building TiDB PDF documentation:
docker pull andelf/doc-build:0.1.9
Estimated time: 10 minutes.
TiDB English documentation repository: https://github.com/pingcap/docs; TiDB Chinese documentation repository: https://github.com/pingcap/docs-cn
The following steps take TiDB English documentation as an example to show how to clone the repository:
-
Go to the TiDB English documentation repository: https://github.com/pingcap/docs.
-
Click Fork in the upper-right corner, and wait for the Fork to complete.
-
Use either of the following methods to clone the TiDB documentation repository locally.
-
Method 1: Use GitHub Desktop client.
- Install and launch GitHub Desktop.
- In GitHub Desktop, click File > Clone Repository.
- Click the GitHub.com tab, select the repository you forked in Your Repositories, and then click Clone in the lower-right corner.
-
Method 2: Use the following Git commands.
cd $working_dir # Replace `$working_dir` with the directory where you want the repository to be placed. For example, `cd ~/Documents/GitHub` git clone [email protected]:$user/docs.git # Replace `$user` with your GitHub ID cd $working_dir/docs git remote add upstream [email protected]:pingcap/docs.git # Add upstream repository git remote -v
-
Estimated time: The following operations only take two minutes, but the PDF generation requires waiting for 0.5 to 1 hour.
-
Make sure that the files in your local TiDB documentation repository are of the latest version in the upstream GitHub repository.
-
Sort or delete the contents in TiDB Documentation according to your needs.
- Open the
TOC.md
file located in the root directory of your local repository. - Edit the
TOC.md
file. For example, you can remove titles and links of all unnecessary document chapters.
- Open the
-
Consolidate chapters from all documents into one Markdown file according to the
TOC.md
file.-
Start the Docker application.
-
Run the following command in macOS Terminal or Windows PowerShell to run the Docker image for PDF documentation building:
docker run -it -v ${doc-path}:/opt/data andelf/doc-build:0.1.9
In the command,
${doc-path}
is the local path of the documentation for PDF generation. For example, if the path is/Users/${username}/Documents/GitHub/docs
, the command is as follows:docker run -it -v /Users/${username}/Documents/GitHub/docs:/opt/data andelf/doc-build:0.1.9
After execution, if
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
is returned, you can ignore it. -
Go to the
opt/data
directory.cd /opt/data
-
Consolidate all Markdown document files into one
doc.md
file according toTOC.md
.python3 scripts/merge_by_toc.py
Expected output:
In the same folder as
TOC.md
, you will see a newly generateddoc.md
file.
-
-
Generate the PDF documentation:
bash scripts/generate_pdf.sh
Expected output:
The time required to generate the PDF file depends on the documentation size. For the complete TiDB documentation, it takes about 1 hour. After the generation is completed, you will see the newly generated PDF file
output.pdf
in the folder where the documentation is located.