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

feat: Plugin error handling #1742

Merged
merged 22 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
631e924
Add try/catch w/ error message to plugin calls
jhildenbiddle Feb 1, 2022
cfbcd81
Merge branch 'develop' into plugin-error-handling
jhildenbiddle Feb 1, 2022
67c5410
Update lifecycle.js
jhildenbiddle Feb 3, 2022
6cb9a58
Merge branch 'develop' into plugin-error-handling
jhildenbiddle Feb 3, 2022
2a58be6
Update lifecycle.js
jhildenbiddle Feb 3, 2022
e276411
Merge branch 'develop' into plugin-error-handling
jhildenbiddle Feb 5, 2022
0a9670e
Merge branch 'develop' into plugin-error-handling
jhildenbiddle Mar 7, 2022
97b91fa
Add try/catch to plugin pre-hooks
jhildenbiddle Mar 8, 2022
b808363
Update error message
jhildenbiddle Mar 8, 2022
2a39cea
Merge branch 'develop' into plugin-error-handling
jhildenbiddle Mar 8, 2022
c2bf5b9
Add catchPluginErrors option
jhildenbiddle Mar 10, 2022
99c9929
Fix async beforeEach calls
jhildenbiddle Mar 10, 2022
01aaced
Update plugin dev documentation
jhildenbiddle Mar 11, 2022
17f0313
Added catchPluginErrors option
jhildenbiddle Mar 11, 2022
bf72293
Remove unnecesary code block
jhildenbiddle Mar 11, 2022
c3c534c
Fix handling of hook return value
jhildenbiddle Mar 11, 2022
7ae61ea
Update template to handle no config scenario
jhildenbiddle Mar 11, 2022
89451d7
Update async hook text and examples
jhildenbiddle Mar 11, 2022
dd40e80
Add tests for catchPluginErrors option
jhildenbiddle Mar 11, 2022
a031405
Add tests for plugin system
jhildenbiddle Mar 11, 2022
70011e2
Update code samples
jhildenbiddle Mar 13, 2022
650870c
Merge branch 'develop' into plugin-error-handling
sy-records Mar 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 35 additions & 28 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ window.$docsify = {

## autoHeader

- type: `Boolean`
- Type: `Boolean`

If `loadSidebar` and `autoHeader` are both enabled, for each link in `_sidebar.md`, prepend a header to the page before converting it to HTML. See [#78](https://github.com/docsifyjs/docsify/issues/78).

Expand All @@ -378,7 +378,7 @@ window.$docsify = {

## executeScript

- type: `Boolean`
- Type: `Boolean`

Execute the script on the page. Only parse the first script tag ([demo](themes)). If Vue is present, it is turned on by default.

Expand All @@ -400,8 +400,8 @@ Note that if you are running an external script, e.g. an embedded jsfiddle demo,

## nativeEmoji

- type: `Boolean`
- default: `false`
- Type: `Boolean`
- Default: `false`

Render emoji shorthand codes using GitHub-style emoji images or platform-native emoji characters.

Expand Down Expand Up @@ -453,8 +453,8 @@ To render shorthand codes as text, replace `:` characters with the `:` HTM

## noEmoji

- type: `Boolean`
- default: `false`
- Type: `Boolean`
- Default: `false`

Disabled emoji parsing and render all emoji shorthand as text.

Expand Down Expand Up @@ -492,7 +492,7 @@ To disable emoji parsing of individual shorthand codes, replace `:` characters w

## mergeNavbar

- type: `Boolean`
- Type: `Boolean`

Navbar will be merged with the sidebar on smaller screens.

Expand All @@ -504,7 +504,7 @@ window.$docsify = {

## formatUpdated

- type: `String|Function`
- Type: `String|Function`

We can display the file update date through **{docsify-updated<span>}</span>** variable. And format it by `formatUpdated`.
See https://github.com/lukeed/tinydate#patterns
Expand All @@ -523,8 +523,8 @@ window.$docsify = {

## externalLinkTarget

- type: `String`
- default: `_blank`
- Type: `String`
- Default: `_blank`

Target to open external links inside the markdown. Default `'_blank'` (new window/tab)

Expand All @@ -536,8 +536,8 @@ window.$docsify = {

## cornerExternalLinkTarget

- type:`String`
- default:`_blank`
- Type:`String`
- Default:`_blank`

Target to open external link at the top right corner. Default `'_blank'` (new window/tab)

Expand All @@ -549,8 +549,8 @@ window.$docsify = {

## externalLinkRel

- type: `String`
- default: `noopener`
- Type: `String`
- Default: `noopener`

Default `'noopener'` (no opener) prevents the newly opened external page (when [externalLinkTarget](#externallinktarget) is `'_blank'`) from having the ability to control our page. No `rel` is set when it's not `'_blank'`. See [this post](https://mathiasbynens.github.io/rel-noopener/) for more information about why you may want to use this option.

Expand All @@ -562,8 +562,8 @@ window.$docsify = {

## routerMode

- type: `String`
- default: `hash`
- Type: `String`
- Default: `hash`

```js
window.$docsify = {
Expand All @@ -573,7 +573,7 @@ window.$docsify = {

## crossOriginLinks

- type: `Array`
- Type: `Array`

When `routerMode: 'history'`, you may face cross-origin issues. See [#1379](https://github.com/docsifyjs/docsify/issues/1379).
In Markdown content, there is a simple way to solve it: see extends Markdown syntax `Cross-Origin link` in [helpers](helpers.md).
Expand All @@ -586,7 +586,7 @@ window.$docsify = {

## noCompileLinks

- type: `Array<string>`
- Type: `Array<string>`

Sometimes we do not want docsify to handle our links. See [#203](https://github.com/docsifyjs/docsify/issues/203). We can skip compiling of certain links by specifying an array of strings. Each string is converted into to a regular expression (`RegExp`) and the _whole_ href of a link is matched against it.

Expand All @@ -598,7 +598,7 @@ window.$docsify = {

## onlyCover

- type: `Boolean`
- Type: `Boolean`

Only coverpage is loaded when visiting the home page.

Expand All @@ -610,7 +610,7 @@ window.$docsify = {

## requestHeaders

- type: `Object`
- Type: `Object`

Set the request resource headers.

Expand All @@ -634,7 +634,7 @@ window.$docsify = {

## ext

- type: `String`
- Type: `String`

Request file extension.

Expand All @@ -646,7 +646,7 @@ window.$docsify = {

## fallbackLanguages

- type: `Array<string>`
- Type: `Array<string>`

List of languages that will fallback to the default language when a page is requested and it doesn't exist for the given locale.

Expand All @@ -664,7 +664,7 @@ window.$docsify = {

## notFoundPage

- type: `Boolean` | `String` | `Object`
- Type: `Boolean` | `String` | `Object`

Load the `_404.md` file:

Expand Down Expand Up @@ -697,8 +697,8 @@ window.$docsify = {

## topMargin

- type: `Number`
- default: `0`
- Type: `Number`
- Default: `0`

Adds a space on top when scrolling the content page to reach the selected section. This is useful in case you have a _sticky-header_ layout and you want to align anchors to the end of your header.

Expand All @@ -710,7 +710,7 @@ window.$docsify = {

## vueComponents

- type: `Object`
- Type: `Object`

Creates and registers global [Vue components](https://vuejs.org/v2/guide/components.html). Components are specified using the component name as the key with an object containing Vue options as the value. Component `data` is unique for each instance and will not persist as users navigate the site.

Expand Down Expand Up @@ -743,7 +743,7 @@ window.$docsify = {

## vueGlobalOptions

- type: `Object`
- Type: `Object`

Specifies [Vue options](https://vuejs.org/v2/api/#Options-Data) for use with Vue content not explicitly mounted with [vueMounts](#mounting-dom-elements), [vueComponents](#components), or a [markdown script](#markdown-script). Changes to global `data` will persist and be reflected anywhere global references are used.

Expand Down Expand Up @@ -777,7 +777,7 @@ window.$docsify = {

## vueMounts

- type: `Object`
- Type: `Object`

Specifies DOM elements to mount as [Vue instances](https://vuejs.org/v2/guide/instance.html) and their associated options. Mount elements are specified using a [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) as the key with an object containing Vue options as their value. Docsify will mount the first matching element in the main content area each time a new page is loaded. Mount element `data` is unique for each instance and will not persist as users navigate the site.

Expand Down Expand Up @@ -808,3 +808,10 @@ window.$docsify = {
{{ count }}
<button @click="count += 1">+</button>
</output>

## catchPluginErrors

- Type: `Boolean`
- Default: `true`

Determines if Docsify should handle uncaught _synchronous_ plugin errors automatically. This can prevent plugin errors from affecting docsify's ability to properly render live site content.
Loading