Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support docsify init --plugins #99

Merged
merged 32 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ee76d17
feat: adding plugins support
tool3 Mar 12, 2020
8b9fccb
fix: fixing url
tool3 Mar 12, 2020
21a097f
fix: removing temp docs
tool3 Mar 12, 2020
a078e08
docs: adding documentation for init --plugins
tool3 Mar 12, 2020
b8b89c7
fix: removing unused files
tool3 Mar 13, 2020
64b32e0
fix: removing .nojekyll top-level
tool3 Mar 13, 2020
f522d07
chore: adding tests
tool3 Mar 13, 2020
e532c1e
fix: fixing docs links
tool3 Mar 13, 2020
6558cee
refactor: cleaner matchSnapshot
tool3 Mar 13, 2020
5431de3
fix: removing redundant spread
tool3 Mar 20, 2020
1083bec
fix(init): adding jsdelivr and major version to plugins init
tool3 Jun 18, 2020
54dd557
fix: realigning with remote
tool3 Jun 18, 2020
de9bcce
fix(e2e): recreating index snap with latest docsify version
tool3 Jun 18, 2020
3c547f9
Merge branch 'master' into master
tool3 Jun 21, 2020
067bb2a
Update docs/README.md
tool3 Apr 28, 2021
c1f92b4
Update README.md
tool3 Apr 28, 2021
5ec56bb
Update lib/template/index.html
tool3 Apr 28, 2021
0059e7f
Update lib/commands/init.js
tool3 Apr 28, 2021
272e310
chore: Optimize code to ensure equal indentation
sy-records Apr 29, 2021
c83fa11
Merge branch 'master' into tool3/master
sy-records Apr 29, 2021
f3e717c
chore: update snap
sy-records Apr 29, 2021
e48d7a8
chore: update snap
sy-records Apr 29, 2021
f96f6d5
chore: update zh.json
sy-records Apr 29, 2021
2debff8
fix: the exception caused by the plugin name being a number
sy-records Apr 29, 2021
6f26f05
Use MultiSelect
sy-records May 19, 2021
1b7f8f2
Update README
sy-records May 19, 2021
f2943a1
Update lib/commands/init.js
sy-records May 27, 2021
e1118d5
Update msg
sy-records May 27, 2021
63e9d95
Fix missing msg
sy-records May 27, 2021
790e96c
refactor: simplify code with async/await
jamesgeorge007 May 27, 2021
149bd81
chore: handle user interruptions
jamesgeorge007 May 28, 2021
828b672
Update README
sy-records Jun 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file added .nojekyll
Empty file.
98 changes: 0 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,98 +0,0 @@
<p align="center">
<a href="https://docsify.js.org">
<img alt="docsify" src="./media/icon.svg">
</a>
</p>

<p align="center">
🖌 docsify cli - A magical documentation generator.
</p>

<p align="center">
<a href="#backers"><img alt="Backers on Open Collective" src="https://opencollective.com/docsify/backers/badge.svg?style=flat-square"></a>
<a href="#sponsors"><img alt="Sponsors on Open Collective" src="https://opencollective.com/docsify/sponsors/badge.svg?style=flat-square"></a>
<a href="https://travis-ci.org/docsifyjs/docsify"><img alt="Travis Status" src="https://img.shields.io/travis/docsifyjs/docsify-cli/master.svg?style=flat-square"></a>
<a href="https://www.npmjs.com/package/docsify"><img alt="npm" src="https://img.shields.io/npm/v/docsify-cli.svg?style=flat-square"></a>
<a href="https://gitter.im/docsifyjs/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link"><img alt="gitter" src="https://img.shields.io/gitter/room/docsifyjs/docsify.svg?style=flat-square"></a>
<a href="https://github.com/docsifyjs/docsify-cli/blob/master/LICENSE"><img alt="license" src="https://img.shields.io/github/license/docsifyjs/docsify-cli.svg?style=flat-square"></a>
<a href="https://www.npmjs.com/package/docsify-cli"><img alt="npm-total-download" src="https://img.shields.io/npm/dt/docsify-cli.svg?style=flat-square"></a>
<a href="https://www.npmjs.com/package/docsify-cli"><img alt="npm-monthly-download" src="https://img.shields.io/npm/dm/docsify-cli.svg?style=flat-square"></a>

</p>

<p align="center">Gold Sponsor via <a href="https://opencollective.com/docsify">Open Collective</a></p>

<p align="center">
<a href="https://opencollective.com/docsify/order/3254">
<img src="https://opencollective.com/docsify/tiers/gold-sponsor.svg?avatarHeight=36">
</a>
</p>
tool3 marked this conversation as resolved.
Show resolved Hide resolved

