1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | const _ = require('underscore');
|
10 | const Handlebars = require('handlebars');
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | exports.buildFileTree = function onbuildFileTree (items) {
|
18 | var out = '<ul>';
|
19 | _.each(items, function (i, k) {
|
20 | out += '<li>';
|
21 | if (_.isObject(i)) {
|
22 | if (!i.path) {
|
23 | out += k + '/' + onbuildFileTree(i);
|
24 | } else {
|
25 | out += '<a href="../files/' + i.name + '.html">' + k + '</a>';
|
26 | }
|
27 | }
|
28 | out += '</li>';
|
29 | });
|
30 | out += '</ul>';
|
31 | return out;
|
32 | };
|
33 | exports.renderFileTree = exports.buildFileTree;
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | exports.crossLink = function oncrossLink (item, options) {
|
40 | var str = '';
|
41 | if (!item) {
|
42 | item = '';
|
43 | }
|
44 | if (item.indexOf('|') > 0) {
|
45 | var parts = item.split('|'),
|
46 | p = [];
|
47 | _.each(parts, function (i) {
|
48 | p.push(this._parseCrossLink.call(this, i));
|
49 | }, this);
|
50 | str = p.join(' | ');
|
51 | } else {
|
52 | var ctx = '';
|
53 | if (typeof options.fn === 'function') {
|
54 | ctx = options.fn(this);
|
55 | }
|
56 | str = this._parseCrossLink.call(this, item, false, ctx);
|
57 | }
|
58 | return str;
|
59 | };
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | exports.crossLinkModule = function oncrossLinkModule (item, options) {
|
66 | var str = item;
|
67 | if (this.ast.modules[item]) {
|
68 | var content = options.fn(this);
|
69 | if (content === "") {
|
70 | content = item;
|
71 | }
|
72 | str = '<a href="../modules/' + item.replace(/\//g, '_') +
|
73 | '.html">' + content + '</a>';
|
74 | }
|
75 | return str;
|
76 | };
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | exports.crossLinkRaw = function oncrossLinkRaw (item, options) {
|
83 | var str = '';
|
84 | if (!item) {
|
85 | item = '';
|
86 | }
|
87 | if (item.indexOf('|') > 0) {
|
88 | var parts = item.split('|'),
|
89 | p = [];
|
90 | _.each(parts, function (i) {
|
91 | p.push(this._parseCrossLink.call(this, i, true));
|
92 | }, this);
|
93 | str = p.join(' | ');
|
94 | } else {
|
95 | str = this._parseCrossLink.call(this, item, true);
|
96 | }
|
97 | return str;
|
98 | };
|
99 |
|
100 | exports.shouldShowInherit = function shouldShowInherit (item, options) {
|
101 | var classObj = this.ast.classes[item];
|
102 | if (classObj && !classObj.access) {
|
103 | classObj.access = 'public';
|
104 | }
|
105 | if (classObj && classObj.access !== 'private') {
|
106 |
|
107 | return options.fn(this);
|
108 | } else {
|
109 |
|
110 | return options.inverse(this);
|
111 | }
|
112 | };
|