File tree 9 files changed +32
-0
lines changed
9 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { renderMixin } from './render';
7
7
import { fetchMixin } from './fetch' ;
8
8
import { eventMixin } from './event' ;
9
9
10
+ /** This class contains all the magic. */
10
11
export class Docsify extends multiple (
11
12
initMixin ,
12
13
lifecycleMixin ,
Original file line number Diff line number Diff line change @@ -3,6 +3,13 @@ import { body, on } from '../util/dom';
3
3
import * as sidebar from './sidebar' ;
4
4
import { scrollIntoView , scroll2Top } from './scroll' ;
5
5
6
+ /**
7
+ * This class wires up some UI events using the `sidebar` utility. On each
8
+ * route change it re-initializes the events because the sidebar is re-rendered
9
+ * each time we go to a new page.
10
+ */
11
+ // TODO @trusktr , this should need to re-initialize events, and the sidebar
12
+ // should not be re-rendered each time.
6
13
export function eventMixin ( Base = class { } ) {
7
14
return class extends Base {
8
15
$resetEvents ( source ) {
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ import { noop } from '../util/core';
4
4
import { getAndActive } from '../event/sidebar' ;
5
5
import { get } from './ajax' ;
6
6
7
+ /**
8
+ * This class provides methods for fetching content (f.e. markdown pages). It
9
+ * coordinates renderMixin with help from the router.
10
+ */
7
11
export function fetchMixin ( Base = class { } ) {
8
12
return class extends Base {
9
13
constructor ( ) {
Original file line number Diff line number Diff line change 1
1
import config from '../config' ;
2
2
3
+ /**
4
+ * This class is responsible to initializing all other mixins in a certain
5
+ * order, and calling lifecycle hooks at appropriate times.
6
+ */
3
7
export function initMixin ( Base = class { } ) {
4
8
return class extends Base {
5
9
constructor ( ) {
Original file line number Diff line number Diff line change 1
1
import { noop } from '../util/core' ;
2
2
3
+ /** This class sets of lifecycle hooks that plugins can hook into. */
3
4
export function lifecycleMixin ( Base = class { } ) {
4
5
return class Lifecycle extends Base {
5
6
initLifecycle ( ) {
Original file line number Diff line number Diff line change 1
1
import { isFn } from '../util/core' ;
2
2
3
+ /** This class gets all plugins that were specified in the Docsify config can calls them. */
3
4
export function pluginMixin ( Base = class { } ) {
4
5
return class Plugin extends Base {
5
6
initPlugin ( ) {
Original file line number Diff line number Diff line change @@ -57,6 +57,10 @@ const compileMedia = {
57
57
} ,
58
58
} ;
59
59
60
+ /**
61
+ * This class compiles the markdown of each page of a Docsify site into HTML
62
+ * (using some information from the provided router).
63
+ */
60
64
export class Compiler {
61
65
constructor ( config , router ) {
62
66
this . config = config ;
Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ import { Compiler } from './compiler';
11
11
import * as tpl from './tpl' ;
12
12
import { prerenderEmbed } from './embed' ;
13
13
14
+ /**
15
+ * This class is provides methods for rendering the Docsify site content using
16
+ * the Compiler to convert markdown into HTML. It wires up the Compiler with
17
+ * the router.
18
+ */
14
19
export function renderMixin ( Base = class { } ) {
15
20
return class extends Base {
16
21
_executeScript ( ) {
@@ -86,6 +91,7 @@ export function renderMixin(Base = class {}) {
86
91
el . setAttribute ( 'href' , nameLink [ match ] ) ;
87
92
}
88
93
}
94
+
89
95
_renderTo ( el , content , replace ) {
90
96
const node = dom . getNode ( el ) ;
91
97
if ( node ) {
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ import { noop } from '../util/core';
4
4
import { HashHistory } from './history/hash' ;
5
5
import { HTML5History } from './history/html5' ;
6
6
7
+ /**
8
+ * This class wires up the mechanisms that react to URL changes of the browser
9
+ * address bar.
10
+ */
7
11
export function routerMixin ( Base = class { } ) {
8
12
return class extends Base {
9
13
constructor ( ) {
You can’t perform that action at this time.
0 commit comments