Skip to content

Commit b3d1d19

Browse files
SunrisepeakCopilot
andauthored
book: add multi language support and adapt d2x tool (#13)
* book: add multi language support and adapt d2x tool - #12 - mcpp-community/OpenOrg#1 - add en dir for English version - add build.sh for online ebook Signed-off-by: sunrisepeak <speakshen@163.com> * add readme zh + en * Update book/src/setup.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update book/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * update build.sh --------- Signed-off-by: sunrisepeak <speakshen@163.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 06fa195 commit b3d1d19

19 files changed

Lines changed: 747 additions & 403 deletions

.d2x.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"buildtools": "xmake d2x-buildtools",
3-
"lang": "zh",
3+
"lang": "en",
44
"llm": {
55
"api_key": "",
66
"api_url": "https://api.deepseek.com/v1",

.github/workflows/online-ebook.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,13 @@ jobs:
5050
# with:
5151
# mdbook-version: '0.4.43'
5252

53-
- run: mdbook build
54-
5553
- name: Setup Pages
5654
id: pages
5755
uses: actions/configure-pages@v4
5856
- name: Build with mdBook
5957
run: |
6058
export PATH=/home/xlings/.xlings_data/bin:$PATH
61-
mdbook build
59+
./build.sh
6260
- name: Upload artifact
6361
uses: actions/upload-pages-artifact@v3
6462
with:

README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# D2MySTL
22

3-
> 从零实现一个迷你STL库
3+
> Implement a mini STL library from scratch
44
55
[![d2x](https://img.shields.io/badge/d2x-ok-green.svg)](https://github.com/d2learn/d2x)
6-
[![online-ebook](https://img.shields.io/badge/online-ebook-orange.svg)](https://github.com/d2learn/d2x)
6+
[![Online-ebook](https://img.shields.io/badge/online-ebook-orange.svg)](https://github.com/d2learn/d2x)
77
[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE-CODE)
88

9-
| [d2x工具](https://github.com/d2learn/d2x) - [文档](https://mcpp-community.github.io/d2mystl) - [论坛](https://mcpp.d2learn.org/forum) |
9+
| [中文](README.zh.md) - [English](README.md) |
1010
| --- |
11+
| [d2x Tool](https://github.com/d2learn/d2x) - [Docs](https://mcpp-community.github.io/d2mystl) - [Forum](https://mcpp.d2learn.org/forum) |
1112

12-
## 快速开始
13+
## Quick Start
1314

14-
### 方式一: d2x自动代码检测
15+
### 1: d2x automatic code detection
1516

1617
<details>
17-
<summary>点击查看xlings安装命令</summary>
18+
<summary>Click to view the xlings installation command</summary>
1819

1920
---
2021

@@ -36,45 +37,45 @@ irm https://d2learn.org/xlings-install.ps1.txt | iex
3637

3738
</details>
3839

39-
**获取项目**
40+
**Obtain the project**
4041

4142
```
4243
d2x install d2mystl
4344
```
4445

45-
**进入练习模式**
46+
**Enter practice mode**
4647

4748
```
4849
d2x checker
4950
```
5051

51-
### 方式二: 动手运行验证
52+
### 2: Hands-on Verification
5253

53-
**获取项目**
54+
**Obtain the project**
5455

5556
```
5657
git clone https://github.com/mcpp-community/d2mystl.git
5758
```
5859

59-
**动手运行测试代码**
60+
**Run the test code manually**
6061

6162
```
6263
xmake run chapter0_tests
6364
```
6465

65-
> 注: 测试名格式`chapter[x]_tests`
66+
> Note: The test name format is `chapter[x]_tests`
6667
67-
## 前置教程
68+
## Pre-requisite Tutorials
6869

69-
如果感觉该教程上手有点难度, 可以先学习下面的教程了解现代C++基础和核心语法特性
70+
If you find this tutorial a bit challenging to get started with, you can first learn the following tutorial to understand the basics and core syntax features of modern C++.
7071

71-
| 项目 | 简介 | 备注 |
72+
| Project | Description | Note |
7273
| --- | --- | --- |
73-
| [mcpp-start](https://github.com/mcpp-community/mcpp-start) | 现代C++启动! - `import std` | 入门-0 |
74-
| [d2mcpp](https://github.com/mcpp-community/d2mcpp) | 现代C++核心特性入门教程 | 入门-1 |
74+
| [mcpp-start](https://github.com/mcpp-community/mcpp-start) | Modern C++, Go! - `import std` | Beginner-0 |
75+
| [d2mcpp](https://github.com/mcpp-community/d2mcpp) | Introduction to Modern C++ Core Features | Beginner-1 |
7576

76-
## 其他
77+
## Other
7778

78-
- [d2x工具](https://github.com/d2learn/d2x)
79-
- [论坛交流和反馈](https://mcpp.d2learn.org/forum)
80-
- `交流群`: 1067245099
79+
- [d2x Tool](https://github.com/d2learn/d2x)
80+
- [Forum discussion and feedback](https://mcpp.d2learn.org/forum)
81+
- `Communication group`: 1067245099

README.zh.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# D2MySTL
2+
3+
> 从零实现一个迷你STL库
4+
5+
[![d2x](https://img.shields.io/badge/d2x-ok-green.svg)](https://github.com/d2learn/d2x)
6+
[![online-ebook](https://img.shields.io/badge/online-ebook-orange.svg)](https://github.com/d2learn/d2x)
7+
[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE-CODE)
8+
9+
| [中文](README.zh.md) - [English](README.md) |
10+
| --- |
11+
| [d2x工具](https://github.com/d2learn/d2x) - [文档](https://mcpp-community.github.io/d2mystl) - [论坛](https://mcpp.d2learn.org/forum) |
12+
13+
## 快速开始
14+
15+
### 方式一: d2x自动代码检测
16+
17+
<details>
18+
<summary>点击查看xlings安装命令</summary>
19+
20+
---
21+
22+
#### Linux/MacOS
23+
24+
```bash
25+
curl -fsSL https://d2learn.org/xlings-install.sh | bash
26+
```
27+
28+
#### Windows - PowerShell
29+
30+
```bash
31+
irm https://d2learn.org/xlings-install.ps1.txt | iex
32+
```
33+
34+
> tips: xlings -> [details](https://xlings.d2learn.org)
35+
36+
---
37+
38+
</details>
39+
40+
**获取项目**
41+
42+
```
43+
d2x install d2mystl
44+
```
45+
46+
**进入练习模式**
47+
48+
```
49+
d2x checker
50+
```
51+
52+
### 方式二: 动手运行验证
53+
54+
**获取项目**
55+
56+
```
57+
git clone https://github.com/mcpp-community/d2mystl.git
58+
```
59+
60+
**动手运行测试代码**
61+
62+
```
63+
xmake run chapter0_tests
64+
```
65+
66+
> 注: 测试名格式`chapter[x]_tests`
67+
68+
## 前置教程
69+
70+
如果感觉该教程上手有点难度, 可以先学习下面的教程了解现代C++基础和核心语法特性
71+
72+
| 项目 | 简介 | 备注 |
73+
| --- | --- | --- |
74+
| [mcpp-start](https://github.com/mcpp-community/mcpp-start) | 现代C++启动! - `import std` | 入门-0 |
75+
| [d2mcpp](https://github.com/mcpp-community/d2mcpp) | 现代C++核心特性入门教程 | 入门-1 |
76+
77+
## 其他
78+
79+
- [d2x工具](https://github.com/d2learn/d2x)
80+
- [论坛交流和反馈](https://mcpp.d2learn.org/forum)
81+
- `交流群`: 1067245099

book/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 书籍/文档
2+
3+
## 本地查看
4+
5+
> 项目根目录运行下面命令, 将会在浏览器打开项目书籍
6+
7+
```
8+
d2x book
9+
```
10+
11+
注: `.d2x.json`中可以通过`lang`配置中文(zh)或英文(en)
12+
13+
## 在线查看
14+
15+
- https://mcpp-community.github.io/d2mystl

book/book.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
[book]
22
authors = ["mcpp-community"]
3-
language = "en"
3+
language = "zh"
44
multilingual = false
55
src = "src"
66
title = "D2MySTL | A Mini STL Tutorial from Scratch"
77

8+
[build]
9+
build-dir = "book"
10+
811
[output.html]
912
git-repository-url = "https://github.com/mcpp-community/d2mystl"

book/build.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# script dir
4+
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
5+
6+
echo "[Top] - Building Chinese book..."
7+
cd "$SCRIPT_DIR"
8+
mdbook build
9+
10+
echo "[Sub - 1] - Building English book..."
11+
cd "$SCRIPT_DIR"
12+
cd en && mdbook build
13+
14+
echo "[imgs] - copy imgs to output directory..."
15+
cd "$SCRIPT_DIR"
16+
cp -r imgs book/
17+
18+
echo "Build completed."
19+
20+
#python -m http.server --directory book

book/en/book.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[book]
2+
authors = ["mcpp-community"]
3+
language = "en"
4+
multilingual = false
5+
src = "src"
6+
title = "D2MySTL | A Mini STL Tutorial from Scratch"
7+
8+
[build]
9+
build-dir = "../book/en"
10+
11+
[output.html]
12+
git-repository-url = "https://github.com/mcpp-community/d2mystl"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<div align=right>
2+
3+
🌎 [中文] | [English]
4+
</div>
5+
6+
[中文]: ../index.html
7+
[English]: ./index.html
8+
19
# D2MySTL
210

311
> Implement a mini STL library from scratch

book/en/src/SUMMARY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Summary
2+
3+
- [README](./README_en.md)
4+
- [Tools/Environment Setup](./setup.md)
5+
6+
# Main Text
7+
8+
- [Global Module and Meta Information](./chapter0.md)
9+
- [Array Module Implementation](./chapter1.md)

0 commit comments

Comments
 (0)