Skip to content

Commit d8a2617

Browse files
committed
add base docs & online ebook
- mcpp-community/OpenOrg#1 - project docs / book - ebook / github pages Signed-off-by: sunrisepeak <speakshen@163.com>
1 parent 02a1379 commit d8a2617

8 files changed

Lines changed: 471 additions & 19 deletions

File tree

.github/workflows/online-ebook.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Sample workflow for building and deploying a mdBook site to GitHub Pages
2+
#
3+
# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html
4+
#
5+
name: Deploy Online EBook site to Pages
6+
7+
on:
8+
# Runs on pushes targeting the default branch
9+
push:
10+
branches: ["main"]
11+
paths:
12+
- "book/src/**"
13+
14+
# Allows you to run this workflow manually from the Actions tab
15+
workflow_dispatch:
16+
17+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
18+
permissions:
19+
contents: read
20+
pages: write
21+
id-token: write
22+
23+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
24+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
25+
concurrency:
26+
group: "pages"
27+
cancel-in-progress: false
28+
29+
jobs:
30+
# Build job
31+
build:
32+
runs-on: ubuntu-latest
33+
34+
defaults:
35+
run:
36+
working-directory: book
37+
38+
env:
39+
MDBOOK_VERSION: 0.4.43
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
- name: Install mdBook by Xlings
44+
run: |
45+
curl -fsSL https://d2learn.org/xlings-install.sh | bash
46+
xlings install mdbook@${MDBOOK_VERSION} --global -y
47+
- name: Setup Pages
48+
id: pages
49+
uses: actions/configure-pages@v4
50+
- name: Build with mdBook
51+
run: |
52+
export PATH=/home/xlings/.xlings_data/bin:$PATH
53+
mdbook build
54+
- name: Upload artifact
55+
uses: actions/upload-pages-artifact@v3
56+
with:
57+
path: ./book/book
58+
59+
# Deployment job
60+
deploy:
61+
environment:
62+
name: github-pages
63+
url: ${{ steps.deployment.outputs.page_url }}
64+
runs-on: ubuntu-latest
65+
needs: build
66+
steps:
67+
- name: Deploy to GitHub Pages
68+
id: deployment
69+
uses: actions/deploy-pages@v4

README.md

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
11
# d2x-project-template
22

