Skip to content

Commit 3bef45b

Browse files
committed
chore: apply our format to the whole code base
1 parent 5591849 commit 3bef45b

20 files changed

+477
-445
lines changed

.github/dependabot.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
version: 2
77
updates:
88
- package-ecosystem: npm # See documentation for possible values
9-
directory: "/" # Location of package manifests
9+
directory: '/' # Location of package manifests
1010
open-pull-requests-limit: 10
1111
schedule:
12-
interval: "weekly"
13-
- package-ecosystem: "github-actions"
14-
directory: "/"
12+
interval: 'weekly'
13+
- package-ecosystem: 'github-actions'
14+
directory: '/'
1515
open-pull-requests-limit: 10
1616
schedule:
1717
interval: monthly

.gitpod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ ports:
77
onOpen: ignore
88
vscode:
99
extensions:
10-
- [email protected]:xX39oruAJ5UQzTNVRdbBaQ==
10+
- [email protected]:xX39oruAJ5UQzTNVRdbBaQ==

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ Move to [awesome-docsify](https://github.com/docsifyjs/awesome-docsify#showcase)
6262

6363
## Similar projects
6464

65-
| Project | Description |
66-
| ------------------------------------------------ | ---------------------------------------- |
67-
| [Docusaurus](https://docusaurus.io) | Docusaurus makes it easy to maintain Open Source documentation websites |
68-
| [GitBook](https://www.gitbook.com) | Where technical teams document |
69-
| [MkDocs](https://www.mkdocs.org) | Project documentation with Markdown |
70-
| [VuePress](https://vuepress.vuejs.org) | Vue-powered Static Site Generator |
65+
| Project | Description |
66+
| -------------------------------------- | ----------------------------------------------------------------------- |
67+
| [Docusaurus](https://docusaurus.io) | Docusaurus makes it easy to maintain Open Source documentation websites |
68+
| [GitBook](https://www.gitbook.com) | Where technical teams document |
69+
| [MkDocs](https://www.mkdocs.org) | Project documentation with Markdown |
70+
| [VuePress](https://vuepress.vuejs.org) | Vue-powered Static Site Generator |
7171

7272
## Contributing
7373

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ If you believe you have found a security vulnerability in docsify, please report
66

77
**Please do not report security vulnerabilities through our public GitHub issues.**
88

9-
Send email via :email: [email protected] to us.
9+
Send email to us via :email: [email protected].
1010

1111
Please include as much of the following information as possible to help us better understand the possible issue:
1212

build/build.js

+68-66
Original file line numberDiff line numberDiff line change
@@ -32,83 +32,89 @@ async function build(opts) {
3232
nodeResolve(),
3333
replace({
3434
__VERSION__: version,
35-
})
35+
}),
3636
],
3737
onwarn(message) {
3838
if (message.code === 'UNRESOLVED_IMPORT') {
3939
throw new Error(
4040
`Could not resolve module ` +
41-
message.source +
42-
`. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
43-
`Module ${message.source} is imported in ${message.importer}`
44-
)
41+
message.source +
42+
`. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
43+
`Module ${message.source} is imported in ${message.importer}`
44+
);
4545
}
46-
}
46+
},
4747
})
4848
.then(bundle => {
49-
const dest = 'lib/' + (opts.output || opts.input)
49+
const dest = 'lib/' + (opts.output || opts.input);
5050

51-
console.log(dest)
51+
console.log(dest);
5252
return bundle.write({
5353
format: 'iife',
54-
output: opts.globalName ? {name: opts.globalName} : {},
54+
output: opts.globalName ? { name: opts.globalName } : {},
5555
file: dest,
56-
strict: false
57-
})
58-
})
56+
strict: false,
57+
});
58+
});
5959
}
6060

6161
async function buildCore() {
62-
const promises = []
62+
const promises = [];
6363

64-
promises.push(build({
65-
input: 'src/core/index.js',
66-
output: 'docsify.js',
67-
}))
64+
promises.push(
65+
build({
66+
input: 'src/core/index.js',
67+
output: 'docsify.js',
68+
})
69+
);
6870

6971
if (isProd) {
70-
promises.push(build({
71-
input: 'src/core/index.js',
72-
output: 'docsify.min.js',
73-
plugins: [uglify()]
74-
}))
72+
promises.push(
73+
build({
74+
input: 'src/core/index.js',
75+
output: 'docsify.min.js',
76+
plugins: [uglify()],
77+
})
78+
);
7579
}
7680

77-
await Promise.all(promises)
81+
await Promise.all(promises);
7882
}
7983

