Skip to content

Commit 08419c5

Browse files
committed
add JSDoc comments to start describing each class
1 parent de38301 commit 08419c5

File tree

9 files changed

+32
-0
lines changed

9 files changed

+32
-0
lines changed

src/core/Docsify.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { renderMixin } from './render';
77
import { fetchMixin } from './fetch';
88
import { eventMixin } from './event';
99

10+
/** This class contains all the magic. */
1011
export class Docsify extends multiple(
1112
initMixin,
1213
lifecycleMixin,

src/core/event/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import { body, on } from '../util/dom';
33
import * as sidebar from './sidebar';
44
import { scrollIntoView, scroll2Top } from './scroll';
55

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.
613
export function eventMixin(Base = class {}) {
714
return class extends Base {
815
$resetEvents(source) {

src/core/fetch/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { noop } from '../util/core';
44
import { getAndActive } from '../event/sidebar';
55
import { get } from './ajax';
66

7+
/**
8+
* This class provides methods for fetching content (f.e. markdown pages). It
9+
* coordinates renderMixin with help from the router.
10+
*/
711
export function fetchMixin(Base = class {}) {
812
return class extends Base {
913
constructor() {

src/core/init/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import config from '../config';
22

3+
/**
4+
* This class is responsible to initializing all other mixins in a certain
5+
* order, and calling lifecycle hooks at appropriate times.
6+
*/
37
export function initMixin(Base = class {}) {
48
return class extends Base {
59
constructor() {

src/core/lifecycle/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { noop } from '../util/core';
22

3+
/** This class sets of lifecycle hooks that plugins can hook into. */
34
export function lifecycleMixin(Base = class {}) {
45
return class Lifecycle extends Base {
56
initLifecycle() {

src/core/plugin/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { isFn } from '../util/core';
22

3+
/** This class gets all plugins that were specified in the Docsify config can calls them. */
34
export function pluginMixin(Base = class {}) {
45
return class Plugin extends Base {
56
initPlugin() {

src/core/render/compiler.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ const compileMedia = {
5757
},
5858
};
5959

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+
*/
6064
export class Compiler {
6165
constructor(config, router) {
6266
this.config = config;

src/core/render/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { Compiler } from './compiler';
1111
import * as tpl from './tpl';
1212
import { prerenderEmbed } from './embed';
1313

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+
*/
1419
export function renderMixin(Base = class {}) {
1520
return class extends Base {
1621
_executeScript() {
@@ -86,6 +91,7 @@ export function renderMixin(Base = class {}) {
8691
el.setAttribute('href', nameLink[match]);
8792
}
8893
}
94+
8995
_renderTo(el, content, replace) {
9096
const node = dom.getNode(el);
9197
if (node) {

src/core/router/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { noop } from '../util/core';
44
import { HashHistory } from './history/hash';
55
import { HTML5History } from './history/html5';
66

7+
/**
8+
* This class wires up the mechanisms that react to URL changes of the browser
9+
* address bar.
10+
*/
711
export function routerMixin(Base = class {}) {
812
return class extends Base {
913
constructor() {

0 commit comments

Comments
 (0)