Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7da3521

Browse filesBrowse files
authored
Merge pull request docsifyjs#2114 from docsifyjs/modernize-source-code
chore: update miscellaneous parts of the source to reasonably modern language alternatives, remove polyfills, improve some JSDoc comments, remove traces of IE
2 parents 4e01f4d + b18865d commit 7da3521
Copy full SHA for 7da3521

73 files changed

+512-586Lines changed: 512 additions & 586 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/PULL_REQUEST_TEMPLATE.md‎

Copy file name to clipboardExpand all lines: .github/PULL_REQUEST_TEMPLATE.md
-1Lines changed: 0 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,3 @@ If yes, please describe the impact and migration path for existing applications:
6262
- [ ] Firefox
6363
- [ ] Safari
6464
- [ ] Edge
65-
- [ ] IE
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
-1Lines changed: 0 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
- Smart full-text search plugin
4747
- Multiple themes
4848
- Useful plugin API
49-
- Compatible with IE11
5049
- Support embedded files
5150

5251
## Quick start
Collapse file

‎build/build.js‎

Copy file name to clipboardExpand all lines: build/build.js
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ async function build(opts) {
2626
await rollup
2727
.rollup({
2828
input: opts.input,
29-
plugins: (opts.plugins || []).concat([
29+
plugins: [
30+
...(opts.plugins || []),
3031
commonjs(),
3132
nodeResolve(),
3233
replace({
3334
__VERSION__: version,
3435
})
35-
]),
36-
onwarn: function (message) {
36+
],
37+
onwarn(message) {
3738
if (message.code === 'UNRESOLVED_IMPORT') {
3839
throw new Error(
3940
`Could not resolve module ` +
@@ -44,8 +45,8 @@ async function build(opts) {
4445
}
4546
}
4647
})
47-
.then(function (bundle) {
48-
var dest = 'lib/' + (opts.output || opts.input)
48+
.then(bundle => {
49+
const dest = 'lib/' + (opts.output || opts.input)
4950

5051
console.log(dest)
5152
return bundle.write({
@@ -77,7 +78,7 @@ async function buildCore() {
7778
}
7879

7980
async function buildAllPlugin() {
80-
var plugins = [
81+
const plugins = [
8182
{name: 'search', input: 'search/index.js'},
8283
{name: 'ga', input: 'ga.js'},
8384
{name: 'gtag', input: 'gtag.js'},
Collapse file

‎build/cover.js‎

Copy file name to clipboard
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import fs from 'fs';
22
import { relative } from './util.js';
3-
var read = fs.readFileSync;
4-
var write = fs.writeFileSync;
3+
const read = fs.readFileSync;
4+
const write = fs.writeFileSync;
55
const pkgPath = relative(import.meta, '..', 'package.json');
66
const pkg = JSON.parse(read(pkgPath).toString());
7-
var version = process.env.VERSION || pkg.version;
7+
const version = process.env.VERSION || pkg.version;
88

9-
var file = relative(import.meta, '..', 'docs', '_coverpage.md');
10-
var cover = read(file, 'utf8').toString();
9+
const file = relative(import.meta, '..', 'docs', '_coverpage.md');
10+
let cover = read(file, 'utf8').toString();
1111

1212
console.log('Replace version number in cover page...');
1313
cover = cover.replace(
1414
/<small>(\S+)?<\/small>/g,
15-
'<small>' + version + '</small>'
15+
/* html */ `<small>${version}</small>`
1616
);
1717
write(file, cover);
Collapse file

‎build/css.js‎

Copy file name to clipboardExpand all lines: build/css.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ fs.readdir(relative('../src/themes'), (err, files) => {
1111
}
1212
files.map(async (file) => {
1313
if (/\.styl/g.test(file)) {
14-
var stylusCMD;
1514
const stylusBin = ['node_modules', 'stylus', 'bin', 'stylus'].join(path.sep)
16-
var cmdargs = [
15+
let cmdargs = [
1716
stylusBin,
1817
`src/themes/${file}`,
1918
'-u',
2019
'autoprefixer-stylus'
2120
]
22-
cmdargs = cmdargs.concat(args)
21+
cmdargs = [...cmdargs, ...args]
2322

24-
stylusCMD = spawn('node', cmdargs, { shell: true })
23+
const stylusCMD = spawn('node', cmdargs, { shell: true })
2524

2625
stylusCMD.stdout.on('data', (data) => {
2726
console.log(`[Stylus Build ] stdout: ${data}`);
Collapse file

‎build/emoji.js‎

Copy file name to clipboardExpand all lines: build/emoji.js
+11-13Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,15 @@ function writeEmojiJS(emojiData) {
9393
}
9494
}
9595

96-
(async () => {
97-
console.info('Build emoji');
98-
99-
try {
100-
const emojiData = await getEmojiData();
101-
102-
if (emojiData) {
103-
writeEmojiPage(emojiData);
104-
writeEmojiJS(emojiData);
105-
}
106-
} catch (err) {
107-
console.warn(`- Error: ${err.message}`);
96+
console.info('Build emoji');
97+
98+
try {
99+
const emojiData = await getEmojiData();
100+
101+
if (emojiData) {
102+
writeEmojiPage(emojiData);
103+
writeEmojiJS(emojiData);
108104
}
109-
})();
105+
} catch (err) {
106+
console.warn(`- Error: ${err.message}`);
107+
}
Collapse file

‎docs/README.md‎

Copy file name to clipboardExpand all lines: docs/README.md
-1Lines changed: 0 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ See the [Quick start](quickstart.md) guide for more details.
1616
- Multiple themes
1717
- Useful plugin API
1818
- Emoji support
19-
- Compatible with IE11
2019

2120
## Examples
2221

Collapse file

‎docs/_media/example.js‎

Copy file name to clipboard
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import fetch from 'fetch'
1+
import fetch from 'fetch';
22

3-
const URL = 'https://example.com'
4-
const PORT = 8080
3+
const URL = 'https://example.com';
4+
const PORT = 8080;
55

66
/// [demo]
77
const result = fetch(`${URL}:${PORT}`)
8-
.then(function (response) {
9-
return response.json()
10-
})
11-
.then(function (myJson) {
12-
console.log(JSON.stringify(myJson))
8+
.then(response => {
9+
return response.json();
1310
})
11+
.then(myJson => {
12+
console.log(JSON.stringify(myJson));
13+
});
1414
/// [demo]
1515

16-
result.then(console.log).catch(console.error)
16+
result.then(console.log).catch(console.error);
Collapse file

‎docs/configuration.md‎

Copy file name to clipboardExpand all lines: docs/configuration.md
+21-14Lines changed: 21 additions & 14 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ See https://github.com/lukeed/tinydate#patterns
249249
window.$docsify = {
250250
formatUpdated: '{MM}/{DD} {HH}:{mm}',
251251

252-
formatUpdated: function (time) {
252+
formatUpdated(time) {
253253
// ...
254254

255255
return time;
@@ -346,14 +346,14 @@ window.$docsify = {
346346
markdown: {
347347
smartypants: true,
348348
renderer: {
349-
link: function () {
349+
link() {
350350
// ...
351351
},
352352
},
353353
},
354354

355355
// function
356-
markdown: function (marked, renderer) {
356+
markdown(marked, renderer) {
357357
// ...
358358
return marked;
359359
},
@@ -747,18 +747,17 @@ window.$docsify = {
747747
'/foo': '# Custom Markdown',
748748
749749
// RegEx match w/ synchronous function
750-
'/bar/(.*)': function (route, matched) {
750+
'/bar/(.*)'(route, matched) {
751751
return '# Custom Markdown';
752752
},
753753
754754
// RegEx match w/ asynchronous function
755-
'/baz/(.*)': function (route, matched, next) {
756-
// Requires `fetch` polyfill for legacy browsers (https://github.github.io/fetch/)
755+
'/baz/(.*)'(route, matched, next) {
757756
fetch('/api/users?id=12345')
758-
.then(function (response) {
757+
.then(response => {
759758
next('# Custom Markdown');
760759
})
761-
.catch(function (err) {
760+
.catch(err => {
762761
// Handle error...
763762
});
764763
},
@@ -772,7 +771,7 @@ Other than strings, route functions can return a falsy value (`null` \ `undefine
772771
window.$docsify = {
773772
routes: {
774773
// accepts everything other than dogs (synchronous)
775-
'/pets/(.+)': function(route, matched) {
774+
'/pets/(.+)'(route, matched) {
776775
if (matched[0] === 'dogs') {
777776
return null;
778777
} else {
@@ -781,7 +780,7 @@ window.$docsify = {
781780
}
782781

783782
// accepts everything other than cats (asynchronous)
784-
'/pets/(.*)': function(route, matched, next) {
783+
'/pets/(.*)'(route, matched, next) {
785784
if (matched[0] === 'cats') {
786785
next();
787786
} else {
@@ -799,12 +798,12 @@ Finally, if you have a specific path that has a real markdown file (and therefor
799798
window.$docsify = {
800799
routes: {
801800
// if you look up /pets/cats, docsify will skip all routes and look for "pets/cats.md"
802-
'/pets/cats': function(route, matched) {
801+
'/pets/cats'(route, matched) {
803802
return false;
804803
}
805804

806805
// but any other pet should generate dynamic content right here
807-
'/pets/(.+)': function(route, matched) {
806+
'/pets/(.+)'(route, matched) {
808807
const pet = matched[0];
809808
return `your pet is ${pet} (but not a cat)`;
810809
}
@@ -835,11 +834,19 @@ If you have a link to the homepage in the sidebar and want it to be shown as act
835834

836835
For more details, see [#1131](https://github.com/docsifyjs/docsify/issues/1131).
837836

838-
## themeColor
837+
## themeColor (_deprecated_)
838+
839+
> **Warning** Deprecated. Use the CSS var `--theme-color` in your `<style>` sheet. Example:
840+
>
841+
> <style>
842+
> :root {
843+
> --theme-color: deeppink;
844+
> }
845+
> </style>
839846
840847
- Type: `String`
841848

842-
Customize the theme color. Use [CSS3 variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables) feature and polyfill in older browsers.
849+
Customize the theme color.
843850

844851
```js
845852
window.$docsify = {
Collapse file

‎docs/index.html‎

Copy file name to clipboardExpand all lines: docs/index.html
+10-12Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
name="google-site-verification"
99
content="6t0LoIeFksrjF4c9sqUEsVXiQNxLp2hgoqo0KryT-sE"
1010
/>
11-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
1211
<meta
1312
name="keywords"
1413
content="doc,docs,documentation,gitbook,creator,generator,github,jekyll,github-pages"
@@ -64,7 +63,7 @@
6463
<script src="//cdn.jsdelivr.net/npm/docsify-plugin-carbon@1"></script>
6564
<script>
6665
// Set html "lang" attribute based on URL
67-
var lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);
66+
const lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);
6867

6968
if (lang) {
7069
document.documentElement.setAttribute('lang', lang[1]);
@@ -128,17 +127,16 @@
128127
},
129128
vueComponents: {
130129
'button-counter': {
131-
template:
132-
'<button @click="count += 1">You clicked me {{ count }} times</button>',
133-
data: function () {
130+
template: /* html */ `<button @click="count += 1">You clicked me {{ count }} times</button>`,
131+
data() {
134132
return {
135133
count: 0,
136134
};
137135
},
138136
},
139137
},
140138
vueGlobalOptions: {
141-
data: function () {
139+
data() {
142140
return {
143141
count: 0,
144142
message: 'Hello, World!',
@@ -151,7 +149,7 @@
151149
};
152150
},
153151
computed: {
154-
timeOfDay: function () {
152+
timeOfDay() {
155153
const date = new Date();
156154
const hours = date.getHours();
157155

@@ -165,14 +163,14 @@
165163
},
166164
},
167165
methods: {
168-
hello: function () {
166+
hello() {
169167
alert(this.message);
170168
},
171169
},
172170
},
173171
vueMounts: {
174172
'#counter': {
175-
data: function () {
173+
data() {
176174
return {
177175
count: 0,
178176
};
@@ -182,7 +180,7 @@
182180
plugins: [
183181
DocsifyCarbon.create('CEBI6KQE', 'docsifyjsorg'),
184182
function (hook, vm) {
185-
hook.beforeEach(function (html) {
183+
hook.beforeEach(html => {
186184
if (/githubusercontent\.com/.test(vm.route.file)) {
187185
url = vm.route.file
188186
.replace('raw.githubusercontent.com', 'github.com')
@@ -196,14 +194,14 @@
196194
'https://github.com/docsifyjs/docsify/blob/develop/docs/' +
197195
vm.route.file;
198196
}
199-
var editHtml = '[:memo: Edit Document](' + url + ')\n';
197+
const editHtml = '[:memo: Edit Document](' + url + ')\n';
200198
return (
201199
editHtml +
202200
html +
203201
'\n\n----\n\n' +
204202
'<a href="https://docsify.js.org" target="_blank" style="color: inherit; font-weight: normal; text-decoration: none;">Powered by docsify</a>'
205203
);
206-
})
204+
});
207205
},
208206
],
209207
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.