8084
async function buildAllPlugin() {
8185
const plugins = [
82-
{name: 'search', input: 'search/index.js'},
83-
{name: 'ga', input: 'ga.js'},
84-
{name: 'gtag', input: 'gtag.js'},
85-
{name: 'matomo', input: 'matomo.js'},
86-
{name: 'emoji', input: 'emoji.js'},
87-
{name: 'external-script', input: 'external-script.js'},
88-
{name: 'front-matter', input: 'front-matter/index.js'},
89-
{name: 'zoom-image', input: 'zoom-image.js'},
90-
{name: 'disqus', input: 'disqus.js'},
91-
{name: 'gitalk', input: 'gitalk.js'}
92-
]
86+
{ name: 'search', input: 'search/index.js' },
87+
{ name: 'ga', input: 'ga.js' },
88+
{ name: 'gtag', input: 'gtag.js' },
89+
{ name: 'matomo', input: 'matomo.js' },
90+
{ name: 'emoji', input: 'emoji.js' },
91+
{ name: 'external-script', input: 'external-script.js' },
92+
{ name: 'front-matter', input: 'front-matter/index.js' },
93+
{ name: 'zoom-image', input: 'zoom-image.js' },
94+
{ name: 'disqus', input: 'disqus.js' },
95+
{ name: 'gitalk', input: 'gitalk.js' },
96+
];
9397

9498
const promises = plugins.map(item => {
9599
return build({
96100
input: 'src/plugins/' + item.input,
97-
output: 'plugins/' + item.name + '.js'
98-
})
99-
})
101+
output: 'plugins/' + item.name + '.js',
102+
});
103+
});
100104

101105
if (isProd) {
102106
plugins.forEach(item => {
103-
promises.push(build({
104-
input: 'src/plugins/' + item.input,
105-
output: 'plugins/' + item.name + '.min.js',
106-
plugins: [uglify()]
107-
}))
108-
})
107+
promises.push(
108+
build({
109+
input: 'src/plugins/' + item.input,
110+
output: 'plugins/' + item.name + '.min.js',
111+
plugins: [uglify()],
112+
})
113+
);
114+
});
109115
}
110116

111-
await Promise.all(promises)
117+
await Promise.all(promises);
112118
}
113119

