-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resource: add tidb-pdf-generation-tutorial.md #16134
Merged
ti-chi-bot
merged 10 commits into
pingcap:master
from
shawn0915:br-shawnyan-trans-15946
Jan 26, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
730ab69
resource: add tidb-pdf-generation-tutorial.md
shawn0915 3ddb711
Update README.md
shawn0915 8c2d276
Update resources/tidb-pdf-generation-tutorial.md
shawn0915 5f9dded
Apply suggestions from code review
shawn0915 c574f49
Update tidb-pdf-generation-tutorial.md
shawn0915 842d5bd
remove unnecessary empty lines
qiancai 902b141
Update tidb-pdf-generation-tutorial.md
shawn0915 e24ed2a
Update wording and format
lilin90 729920d
Update tidb-pdf-generation-tutorial.md
shawn0915 ce7a07f
wording updates
qiancai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
--- | ||
title: TiDB Documentation PDF Generation Tutorial | ||
summary: Learn how to locally customize the PDF output of TiDB Documentation to meet the needs of specific scenarios. | ||
--- | ||
|
||
# TiDB Documentation PDF Generation Tutorial | ||
|
||
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. | ||
|
||
## Environment preparation | ||
|
||
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. | ||
|
||
### Preparation 1: Install and configure the Docker environment | ||
|
||
> Estimated time: 30 minutes. | ||
|
||
The following steps take macOS or Windows as an example for Docker Desktop installation. | ||
|
||
1. Install [Docker Desktop](https://docs.docker.com/get-docker/). | ||
|
||
2. Run the `docker --version` command in macOS Terminal or Windows PowerShell. | ||
|
||
If you see the Docker version information, the installation is successful. | ||
|
||
3. Configure Docker resources. | ||
|
||
1. Launch the Docker application and click the gear icon in the upper-right corner. | ||
|
||
2. Click **Resources** and set **Memory** to `8.00 GB`. | ||
|
||
4. Run the following command in macOS Terminal or Windows PowerShell to pull the Docker image used for building TiDB PDF documentation: | ||
|
||
```bash | ||
docker pull andelf/doc-build:0.1.9 | ||
``` | ||
|
||
### Preparation 2: Clone the TiDB documentation repository to your local disk | ||
|
||
> 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: | ||
|
||
1. Go to the TiDB English documentation repository: <https://github.com/pingcap/docs>. | ||
|
||
2. Click [**Fork**](https://github.com/pingcap/docs/fork) in the upper-right corner, and wait for the Fork to complete. | ||
|
||
3. Use either of the following methods to clone the TiDB documentation repository locally. | ||
|
||
- Method 1: Use GitHub Desktop client. | ||
|
||
1. Install and launch [GitHub Desktop](https://desktop.github.com/). | ||
2. In GitHub Desktop, click **File** > **Clone Repository**. | ||
3. 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. | ||
|
||
```shell | ||
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 | ||
``` | ||
|
||
## Steps | ||
|
||
> Estimated time: The following operations only take two minutes, but the PDF generation requires waiting for 0.5 to 1 hour. | ||
|
||
1. Make sure that the files in your local TiDB documentation repository are of the latest version in the upstream GitHub repository. | ||
|
||
2. Sort or delete the contents in TiDB Documentation according to your needs. | ||
|
||
1. Open the `TOC.md` file located in the root directory of your local repository. | ||
2. Edit the `TOC.md` file. For example, you can remove titles and links of all unnecessary document chapters. | ||
|
||
3. Consolidate chapters from all documents into one Markdown file according to the `TOC.md` file. | ||
|
||
1. Start the Docker application. | ||
2. Run the following command in macOS Terminal or Windows PowerShell to run the Docker image for PDF documentation building: | ||
|
||
```bash | ||
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: | ||
|
||
```bash | ||
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. | ||
|
||
3. Go to the `opt/data` directory. | ||
|
||
```bash | ||
cd /opt/data | ||
``` | ||
|
||
4. Consolidate all Markdown document files into one `doc.md` file according to `TOC.md`. | ||
|
||
```bash | ||
python3 scripts/merge_by_toc.py | ||
``` | ||
|
||
**Expected output:** | ||
|
||
In the same folder as `TOC.md`, you will see a newly generated `doc.md` file. | ||
|
||
4. Generate the PDF documentation: | ||
|
||
```bash | ||
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. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice to have a
Makefile
to do the generation ofdoc.md
and PDF.Then
make output.pdf
would runmerge_by_toc.py
if there is nodoc.md
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can save one step 👍