3-
d2x项目模板
4-
5-
## 目录结构
6-
7-
```cpp
8-
├── book // 项目文档/书籍
9-
├── d2x // d2x工具依赖
10-
│ ├── buildtools
11-
│ │ ├── cmake
12-
│ │ └── xmake
13-
| ├── cpp
14-
│ └── mcpp
15-
└── dslings // 项目练习代码
16-
```
3+
> d2x教程类项目模板 - `Book + Video + Code + X`
4+
5+
[![d2x](https://img.shields.io/badge/d2x-ok-green.svg)](https://github.com/d2learn/d2x)
6+
[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE-CODE)
7+
8+
该项目提供了一个, 可以被[d2x](https://github.com/d2learn/d2x)工具识别和加载的**交互式**教程类项目结构. 开发者和教程制作者, 可以基于这个模板来设计开发自己的交互式教程项目
9+
10+
## 功能特色
11+
12+
- 提供了基础的 `Book + Video + Code + X` 结构
13+
- d2x工具可以直接识别和加载
14+
- 提供了项目依赖描述, 支持一键配置环境
15+
16+
## 快速开始
17+
18+
**方式一: 本地安装使用**
19+
20+
```
21+
xlings install d2x@latest
22+
d2x create d2hello
23+
cd d2hello
24+
d2x book
25+
```
26+
27+
**方式二: 直接使用项目模板**
28+
29+
通过 [Use this template](https://github.com/new?template_name=d2x-project-template&template_owner=d2learn) 创建新的仓库
30+
31+
> 注: 工具安装及环境配置文档 -> [详情](https://d2learn.github.io/d2x-project-template)
32+
33+
## 具体项目案例
34+
35+
| 项目 | 简介 | 备注 |
36+
| --- | --- | --- |
37+
| [d2mcpp](https://github.com/mcpp-community/d2mcpp) | 现代C++核心特性入门教程 | |
38+
39+
## 其他
40+
41+
- [d2x工具](https://github.com/d2learn/d2x)
42+
- [论坛交流和反馈](https://forum.d2learn.org)

book/book.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ language = "en"
44
multilingual = false
55
src = "src"
66
title = "D2X Project Template | D2X项目模板"
7+
8+
[output.html]
9+
git-repository-url = "https://github.com/d2learn/d2x-project-template"

book/src/SUMMARY.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Summary
22

33
- [简介](./chapter_0.md)
4-
- [环境配置](./chapter_1.md)
5-
- [使用模板](./chapter_2.md)
4+
- [工具安装与环境配置](./chapter_1.md)
5+
- [配置并添加内容](./chapter_2.md)
6+
- [等待你的扩展](./chapter_2.md)

book/src/chapter_0.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1-
# 简介
1+
# d2x-project-template 简介
22

3+
> d2x教程类项目模板 - `Book + Video + Code + X`
4+
5+
[![d2x](https://img.shields.io/badge/d2x-ok-green.svg)](https://github.com/d2learn/d2x)
6+
[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE-CODE)
7+
8+
该项目提供了一个, 可以被[d2x](https://github.com/d2learn/d2x)工具识别和加载的**交互式**教程类项目结构. 开发者和教程制作者, 可以基于这个模板来设计开发自己的交互式教程项目
9+
10+
## 功能特色
11+
12+
- 提供了基础的 `Book + Video + Code + X` 结构
13+
- d2x工具可以直接识别和加载
14+
- 提供了项目依赖描述, 支持一键配置环境
15+
16+
## 快速开始
17+
18+
**方式一: 本地安装使用**
19+
20+
```
21+
xlings install d2x@latest
22+
d2x create d2hello
23+
cd d2hello
24+
d2x book
25+
```
26+
27+
**方式二: 直接使用项目模板**
28+
29+
通过 [Use this template](https://github.com/new?template_name=d2x-project-template&template_owner=d2learn) 创建新的仓库
30+
31+
> 注: 工具安装及环境配置文档 -> [详情](https://d2learn.github.io/d2x-project-template)
32+
33+
## 具体项目案例
34+
35+
| 项目 | 简介 | 备注 |
36+
| --- | --- | --- |
37+
| [d2mcpp](https://github.com/mcpp-community/d2mcpp) | 现代C++核心特性入门教程 | |
38+
39+
## 其他
40+
41+
- [d2x工具](https://github.com/d2learn/d2x)
42+
- [论坛交流和反馈](https://forum.d2learn.org)

book/src/chapter_1.md

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,72 @@
1-
# 环境配置
1+
# 工具安装与环境配置
22

3+
本章节介绍如果安装d2x工具并创建模板项目, 以及基础的环境配置
4+
5+
## 一、安装d2x工具
6+
7+
### 方法1: 通过xlings包管理器安装 (推荐)
8+
9+
[xlings](https://xlings.d2learn.org)开源包管理器, 可以解决不同环境依赖不一致的问题
10+
11+
<details>
12+
<summary>点击查看xlings安装命令</summary>
13+
14+
---
15+
16+
#### Linux/MacOS
17+
18+
```bash
19+
curl -fsSL https://d2learn.org/xlings-install.sh | bash
20+
```
21+
22+
#### Windows - PowerShell
23+
24+
```bash
25+
irm https://d2learn.org/xlings-install.ps1.txt | iex
26+
```
27+
28+
> tips: xlings -> [details](https://xlings.d2learn.org)
29+
30+
---
31+
32+
</details>
33+
34+
```
35+
xlings install d2x
36+
```
37+
38+
### 方法2: 从源码进行构建
39+
40+
TODO...
41+
42+
## 二、创建项目 & 测试
43+
44+
### 创建项目
45+
46+
通过`d2x create xxx`命令创建一个新项目
47+
48+
```
49+
d2x create d2hello
50+
```
51+
52+
命令运行后会生成一个叫`d2hello`的目录, 进入/打开这个目录就能看到项目的基础结构
53+
54+
## 测试
55+
56+
进入新创建项目的根目录, 运行命令进行测试完整性
57+
58+
**查看文档命令测试**
59+
60+
运行下面命令后会在浏览器打开新项目的文档/书籍
61+
62+
```
63+
d2x book
64+
```
65+
66+
**代码自动检测功能测试**
67+
68+
运行下面的checker命令, 可以看到控制台进入实时代码检测模式, 修改文件代码, 控制台会自动更新
69+
70+
```
71+
d2x checker
72+
```

0 commit comments

Comments
 (0)