114120
async function main() {
@@ -118,41 +124,37 @@ async function main() {
118124
atomic: true,
119125
awaitWriteFinish: {
120126
stabilityThreshold: 1000,
121-
pollInterval: 100
122-
}
127+
pollInterval: 100,
128+
},
123129
})
124130
.on('change', p => {
125-
console.log('[watch] ', p)
126-
const dirs = p.split(path.sep)
131+
console.log('[watch] ', p);
132+
const dirs = p.split(path.sep);
127133
if (dirs[1] === 'core') {
128-
buildCore()
134+
buildCore();
129135
} else if (dirs[2]) {
130-
const name = path.basename(dirs[2], '.js')
136+
const name = path.basename(dirs[2], '.js');
131137
const input = `src/plugins/${name}${
132138
/\.js/.test(dirs[2]) ? '' : '/index'
133-
}.js`
139+
}.js`;
134140

135141
build({
136142
input,
137-
output: 'plugins/' + name + '.js'
138-
})
143+
output: 'plugins/' + name + '.js',
144+
});
139145
}
140146
})
141147
.on('ready', () => {
142-
console.log('[start]')
143-
buildCore()
144-
buildAllPlugin()
145-
})
148+
console.log('[start]');
149+
buildCore();
150+
buildAllPlugin();
151+
});
146152
} else {
147-
await Promise.all([
148-
buildCore(),
149-
buildAllPlugin()
150-
])
153+
await Promise.all([buildCore(), buildAllPlugin()]);
151154
}
152155
}
153156

154-
main().catch((e) => {
155-
console.error(e)
156-
process.exit(1)
157-
})
158-
157+
main().catch(e => {
158+
console.error(e);
159+
process.exit(1);
160+
});

build/css.js

+39-38
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
1-
import fs from 'fs'
2-
import path from 'path'
3-
import {spawn} from 'child_process'
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { spawn } from 'child_process';
44

55
const relative = path => new URL(path, import.meta.url);
6-
const args = process.argv.slice(2)
6+
const args = process.argv.slice(2);
77
fs.readdir(relative('../src/themes'), (err, files) => {
8-
if (err) {
9-
console.error('err', err)
10-
process.exit(1)
11-
}
12-
files.map(async (file) => {
13-
if (/\.styl/g.test(file)) {
14-
const stylusBin = ['node_modules', 'stylus', 'bin', 'stylus'].join(path.sep)
15-
let cmdargs = [
16-
stylusBin,
17-
`src/themes/${file}`,
18-
'-u',
19-
'autoprefixer-stylus'
20-
]
21-
cmdargs = [...cmdargs, ...args]
8+
if (err) {
9+
console.error('err', err);
10+
process.exit(1);
11+
}
12+
files.map(async file => {
13+
if (/\.styl/g.test(file)) {
14+
const stylusBin = ['node_modules', 'stylus', 'bin', 'stylus'].join(
15+
path.sep
16+
);
17+
let cmdargs = [
18+
stylusBin,
19+
`src/themes/${file}`,
20+
'-u',
21+
'autoprefixer-stylus',
22+
];
23+
cmdargs = [...cmdargs, ...args];
2224

23-
const stylusCMD = spawn('node', cmdargs, { shell: true })
25+
const stylusCMD = spawn('node', cmdargs, { shell: true });
2426

25-
stylusCMD.stdout.on('data', (data) => {
26-
console.log(`[Stylus Build ] stdout: ${data}`);
27-
});
27+
stylusCMD.stdout.on('data', data => {
28+
console.log(`[Stylus Build ] stdout: ${data}`);
29+
});
2830

29-
stylusCMD.stderr.on('data', (data) => {
30-
console.error(`[Stylus Build ] stderr: ${data}`);
31-
});
31+
stylusCMD.stderr.on('data', data => {
32+
console.error(`[Stylus Build ] stderr: ${data}`);
33+
});
3234

33-
stylusCMD.on('close', (code) => {
34-
const message = `[Stylus Build ] child process exited with code ${code}`
35+
stylusCMD.on('close', code => {
36+
const message = `[Stylus Build ] child process exited with code ${code}`;
3537

36-
if (code !== 0) {
37-
console.error(message);
38-
process.exit(code)
39-
}
40-
console.log(message);
41-
});
42-
} else {
43-
return
38+
if (code !== 0) {
39+
console.error(message);
40+
process.exit(code);
4441
}
45-
46-
})
47-
})
42+
console.log(message);
43+
});
44+
} else {
45+
return;
46+
}
47+
});
48+
});

build/mincss.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import cssnano from 'cssnano';
2-
import path from 'path'
3-
import fs from 'fs'
2+
import path from 'path';
3+
import fs from 'fs';
44

5-
const files = fs.readdirSync(path.resolve('lib/themes'))
5+
const files = fs.readdirSync(path.resolve('lib/themes'));
66

77
files.forEach(file => {
8-
file = path.resolve('lib/themes', file)
9-
cssnano.process(fs.readFileSync(file)).then(result => {
10-
fs.writeFileSync(file, result.css)
11-
}).catch(e => {
12-
console.error(e)
13-
process.exit(1)
14-
})
15-
})
8+
file = path.resolve('lib/themes', file);
9+
cssnano
10+
.process(fs.readFileSync(file))
11+
.then(result => {
12+
fs.writeFileSync(file, result.css);
13+
})
14+
.catch(e => {
15+
console.error(e);
16+
process.exit(1);
17+
});
18+
});

docs/_media/example.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<h1>To infinity and Beyond!</h1>
1+
<h1>To infinity and Beyond!</h1>

0 commit comments

Comments
 (0)