Skip to content

Commit

Permalink
feat(framework): 新增 Vuepress 演示文档能力
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyi2 committed Aug 2, 2020
1 parent 7f3487a commit 66e38d1
Show file tree
Hide file tree
Showing 27 changed files with 17,356 additions and 8,118 deletions.
6 changes: 5 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ commitlint.config.js
jest.config.js

# build
dist
dist

# docs
docs
docs/.vuepress
4 changes: 4 additions & 0 deletions .markdownlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"MD013": false,
"MD033": false
}
22 changes: 14 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# 1.0.0 (2020-07-20)
# 1.0.0 (2020-08-02)


### Features

- **framework:** 新增 ESLint 代码校验能力 ([dca67d4](https://github.com/ziyi2/algorithms/commit/dca67d4da73259636c612e677d7d406903d7abd8))
- **framework:** 新增 Git Commit Message 规范提交能力 ([d04e259](https://github.com/ziyi2/algorithms/commit/d04e25977a7041b5e2d9d801934d554ab6815c42))
- **framework:** 新增 Jest 单元测试能力 ([6f086f2](https://github.com/ziyi2/algorithms/commit/6f086f27ac16be565f2cd4f49a310ad277571e08))
- **framework:** 新增 Lint Staged 上传校验能力 ([b440186](https://github.com/ziyi2/algorithms/commit/b440186dbd8ac4052fe3715882c8fe86c495a4ae))
- **framework:** 新增 npm scripts hook 能力 ([93e597a](https://github.com/ziyi2/algorithms/commit/93e597a1cf9bc3d9ea6ba4c1e5ba18c4cb4575fe))
- **framework:** 新增 TypeScript 编译能力 ([ebecee9](https://github.com/ziyi2/algorithms/commit/ebecee96551f8ed49a7b48c61be3da6b79ae3974))
- 项目初始化 ([afaa458](https://github.com/ziyi2/algorithms/commit/afaa4583009ea5ac3ead2f3bfc5c61103ce8533c))
* **framework:** 新增 ESLint 代码校验能力 ([dca67d4](https://github.com/ziyi2/algorithms/commit/dca67d4da73259636c612e677d7d406903d7abd8))
* **framework:** 新增 Git Commit Message 规范提交能力 ([d04e259](https://github.com/ziyi2/algorithms/commit/d04e25977a7041b5e2d9d801934d554ab6815c42))
* **framework:** 新增 Github Actions 能力 ([f0cc962](https://github.com/ziyi2/algorithms/commit/f0cc9627a59480fd68c4f60fe6261b92122ca216))
* **framework:** 新增 Jest 单元测试能力 ([6f086f2](https://github.com/ziyi2/algorithms/commit/6f086f27ac16be565f2cd4f49a310ad277571e08))
* **framework:** 新增 Lint Staged 上传校验能力 ([b440186](https://github.com/ziyi2/algorithms/commit/b440186dbd8ac4052fe3715882c8fe86c495a4ae))
* **framework:** 新增 npm scripts hook 能力 ([93e597a](https://github.com/ziyi2/algorithms/commit/93e597a1cf9bc3d9ea6ba4c1e5ba18c4cb4575fe))
* **framework:** 新增 Prettier 自动格式化能力 ([7f3487a](https://github.com/ziyi2/algorithms/commit/7f3487a65f3325a9964d1ee462941f138f299f42))
* **framework:** 新增 TypeScript 编译能力 ([ebecee9](https://github.com/ziyi2/algorithms/commit/ebecee96551f8ed49a7b48c61be3da6b79ae3974))
* 项目初始化 ([afaa458](https://github.com/ziyi2/algorithms/commit/afaa4583009ea5ac3ead2f3bfc5c61103ce8533c))



278 changes: 278 additions & 0 deletions README.md

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions docs/.vuepress/components/Collapse.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<template>
<section class="collapse">
<section class="collapse-header" :class="{ collapse }">
<div class="collapse-header-title">{{ title }}</div>
<div class="collapse-header-action" @click="handlerCollapse">{{ action }}</div>
</section>
<transition name="fade">
<section ref="content" class="collapse-content" v-show="!collapse"></section>
</transition>
</section>
</template>

<script>
const COLLAPSE_TEXT = {
ON: "收缩",
OFF: "展开",
};
export default {
name: "Collapse",
data() {
return {
collapse: true,
action: COLLAPSE_TEXT.OFF,
};
},
props: {
title: String,
desc: String,
},
methods: {
handlerCollapse() {
this.collapse = !this.collapse;
this.action = this.collapse ? COLLAPSE_TEXT.OFF : COLLAPSE_TEXT.ON;
},
},
mounted() {
const $collapse = this.$el.nextSibling && this.$el.nextSibling.nextSibling;
$collapse && this.$refs.content.appendChild($collapse);
},
};
</script>

<style>
.collapse {
position: relative;
}
.collapse-header {
border: 1px solid #ebedf0;
border-radius: 4px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
padding: 16px;
display: flex;
height: 20px;
line-height: 1;
}
.collapse-header.collapse {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
.collapse-header-title {
color: #777;
background: #fff;
flex: 1;
}
.collapse-header-action {
color: #41c4ff;
cursor: pointer;
user-select: none;
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.2s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
opacity: 0;
}
.language-javascript,
.language-javascript {
display: block !important;
}
.collapse-content .language-javascript,
.collapse-content .language-typescript {
margin: 0 !important;
border-radius: 0;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
}
</style>
64 changes: 64 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const packageJson = require("../../package.json");
const sidebar = require("./config/sidebar.js");
const nav = require("./config/nav.js");
const path = require("path");

module.exports = {
title: packageJson.name,
description: packageJson.description,
base: "/algorithms/",
port: "8080",

themeConfig: {
nav,
sidebar,
},

plugins: [
"vuepress-plugin-cat",
[
"mathjax",
{
target: "svg",
macros: {
"*": "\\times",
},
},
],
[
"vuepress-plugin-typescript",
{
tsLoaderOptions: {
// ts-loader 的所有配置项
},
},
],
],

chainWebpack: (config) => {
config.resolve.alias.set("image", path.resolve(__dirname, "public"));
config.resolve.alias.set(
"algorithms-utils",
path.resolve(__dirname, "../../src")
);
config.resolve.alias.set("@", path.resolve(__dirname, "../../src"));

// config.module
// .rule("eslint")
// .pre()
// .exclude.add([/node_modules/])
// .add(path.resolve(__dirname, "../../src"))
// .end()
// .test(/\.ts$/)
// .use("eslint-loader")
// .loader("eslint-loader")
// .options({
// // extensions: [".ts"],
// // cache: true,
// emitWarning: true,
// emitError: true,
// // formatter: "stylish",
// formatter: require("eslint/lib/cli-engine/formatters/stylish"),
// });
},
};
47 changes: 47 additions & 0 deletions docs/.vuepress/config/nav.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module.exports = [
{
text: "指南",
link: "/guide/introduction",
},
{
text: "API",
link: "/api/test",
},
{
text: "文档",
items: [
{
text: "基础知识",
link: "/basic/insertion",
},
{
text: "排序和顺序统计量",
link: "/sort",
},
{
text: "数据结构",
link: "/data-structure",
},
{
text: "高级设计和分析技术",
link: "",
},
{
text: "高级数据结构",
link: "",
},
{
text: "图算法",
link: "",
},
{
text: "算法问题选编",
link: "",
},
],
},
{
text: "GitHub",
link: "https://github.com/ziyi2/algorithms",
},
];
46 changes: 46 additions & 0 deletions docs/.vuepress/config/sidebar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = {
"/guide": [
{
title: "指南",
collapsable: false,
children: [
"/guide/introduction",
"/guide/chapter",
"/guide/install",
"/guide/repo",
"/guide/pull",
],
},
],
"/api": [
{
title: "API文档",
collapsable: false,
children: ["/api/test"],
},
],
"/basic": [
{
title: "算法基础",
collapsable: false,
children: [
"/basic/insertion",
"/basic/insertion-exercise",
"/basic/analyse",
"/basic/analyse-exercise",
"/basic/merge",
"/basic/merge-exercise",
],
},
{
title: "函数的增长",
collapsable: false,
children: [
"/basic/symbol",
"/basic/symbol-exercise",
"/basic/common",
"/basic/common-exercise",
],
},
],
};
1 change: 1 addition & 0 deletions docs/.vuepress/enhanceApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./style/reset.css";
5 changes: 5 additions & 0 deletions docs/.vuepress/style/reset.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
div.custom-block.danger {
background-color: #ffebeb;
border-color: #cc000075;
color: black;
}
16 changes: 16 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
home: true
# heroImage: /hero.png
heroText: algorithms-utils
tagline: 算法与 TypeScript 实现
actionText: 开始学习
actionLink: /guide/introduction
features:
- title: 精简理论
details: 精简《算法导论》的内容,帮助自己更容易学习算法理论知识。
- title: 习题练习
details: 解答《算法导论》的习题,帮助自己更好的实践算法理论知识。
- title: 面题精选
details: 搜集常见的面试题目,提升自己的算法编程能力以及面试通过率。
footer: MIT Licensed | Copyright © 2020-present 子弈
---
30 changes: 30 additions & 0 deletions docs/api/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Test vuepress

::: danger 测试 Vuepress
引入 greet.ts 并进行调用测试。
:::

<template>
<collapse title="查看答案">{{msg}}</collapse>
</template>

```typescript
import greet from "algorithms-utils/greet";
greet("hello");
```

<template>
<div>{{msg}}</div>
</template>

<script lang="ts">
import greet from 'algorithms-utils/greet'
const msg = greet('ziyi')
export default {
data() {
return {
msg
}
},
}
</script>
21 changes: 21 additions & 0 deletions docs/guide/chapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 章节目录

文档的章节设计将按照《算法导论》的章节内容进行设计,包括第一部分**基础知识**、第二部分**排序和顺序统计量**、第三部分**数据结构**、第四部分**高级设计和分析技术**、第五部分**高级数据结构**、第六部分**图算法**以及第七部分**算法问题选编**,同时在此过程中可能会将**数学基础知识**穿插到各个需要解释的章节中。

## 基础知识

第一章:算法基础

- [插入排序](/algorithms/basic/insertion)
- [插入排序习题](/algorithms/basic/insertion-exercise)
- [分析算法](/algorithms/basic/analyse)
- [分析算法习题](/algorithms/basic/analyse-exercise)
- [归并排序](/algorithms/basic/merge)
- [归并排序习题](/algorithms/basic/merge-exercise)

第二章:函数的增长

- [渐进标记](/algorithms/basic/symbol)
- [渐进标记习题](/algorithms/basic/symbol-exercise)
- [常用函数](/algorithms/basic/common)
- [常用函数习题](/algorithms/basic/common-exercise)
Loading

0 comments on commit 66e38d1

Please sign in to comment.