## Screencast

![Screencast](https://raw.githubusercontent.com/QingWei-Li/docsify-cli/master/media/screencast.gif)

> Running a server on `localhost` with live-reload.

## Installation

Install `docsify-cli` via `npm` or `yarn` globally.

```shell
npm i docsify-cli -g
# yarn global add docsify-cli
```

## Usage

### `init` command

Use `init` to generate your docs.

```shell
docsify init <path> [--local false] [--theme vue]

# docsify i <path> [--local false] [--theme vue]
```

`<path>` defaults to the current directory. Use relative paths like `./docs` (or `docs`).

- `--local` option:
- Shorthand: `-l`
- Type: boolean
- Default: `false`
- Description: Copy `docsify` files to the docs path, defaults to `false` using `unpkg.com` as the content delivery network (CDN). To explicitly set this option to `false` use `--no-local`.
- `--theme` option:
- Shorthand: `-t`
- Type: string
- Default: `vue`
- Description: Choose a theme, defaults to `vue`, other choices are `buble`, `dark` and `pure`.

### `serve` command

Run a server on `localhost` with livereload.

```shell
docsify serve <path> [--open false] [--port 3000]

# docsify s <path> [--open false] [--port 3000]
```

- `--open` option:
- Shorthand: `-o`
- Type: boolean
- Default: `false`
- Description: Open the docs in the default browser, defaults to `false`. To explicitly set this option to `false` use `--no-open`.
- `--port` option:
- Shorthand: `-p`
- Type: number
- Default: `3000`
- Description: Choose a listen port, defaults to `3000`.

## Contributing

Please see the [Contributing Guidelines](./CONTRIBUTING.md)

## License

[MIT](./LICENSE)
5 changes: 5 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ docsify init <path> [--local false] [--theme vue]
* Type: string
* Default: `vue`
* Description: Choose a theme, defaults to `vue`, other choices are `buble`, `dark` and `pure`.
* `--plugins` option:
* Shorthand: `-p`
* Type: array
* Default: `[]`
* Description: Provide a list of plugins to insert as `<script>` tags to `index.html`. If a plugin name is provided the script will have a url of `https://unpkg.com/docsify/lib/plugins/<plugin_name>`, otherwise provide the url to the plugin. Example: `docsify init docs/ -p search gitalk https://unpkg.com/docsify-copy-code@2`
tool3 marked this conversation as resolved.
Show resolved Hide resolved

### `serve` command

Expand Down
21 changes: 21 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/vue.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: '',
repo: ''
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
</body>
</html>
7 changes: 6 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ require('yargs')
nargs: 1,
requiresArg: true,
type: 'string'
},
plugins: {
alias: 'p',
desc: chalk.gray(y18n.__('init.plugins')),
type: 'array'
}
}),
handler: argv => run.init(argv.path, argv.local, argv.theme)
handler: argv => run.init(argv.path, argv.local, argv.theme, argv.plugins)
})
.command({
command: 'serve [path]',
Expand Down
13 changes: 12 additions & 1 deletion lib/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const replace = function (file, tpl, replace) {
}

// eslint-disable-next-line
module.exports = function (path = '', local, theme) {
module.exports = function (path = '', local, theme, plugins) {
const msg =
'\n' +
chalk.green('Initialization succeeded!') +
Expand Down Expand Up @@ -64,5 +64,16 @@ module.exports = function (path = '', local, theme) {
replace(target(filename), 'repo: \'\'', `repo: '${repo}'`)
}

if (plugins) {
replace(target(filename), '_plugins_', '_plugin\n '.repeat(plugins.length))
plugins.forEach(plugin => {
const url = plugin.includes('//') ? plugin : `https://unpkg.com/docsify/lib/plugins/${plugin}.min.js`
tool3 marked this conversation as resolved.
Show resolved Hide resolved
const scriptTemplate = `<script src="${url}"></script>`
replace(target(filename), '_plugin', scriptTemplate)
})
} else {
replace(target(filename), '_plugins_', '')
}

console.log(msg)
}
1 change: 1 addition & 0 deletions lib/template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
_plugins_
</body>
</html>
1 change: 1 addition & 0 deletions tools/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"start": "Server for SSR",
"init.local": "Copy docsify files to local. To explicitly set --local to false you may use --no-local.",
"init.theme": "Theme file to be used.",
"init.plugins": "A list of plugins to be used.",
"serve": "Run local server to preview site.",
"serve.open": "Open docs in default browser. To explicitly set --open to false you may use --no-open.",
"serve.port": "Listen port.",
Expand Down