@edx/frontend-platform 4.6.0 → 4.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.development +30 -0
- package/.env.test +30 -0
- package/.eslintignore +6 -0
- package/.eslintrc.js +28 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +13 -0
- package/.github/workflows/add-depr-ticket-to-depr-board.yml +19 -0
- package/.github/workflows/add-remove-label-on-comment.yml +20 -0
- package/.github/workflows/ci.yml +42 -0
- package/.github/workflows/commitlint.yml +10 -0
- package/.github/workflows/lockfileversion-check.yml +13 -0
- package/.github/workflows/manual-publish.yml +43 -0
- package/.github/workflows/npm-deprecate.yml +22 -0
- package/.github/workflows/release.yml +45 -0
- package/.github/workflows/self-assign-issue.yml +12 -0
- package/.github/workflows/update-browserslist-db.yml +12 -0
- package/.nvmrc +1 -0
- package/.releaserc +32 -0
- package/catalog-info.yaml +21 -0
- package/dist/LICENSE +661 -0
- package/dist/README.md +155 -0
- package/dist/package.json +86 -0
- package/docs/addTagsPlugin.js +10 -0
- package/docs/auth-API.md +114 -0
- package/docs/decisions/0001-record-architecture-decisions.rst +32 -0
- package/docs/decisions/0002-frontend-base-design-goals.rst +222 -0
- package/docs/decisions/0003-consolidation-into-frontend-platform.rst +71 -0
- package/docs/decisions/0004-axios-caching-implementation.rst +88 -0
- package/docs/decisions/0005-token-null-after-successful-refresh.rst +69 -0
- package/docs/decisions/0006-middleware-support-for-http-clients.rst +44 -0
- package/docs/decisions/0007-javascript-file-configuration.rst +143 -0
- package/docs/how_tos/automatic-case-conversion.rst +58 -0
- package/docs/how_tos/caching.rst +93 -0
- package/docs/how_tos/i18n.rst +305 -0
- package/docs/removeExport.js +24 -0
- package/docs/template/edx/README.md +12 -0
- package/docs/template/edx/publish.js +713 -0
- package/docs/template/edx/static/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/template/edx/static/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/template/edx/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/template/edx/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/template/edx/static/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/template/edx/static/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/template/edx/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/template/edx/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/template/edx/static/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/template/edx/static/scripts/linenumber.js +25 -0
- package/docs/template/edx/static/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/template/edx/static/scripts/prettify/lang-css.js +2 -0
- package/docs/template/edx/static/scripts/prettify/prettify.js +28 -0
- package/docs/template/edx/static/styles/jsdoc-default.css +356 -0
- package/docs/template/edx/static/styles/prettify-jsdoc.css +111 -0
- package/docs/template/edx/static/styles/prettify-tomorrow.css +132 -0
- package/docs/template/edx/tmpl/augments.tmpl +10 -0
- package/docs/template/edx/tmpl/container.tmpl +196 -0
- package/docs/template/edx/tmpl/details.tmpl +143 -0
- package/docs/template/edx/tmpl/example.tmpl +2 -0
- package/docs/template/edx/tmpl/examples.tmpl +13 -0
- package/docs/template/edx/tmpl/exceptions.tmpl +32 -0
- package/docs/template/edx/tmpl/layout.tmpl +39 -0
- package/docs/template/edx/tmpl/mainpage.tmpl +10 -0
- package/docs/template/edx/tmpl/members.tmpl +38 -0
- package/docs/template/edx/tmpl/method.tmpl +131 -0
- package/docs/template/edx/tmpl/modifies.tmpl +14 -0
- package/docs/template/edx/tmpl/params.tmpl +131 -0
- package/docs/template/edx/tmpl/properties.tmpl +108 -0
- package/docs/template/edx/tmpl/returns.tmpl +19 -0
- package/docs/template/edx/tmpl/source.tmpl +8 -0
- package/docs/template/edx/tmpl/tutorial.tmpl +19 -0
- package/docs/template/edx/tmpl/type.tmpl +7 -0
- package/env.config.js +8 -0
- package/jsdoc.json +36 -0
- package/openedx.yaml +12 -0
- package/package.json +6 -6
- package/service-interface.png +0 -0
- package/src/analytics/MockAnalyticsService.js +71 -0
- package/src/analytics/SegmentAnalyticsService.js +243 -0
- package/src/analytics/index.js +12 -0
- package/src/analytics/interface.js +142 -0
- package/src/auth/AxiosCsrfTokenService.js +60 -0
- package/src/auth/AxiosJwtAuthService.js +364 -0
- package/src/auth/AxiosJwtTokenService.js +134 -0
- package/src/auth/LocalForageCache.js +78 -0
- package/src/auth/MockAuthService.js +285 -0
- package/src/auth/index.js +19 -0
- package/src/auth/interceptors/createCsrfTokenProviderInterceptor.js +37 -0
- package/src/auth/interceptors/createJwtTokenProviderInterceptor.js +38 -0
- package/src/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +20 -0
- package/src/auth/interceptors/createRetryInterceptor.js +72 -0
- package/src/auth/interface.js +309 -0
- package/src/auth/utils.js +105 -0
- package/src/config.js +327 -0
- package/src/constants.js +66 -0
- package/src/i18n/countries.js +57 -0
- package/src/i18n/index.js +123 -0
- package/src/i18n/injectIntlWithShim.jsx +45 -0
- package/src/i18n/languages.js +60 -0
- package/src/i18n/lib.js +282 -0
- package/src/i18n/scripts/README.md +29 -0
- package/src/i18n/scripts/intl-imports.js +259 -0
- package/src/i18n/scripts/transifex-utils.js +75 -0
- package/src/index.js +42 -0
- package/src/initialize.js +357 -0
- package/src/logging/MockLoggingService.js +31 -0
- package/src/logging/NewRelicLoggingService.js +181 -0
- package/src/logging/index.js +9 -0
- package/src/logging/interface.js +110 -0
- package/src/pubSub.js +47 -0
- package/src/react/AppContext.jsx +24 -0
- package/src/react/AppProvider.jsx +93 -0
- package/src/react/AuthenticatedPageRoute.jsx +60 -0
- package/src/react/ErrorBoundary.jsx +44 -0
- package/src/react/ErrorPage.jsx +76 -0
- package/src/react/LoginRedirect.jsx +16 -0
- package/src/react/OptionalReduxProvider.jsx +28 -0
- package/src/react/PageRoute.jsx +31 -0
- package/src/react/hooks.js +50 -0
- package/src/react/index.js +16 -0
- package/src/scripts/GoogleAnalyticsLoader.js +53 -0
- package/src/scripts/index.js +2 -0
- package/src/testing/index.js +9 -0
- package/src/testing/initializeMockApp.js +77 -0
- package/src/testing/mockMessages.js +21 -0
- package/src/utils.js +167 -0
- /package/{analytics → dist/analytics}/MockAnalyticsService.js +0 -0
- /package/{analytics → dist/analytics}/MockAnalyticsService.js.map +0 -0
- /package/{analytics → dist/analytics}/SegmentAnalyticsService.js +0 -0
- /package/{analytics → dist/analytics}/SegmentAnalyticsService.js.map +0 -0
- /package/{analytics → dist/analytics}/index.js +0 -0
- /package/{analytics → dist/analytics}/index.js.map +0 -0
- /package/{analytics → dist/analytics}/interface.js +0 -0
- /package/{analytics → dist/analytics}/interface.js.map +0 -0
- /package/{auth → dist/auth}/AxiosCsrfTokenService.js +0 -0
- /package/{auth → dist/auth}/AxiosCsrfTokenService.js.map +0 -0
- /package/{auth → dist/auth}/AxiosJwtAuthService.js +0 -0
- /package/{auth → dist/auth}/AxiosJwtAuthService.js.map +0 -0
- /package/{auth → dist/auth}/AxiosJwtTokenService.js +0 -0
- /package/{auth → dist/auth}/AxiosJwtTokenService.js.map +0 -0
- /package/{auth → dist/auth}/LocalForageCache.js +0 -0
- /package/{auth → dist/auth}/LocalForageCache.js.map +0 -0
- /package/{auth → dist/auth}/MockAuthService.js +0 -0
- /package/{auth → dist/auth}/MockAuthService.js.map +0 -0
- /package/{auth → dist/auth}/index.js +0 -0
- /package/{auth → dist/auth}/index.js.map +0 -0
- /package/{auth → dist/auth}/interceptors/createCsrfTokenProviderInterceptor.js +0 -0
- /package/{auth → dist/auth}/interceptors/createCsrfTokenProviderInterceptor.js.map +0 -0
- /package/{auth → dist/auth}/interceptors/createJwtTokenProviderInterceptor.js +0 -0
- /package/{auth → dist/auth}/interceptors/createJwtTokenProviderInterceptor.js.map +0 -0
- /package/{auth → dist/auth}/interceptors/createProcessAxiosRequestErrorInterceptor.js +0 -0
- /package/{auth → dist/auth}/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +0 -0
- /package/{auth → dist/auth}/interceptors/createRetryInterceptor.js +0 -0
- /package/{auth → dist/auth}/interceptors/createRetryInterceptor.js.map +0 -0
- /package/{auth → dist/auth}/interface.js +0 -0
- /package/{auth → dist/auth}/interface.js.map +0 -0
- /package/{auth → dist/auth}/utils.js +0 -0
- /package/{auth → dist/auth}/utils.js.map +0 -0
- /package/{config.js → dist/config.js} +0 -0
- /package/{config.js.map → dist/config.js.map} +0 -0
- /package/{constants.js → dist/constants.js} +0 -0
- /package/{constants.js.map → dist/constants.js.map} +0 -0
- /package/{i18n → dist/i18n}/countries.js +0 -0
- /package/{i18n → dist/i18n}/countries.js.map +0 -0
- /package/{i18n → dist/i18n}/index.js +0 -0
- /package/{i18n → dist/i18n}/index.js.map +0 -0
- /package/{i18n → dist/i18n}/injectIntlWithShim.js +0 -0
- /package/{i18n → dist/i18n}/injectIntlWithShim.js.map +0 -0
- /package/{i18n → dist/i18n}/languages.js +0 -0
- /package/{i18n → dist/i18n}/languages.js.map +0 -0
- /package/{i18n → dist/i18n}/lib.js +0 -0
- /package/{i18n → dist/i18n}/lib.js.map +0 -0
- /package/{i18n → dist/i18n}/scripts/README.md +0 -0
- /package/{i18n → dist/i18n}/scripts/intl-imports.js +0 -0
- /package/{i18n → dist/i18n}/scripts/intl-imports.js.map +0 -0
- /package/{i18n → dist/i18n}/scripts/transifex-utils.js +0 -0
- /package/{i18n → dist/i18n}/scripts/transifex-utils.js.map +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{index.js.map → dist/index.js.map} +0 -0
- /package/{initialize.js → dist/initialize.js} +0 -0
- /package/{initialize.js.map → dist/initialize.js.map} +0 -0
- /package/{logging → dist/logging}/MockLoggingService.js +0 -0
- /package/{logging → dist/logging}/MockLoggingService.js.map +0 -0
- /package/{logging → dist/logging}/NewRelicLoggingService.js +0 -0
- /package/{logging → dist/logging}/NewRelicLoggingService.js.map +0 -0
- /package/{logging → dist/logging}/index.js +0 -0
- /package/{logging → dist/logging}/index.js.map +0 -0
- /package/{logging → dist/logging}/interface.js +0 -0
- /package/{logging → dist/logging}/interface.js.map +0 -0
- /package/{pubSub.js → dist/pubSub.js} +0 -0
- /package/{pubSub.js.map → dist/pubSub.js.map} +0 -0
- /package/{react → dist/react}/AppContext.js +0 -0
- /package/{react → dist/react}/AppContext.js.map +0 -0
- /package/{react → dist/react}/AppProvider.js +0 -0
- /package/{react → dist/react}/AppProvider.js.map +0 -0
- /package/{react → dist/react}/AuthenticatedPageRoute.js +0 -0
- /package/{react → dist/react}/AuthenticatedPageRoute.js.map +0 -0
- /package/{react → dist/react}/ErrorBoundary.js +0 -0
- /package/{react → dist/react}/ErrorBoundary.js.map +0 -0
- /package/{react → dist/react}/ErrorPage.js +0 -0
- /package/{react → dist/react}/ErrorPage.js.map +0 -0
- /package/{react → dist/react}/LoginRedirect.js +0 -0
- /package/{react → dist/react}/LoginRedirect.js.map +0 -0
- /package/{react → dist/react}/OptionalReduxProvider.js +0 -0
- /package/{react → dist/react}/OptionalReduxProvider.js.map +0 -0
- /package/{react → dist/react}/PageRoute.js +0 -0
- /package/{react → dist/react}/PageRoute.js.map +0 -0
- /package/{react → dist/react}/hooks.js +0 -0
- /package/{react → dist/react}/hooks.js.map +0 -0
- /package/{react → dist/react}/index.js +0 -0
- /package/{react → dist/react}/index.js.map +0 -0
- /package/{scripts → dist/scripts}/GoogleAnalyticsLoader.js +0 -0
- /package/{scripts → dist/scripts}/GoogleAnalyticsLoader.js.map +0 -0
- /package/{scripts → dist/scripts}/index.js +0 -0
- /package/{scripts → dist/scripts}/index.js.map +0 -0
- /package/{testing → dist/testing}/index.js +0 -0
- /package/{testing → dist/testing}/index.js.map +0 -0
- /package/{testing → dist/testing}/initializeMockApp.js +0 -0
- /package/{testing → dist/testing}/initializeMockApp.js.map +0 -0
- /package/{testing → dist/testing}/mockMessages.js +0 -0
- /package/{testing → dist/testing}/mockMessages.js.map +0 -0
- /package/{utils.js → dist/utils.js} +0 -0
- /package/{utils.js.map → dist/utils.js.map} +0 -0
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
const doop = require('jsdoc/util/doop');
|
|
2
|
+
const env = require('jsdoc/env');
|
|
3
|
+
const fs = require('jsdoc/fs');
|
|
4
|
+
const helper = require('jsdoc/util/templateHelper');
|
|
5
|
+
const logger = require('jsdoc/util/logger');
|
|
6
|
+
const path = require('jsdoc/path');
|
|
7
|
+
const template = require('jsdoc/template');
|
|
8
|
+
const util = require('util');
|
|
9
|
+
|
|
10
|
+
const htmlsafe = helper.htmlsafe;
|
|
11
|
+
const linkto = helper.linkto;
|
|
12
|
+
const resolveAuthorLinks = helper.resolveAuthorLinks;
|
|
13
|
+
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
|
|
15
|
+
let data;
|
|
16
|
+
let view;
|
|
17
|
+
|
|
18
|
+
let outdir = path.normalize(env.opts.destination);
|
|
19
|
+
|
|
20
|
+
function find(spec) {
|
|
21
|
+
return helper.find(data, spec);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function tutoriallink(tutorial) {
|
|
25
|
+
return helper.toTutorial(tutorial, null, {
|
|
26
|
+
tag: 'em',
|
|
27
|
+
classname: 'disabled',
|
|
28
|
+
prefix: 'Tutorial: '
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getAncestorLinks(doclet) {
|
|
33
|
+
return helper.getAncestorLinks(data, doclet);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function hashToLink(doclet, hash) {
|
|
37
|
+
let url;
|
|
38
|
+
|
|
39
|
+
if ( !/^(#.+)/.test(hash) ) {
|
|
40
|
+
return hash;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
url = helper.createLink(doclet);
|
|
44
|
+
url = url.replace(/(#.+|$)/, hash);
|
|
45
|
+
|
|
46
|
+
return `<a href="${url}">${hash}</a>`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function needsSignature({kind, type, meta}) {
|
|
50
|
+
let needsSig = false;
|
|
51
|
+
|
|
52
|
+
// function and class definitions always get a signature
|
|
53
|
+
if (kind === 'function' || kind === 'class') {
|
|
54
|
+
needsSig = true;
|
|
55
|
+
}
|
|
56
|
+
// typedefs that contain functions get a signature, too
|
|
57
|
+
else if (kind === 'typedef' && type && type.names &&
|
|
58
|
+
type.names.length) {
|
|
59
|
+
for (let i = 0, l = type.names.length; i < l; i++) {
|
|
60
|
+
if (type.names[i].toLowerCase() === 'function') {
|
|
61
|
+
needsSig = true;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// and namespaces that are functions get a signature (but finding them is a
|
|
67
|
+
// bit messy)
|
|
68
|
+
else if (kind === 'namespace' && meta && meta.code &&
|
|
69
|
+
meta.code.type && meta.code.type.match(/[Ff]unction/)) {
|
|
70
|
+
needsSig = true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return needsSig;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function getSignatureAttributes({optional, nullable}) {
|
|
77
|
+
const attributes = [];
|
|
78
|
+
|
|
79
|
+
if (optional) {
|
|
80
|
+
attributes.push('opt');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (nullable === true) {
|
|
84
|
+
attributes.push('nullable');
|
|
85
|
+
}
|
|
86
|
+
else if (nullable === false) {
|
|
87
|
+
attributes.push('non-null');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return attributes;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function updateItemName(item) {
|
|
94
|
+
const attributes = getSignatureAttributes(item);
|
|
95
|
+
let itemName = item.name || '';
|
|
96
|
+
|
|
97
|
+
if (item.variable) {
|
|
98
|
+
itemName = `…${itemName}`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (attributes && attributes.length) {
|
|
102
|
+
itemName = util.format( '%s<span class="signature-attributes">%s</span>', itemName,
|
|
103
|
+
attributes.join(', ') );
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return itemName;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function addParamAttributes(params) {
|
|
110
|
+
return params.filter(({name}) => name && !name.includes('.')).map(updateItemName);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function buildItemTypeStrings(item) {
|
|
114
|
+
const types = [];
|
|
115
|
+
|
|
116
|
+
if (item && item.type && item.type.names) {
|
|
117
|
+
item.type.names.forEach(name => {
|
|
118
|
+
types.push( linkto(name, htmlsafe(name)) );
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return types;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function buildAttribsString(attribs) {
|
|
126
|
+
let attribsString = '';
|
|
127
|
+
|
|
128
|
+
if (attribs && attribs.length) {
|
|
129
|
+
attribsString = htmlsafe( util.format('(%s) ', attribs.join(', ')) );
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return attribsString;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function addNonParamAttributes(items) {
|
|
136
|
+
let types = [];
|
|
137
|
+
|
|
138
|
+
items.forEach(item => {
|
|
139
|
+
types = types.concat( buildItemTypeStrings(item) );
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return types;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function addSignatureParams(f) {
|
|
146
|
+
const params = f.params ? addParamAttributes(f.params) : [];
|
|
147
|
+
|
|
148
|
+
f.signature = util.format( '%s(%s)', (f.signature || ''), params.join(', ') );
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function addSignatureReturns(f) {
|
|
152
|
+
const attribs = [];
|
|
153
|
+
let attribsString = '';
|
|
154
|
+
let returnTypes = [];
|
|
155
|
+
let returnTypesString = '';
|
|
156
|
+
const source = f.yields || f.returns;
|
|
157
|
+
|
|
158
|
+
// jam all the return-type attributes into an array. this could create odd results (for example,
|
|
159
|
+
// if there are both nullable and non-nullable return types), but let's assume that most people
|
|
160
|
+
// who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa.
|
|
161
|
+
if (source) {
|
|
162
|
+
source.forEach(item => {
|
|
163
|
+
helper.getAttribs(item).forEach(attrib => {
|
|
164
|
+
if (!attribs.includes(attrib)) {
|
|
165
|
+
attribs.push(attrib);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
attribsString = buildAttribsString(attribs);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (source) {
|
|
174
|
+
returnTypes = addNonParamAttributes(source);
|
|
175
|
+
}
|
|
176
|
+
if (returnTypes.length) {
|
|
177
|
+
returnTypesString = util.format( ' → %s{%s}', attribsString, returnTypes.join('|') );
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
f.signature = `<span class="signature">${f.signature || ''}</span><span class="type-signature">${returnTypesString}</span>`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function addSignatureTypes(f) {
|
|
184
|
+
const types = f.type ? buildItemTypeStrings(f) : [];
|
|
185
|
+
|
|
186
|
+
f.signature = `${f.signature || ''}<span class="type-signature">${types.length ? ` :${types.join('|')}` : ''}</span>`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function addAttribs(f) {
|
|
190
|
+
const attribs = helper.getAttribs(f);
|
|
191
|
+
const attribsString = buildAttribsString(attribs);
|
|
192
|
+
|
|
193
|
+
f.attribs = util.format('<span class="type-signature">%s</span>', attribsString);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function shortenPaths(files, commonPrefix) {
|
|
197
|
+
Object.keys(files).forEach(file => {
|
|
198
|
+
files[file].shortened = files[file].resolved.replace(commonPrefix, '')
|
|
199
|
+
// always use forward slashes
|
|
200
|
+
.replace(/\\/g, '/');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
return files;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function getPathFromDoclet({meta}) {
|
|
207
|
+
if (!meta) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return meta.path && meta.path !== 'null' ?
|
|
212
|
+
path.join(meta.path, meta.filename) :
|
|
213
|
+
meta.filename;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function generate(title, docs, filename, { resolveLinks = false, moduleName = '' } = {}) {
|
|
217
|
+
let docData;
|
|
218
|
+
let html;
|
|
219
|
+
let outpath;
|
|
220
|
+
resolveLinks = resolveLinks !== false;
|
|
221
|
+
|
|
222
|
+
docData = {
|
|
223
|
+
env: env,
|
|
224
|
+
title: title,
|
|
225
|
+
docs: docs,
|
|
226
|
+
moduleName,
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
outpath = path.join(outdir, filename);
|
|
230
|
+
html = view.render('container.tmpl', docData);
|
|
231
|
+
|
|
232
|
+
if (resolveLinks) {
|
|
233
|
+
html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
fs.writeFileSync(outpath, html, 'utf8');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function generateSourceFiles(sourceFiles, encoding = 'utf8') {
|
|
240
|
+
Object.keys(sourceFiles).forEach(file => {
|
|
241
|
+
let source;
|
|
242
|
+
// links are keyed to the shortened path in each doclet's `meta.shortpath` property
|
|
243
|
+
const sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
|
|
244
|
+
|
|
245
|
+
helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
source = {
|
|
249
|
+
kind: 'source',
|
|
250
|
+
code: helper.htmlsafe( fs.readFileSync(sourceFiles[file].resolved, encoding) )
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
catch (e) {
|
|
254
|
+
logger.error('Error while generating source file %s: %s', file, e.message);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
generate(`Source: ${sourceFiles[file].shortened}`, [source], sourceOutfile);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Look for classes or functions with the same name as modules (which indicates that the module
|
|
263
|
+
* exports only that class or function), then attach the classes or functions to the `module`
|
|
264
|
+
* property of the appropriate module doclets. The name of each class or function is also updated
|
|
265
|
+
* for display purposes. This function mutates the original arrays.
|
|
266
|
+
*
|
|
267
|
+
* @private
|
|
268
|
+
* @param {Array.<module:jsdoc/doclet.Doclet>} doclets - The array of classes and functions to
|
|
269
|
+
* check.
|
|
270
|
+
* @param {Array.<module:jsdoc/doclet.Doclet>} modules - The array of module doclets to search.
|
|
271
|
+
*/
|
|
272
|
+
function attachModuleSymbols(doclets, modules) {
|
|
273
|
+
const symbols = {};
|
|
274
|
+
|
|
275
|
+
// build a lookup table
|
|
276
|
+
doclets.forEach(symbol => {
|
|
277
|
+
symbols[symbol.longname] = symbols[symbol.longname] || [];
|
|
278
|
+
symbols[symbol.longname].push(symbol);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
modules.forEach(module => {
|
|
282
|
+
if (symbols[module.longname]) {
|
|
283
|
+
module.modules = symbols[module.longname]
|
|
284
|
+
// Only show symbols that have a description. Make an exception for classes, because
|
|
285
|
+
// we want to show the constructor-signature heading no matter what.
|
|
286
|
+
.filter(({description, kind}) => description || kind === 'class')
|
|
287
|
+
.map(symbol => {
|
|
288
|
+
symbol = doop(symbol);
|
|
289
|
+
|
|
290
|
+
if (symbol.kind === 'class' || symbol.kind === 'function') {
|
|
291
|
+
symbol.name = `${symbol.name.replace('module:', '(require("')}"))`;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return symbol;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function buildMemberNav(items, itemHeading, itemsSeen, linktoFn) {
|
|
301
|
+
let nav = '';
|
|
302
|
+
|
|
303
|
+
const renderSubNav = (doclets => {
|
|
304
|
+
if (!doclets || !doclets.length) return '';
|
|
305
|
+
|
|
306
|
+
const renderChild = (doclet) => {
|
|
307
|
+
return `<li>${linktoFn(doclet.longname, doclet.name)}</li>`;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return `
|
|
311
|
+
<ul class="list-unstyled px-3 pb-4 bg-light">
|
|
312
|
+
${doclets.map(renderChild).join('')}
|
|
313
|
+
</ul>
|
|
314
|
+
`;
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
if (items.length) {
|
|
318
|
+
let itemsNav = '';
|
|
319
|
+
|
|
320
|
+
items.forEach(item => {
|
|
321
|
+
let displayName;
|
|
322
|
+
|
|
323
|
+
if ( !hasOwnProp.call(item, 'longname') ) {
|
|
324
|
+
itemsNav += `<li class="nav-item">${linktoFn('', item.name, 'nav-link')}</li>`;
|
|
325
|
+
}
|
|
326
|
+
else if ( !hasOwnProp.call(itemsSeen, item.longname) ) {
|
|
327
|
+
if (env.conf.templates.default.useLongnameInNav) {
|
|
328
|
+
displayName = item.longname;
|
|
329
|
+
} else {
|
|
330
|
+
displayName = item.name;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
itemsNav += `<li class="module-section nav-item ${displayName}">
|
|
334
|
+
${linktoFn(item.longname, displayName.replace(/\b(module|event):/g), 'nav-link font-weight-bold')}
|
|
335
|
+
${renderSubNav(item.children)}
|
|
336
|
+
</li>`;
|
|
337
|
+
|
|
338
|
+
itemsSeen[item.longname] = true;
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
if (itemsNav !== '') {
|
|
343
|
+
nav += `<ul class="list-unstyled nav flex-column">${itemsNav}</ul>`;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
return nav;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function linktoTutorial(longName, name) {
|
|
351
|
+
return tutoriallink(name);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function linktoExternal(longName, name) {
|
|
355
|
+
return linkto(longName, name.replace(/(^"|"$)/g, ''));
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Create the navigation sidebar.
|
|
360
|
+
* @param {object} members The members that will be used to create the sidebar.
|
|
361
|
+
* @param {array<object>} members.classes
|
|
362
|
+
* @param {array<object>} members.externals
|
|
363
|
+
* @param {array<object>} members.globals
|
|
364
|
+
* @param {array<object>} members.mixins
|
|
365
|
+
* @param {array<object>} members.modules
|
|
366
|
+
* @param {array<object>} members.namespaces
|
|
367
|
+
* @param {array<object>} members.tutorials
|
|
368
|
+
* @param {array<object>} members.events
|
|
369
|
+
* @param {array<object>} members.interfaces
|
|
370
|
+
* @return {string} The HTML for the navigation sidebar.
|
|
371
|
+
*/
|
|
372
|
+
function buildNav(members) {
|
|
373
|
+
let globalNav;
|
|
374
|
+
let nav = '<h2><a href="index.html">Home</a></h2>';
|
|
375
|
+
const seen = {};
|
|
376
|
+
const seenTutorials = {};
|
|
377
|
+
|
|
378
|
+
nav += buildMemberNav(members.modules, 'Modules', {}, linkto);
|
|
379
|
+
// nav += buildMemberNav(members.externals, 'Externals', seen, linktoExternal);
|
|
380
|
+
// nav += buildMemberNav(members.namespaces, 'Namespaces', seen, linkto);
|
|
381
|
+
// nav += buildMemberNav(members.classes, 'Classes', seen, linkto);
|
|
382
|
+
// nav += buildMemberNav(members.interfaces, 'Interfaces', seen, linkto);
|
|
383
|
+
// nav += buildMemberNav(members.events, 'Events', seen, linkto);
|
|
384
|
+
// nav += buildMemberNav(members.mixins, 'Mixins', seen, linkto);
|
|
385
|
+
// nav += buildMemberNav(members.tutorials, 'Tutorials', seenTutorials, linktoTutorial);
|
|
386
|
+
|
|
387
|
+
// if (members.globals.length) {
|
|
388
|
+
// globalNav = '';
|
|
389
|
+
|
|
390
|
+
// members.globals.forEach(({kind, longname, name}) => {
|
|
391
|
+
// if ( kind !== 'typedef' && !hasOwnProp.call(seen, longname) ) {
|
|
392
|
+
// globalNav += `<li>${linkto(longname, name)}</li>`;
|
|
393
|
+
// }
|
|
394
|
+
// seen[longname] = true;
|
|
395
|
+
// });
|
|
396
|
+
|
|
397
|
+
// if (!globalNav) {
|
|
398
|
+
// // turn the heading into a link so you can actually get to the global page
|
|
399
|
+
// nav += `<h3>${linkto('global', 'Global')}</h3>`;
|
|
400
|
+
// }
|
|
401
|
+
// else {
|
|
402
|
+
// nav += `<h3>Global</h3><ul>${globalNav}</ul>`;
|
|
403
|
+
// }
|
|
404
|
+
// }
|
|
405
|
+
|
|
406
|
+
return nav;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
@param {object} memberData
|
|
411
|
+
@param {object} opts
|
|
412
|
+
@param {Tutorial} tutorials
|
|
413
|
+
*/
|
|
414
|
+
exports.publish = (memberData, opts, tutorials) => {
|
|
415
|
+
let classes;
|
|
416
|
+
let conf;
|
|
417
|
+
let externals;
|
|
418
|
+
let files;
|
|
419
|
+
let fromDir;
|
|
420
|
+
let globalUrl;
|
|
421
|
+
let indexUrl;
|
|
422
|
+
let interfaces;
|
|
423
|
+
let members;
|
|
424
|
+
let mixins;
|
|
425
|
+
let modules;
|
|
426
|
+
let namespaces;
|
|
427
|
+
let outputSourceFiles;
|
|
428
|
+
let packageInfo;
|
|
429
|
+
let packages;
|
|
430
|
+
const sourceFilePaths = [];
|
|
431
|
+
let sourceFiles = {};
|
|
432
|
+
let staticFileFilter;
|
|
433
|
+
let staticFilePaths;
|
|
434
|
+
let staticFiles;
|
|
435
|
+
let staticFileScanner;
|
|
436
|
+
let templatePath;
|
|
437
|
+
|
|
438
|
+
data = memberData;
|
|
439
|
+
|
|
440
|
+
conf = env.conf.templates || {};
|
|
441
|
+
conf.default = conf.default || {};
|
|
442
|
+
|
|
443
|
+
templatePath = path.normalize(opts.template);
|
|
444
|
+
view = new template.Template( path.join(templatePath, 'tmpl') );
|
|
445
|
+
|
|
446
|
+
// claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
|
|
447
|
+
// doesn't try to hand them out later
|
|
448
|
+
indexUrl = helper.getUniqueFilename('index');
|
|
449
|
+
// don't call registerLink() on this one! 'index' is also a valid longname
|
|
450
|
+
|
|
451
|
+
globalUrl = helper.getUniqueFilename('global');
|
|
452
|
+
helper.registerLink('global', globalUrl);
|
|
453
|
+
|
|
454
|
+
// set up templating
|
|
455
|
+
view.layout = conf.default.layoutFile ?
|
|
456
|
+
path.getResourcePath(path.dirname(conf.default.layoutFile),
|
|
457
|
+
path.basename(conf.default.layoutFile) ) :
|
|
458
|
+
'layout.tmpl';
|
|
459
|
+
|
|
460
|
+
// set up tutorials for helper
|
|
461
|
+
helper.setTutorials(tutorials);
|
|
462
|
+
|
|
463
|
+
data = helper.prune(data);
|
|
464
|
+
data.sort('longname, version, since');
|
|
465
|
+
helper.addEventListeners(data);
|
|
466
|
+
|
|
467
|
+
data().each(doclet => {
|
|
468
|
+
let sourcePath;
|
|
469
|
+
|
|
470
|
+
doclet.attribs = '';
|
|
471
|
+
|
|
472
|
+
if (doclet.examples) {
|
|
473
|
+
doclet.examples = doclet.examples.map(example => {
|
|
474
|
+
let caption;
|
|
475
|
+
let code;
|
|
476
|
+
|
|
477
|
+
if (example.match(/^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) {
|
|
478
|
+
caption = RegExp.$1;
|
|
479
|
+
code = RegExp.$3;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return {
|
|
483
|
+
caption: caption || '',
|
|
484
|
+
code: code || example
|
|
485
|
+
};
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
if (doclet.see) {
|
|
489
|
+
doclet.see.forEach((seeItem, i) => {
|
|
490
|
+
doclet.see[i] = hashToLink(doclet, seeItem);
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// build a list of source files
|
|
495
|
+
if (doclet.meta) {
|
|
496
|
+
sourcePath = getPathFromDoclet(doclet);
|
|
497
|
+
sourceFiles[sourcePath] = {
|
|
498
|
+
resolved: sourcePath,
|
|
499
|
+
shortened: null
|
|
500
|
+
};
|
|
501
|
+
if (!sourceFilePaths.includes(sourcePath)) {
|
|
502
|
+
sourceFilePaths.push(sourcePath);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
// update outdir if necessary, then create outdir
|
|
508
|
+
packageInfo = ( find({kind: 'package'}) || [] )[0];
|
|
509
|
+
if (packageInfo && packageInfo.name) {
|
|
510
|
+
outdir = path.join( outdir, packageInfo.name, (packageInfo.version || '') );
|
|
511
|
+
}
|
|
512
|
+
fs.mkPath(outdir);
|
|
513
|
+
|
|
514
|
+
// copy the template's static files to outdir
|
|
515
|
+
fromDir = path.join(templatePath, 'static');
|
|
516
|
+
staticFiles = fs.ls(fromDir, 3);
|
|
517
|
+
|
|
518
|
+
staticFiles.forEach(fileName => {
|
|
519
|
+
const toDir = fs.toDir( fileName.replace(fromDir, outdir) );
|
|
520
|
+
|
|
521
|
+
fs.mkPath(toDir);
|
|
522
|
+
fs.copyFileSync(fileName, toDir);
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// copy user-specified static files to outdir
|
|
526
|
+
if (conf.default.staticFiles) {
|
|
527
|
+
// The canonical property name is `include`. We accept `paths` for backwards compatibility
|
|
528
|
+
// with a bug in JSDoc 3.2.x.
|
|
529
|
+
staticFilePaths = conf.default.staticFiles.include ||
|
|
530
|
+
conf.default.staticFiles.paths ||
|
|
531
|
+
[];
|
|
532
|
+
staticFileFilter = new (require('jsdoc/src/filter').Filter)(conf.default.staticFiles);
|
|
533
|
+
staticFileScanner = new (require('jsdoc/src/scanner').Scanner)();
|
|
534
|
+
|
|
535
|
+
staticFilePaths.forEach(filePath => {
|
|
536
|
+
let extraStaticFiles;
|
|
537
|
+
|
|
538
|
+
filePath = path.resolve(env.pwd, filePath);
|
|
539
|
+
extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter);
|
|
540
|
+
|
|
541
|
+
extraStaticFiles.forEach(fileName => {
|
|
542
|
+
const sourcePath = fs.toDir(filePath);
|
|
543
|
+
const toDir = fs.toDir( fileName.replace(sourcePath, outdir) );
|
|
544
|
+
|
|
545
|
+
fs.mkPath(toDir);
|
|
546
|
+
fs.copyFileSync(fileName, toDir);
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (sourceFilePaths.length) {
|
|
552
|
+
sourceFiles = shortenPaths( sourceFiles, path.commonPrefix(sourceFilePaths) );
|
|
553
|
+
}
|
|
554
|
+
data().each(doclet => {
|
|
555
|
+
let docletPath;
|
|
556
|
+
const url = helper.createLink(doclet);
|
|
557
|
+
|
|
558
|
+
helper.registerLink(doclet.longname, url);
|
|
559
|
+
|
|
560
|
+
// add a shortened version of the full path
|
|
561
|
+
if (doclet.meta) {
|
|
562
|
+
docletPath = getPathFromDoclet(doclet);
|
|
563
|
+
docletPath = sourceFiles[docletPath].shortened;
|
|
564
|
+
if (docletPath) {
|
|
565
|
+
doclet.meta.shortpath = docletPath;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
data().each(doclet => {
|
|
571
|
+
const url = helper.longnameToUrl[doclet.longname];
|
|
572
|
+
|
|
573
|
+
if (url.includes('#')) {
|
|
574
|
+
doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
doclet.id = doclet.name;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if ( needsSignature(doclet) ) {
|
|
581
|
+
addSignatureParams(doclet);
|
|
582
|
+
addSignatureReturns(doclet);
|
|
583
|
+
addAttribs(doclet);
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
// do this after the urls have all been generated
|
|
588
|
+
data().each(doclet => {
|
|
589
|
+
doclet.ancestors = getAncestorLinks(doclet);
|
|
590
|
+
|
|
591
|
+
if (doclet.kind === 'member') {
|
|
592
|
+
addSignatureTypes(doclet);
|
|
593
|
+
addAttribs(doclet);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if (doclet.kind === 'constant') {
|
|
597
|
+
addSignatureTypes(doclet);
|
|
598
|
+
addAttribs(doclet);
|
|
599
|
+
doclet.kind = 'member';
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
members = helper.getMembers(data);
|
|
604
|
+
|
|
605
|
+
members.modules = members.modules.map(module => {
|
|
606
|
+
module.children = data({ memberof: `module:${module.name}`}).get();
|
|
607
|
+
return module;
|
|
608
|
+
})
|
|
609
|
+
|
|
610
|
+
members.tutorials = tutorials.children;
|
|
611
|
+
|
|
612
|
+
// output pretty-printed source files by default
|
|
613
|
+
outputSourceFiles = conf.default && conf.default.outputSourceFiles !== false;
|
|
614
|
+
|
|
615
|
+
// add template helpers
|
|
616
|
+
view.find = find;
|
|
617
|
+
view.linkto = linkto;
|
|
618
|
+
view.resolveAuthorLinks = resolveAuthorLinks;
|
|
619
|
+
view.tutoriallink = tutoriallink;
|
|
620
|
+
view.htmlsafe = htmlsafe;
|
|
621
|
+
view.outputSourceFiles = outputSourceFiles;
|
|
622
|
+
|
|
623
|
+
// once for all
|
|
624
|
+
view.nav = buildNav(members);
|
|
625
|
+
attachModuleSymbols( find({ longname: {left: 'module:'} }), members.modules );
|
|
626
|
+
|
|
627
|
+
// generate the pretty-printed source files first so other pages can link to them
|
|
628
|
+
if (outputSourceFiles) {
|
|
629
|
+
generateSourceFiles(sourceFiles, opts.encoding);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); }
|
|
633
|
+
|
|
634
|
+
// index page displays information from package.json and lists files
|
|
635
|
+
files = find({kind: 'file'});
|
|
636
|
+
packages = find({kind: 'package'});
|
|
637
|
+
|
|
638
|
+
generate('Open edX frontend-platform API Documentation',
|
|
639
|
+
packages.concat(
|
|
640
|
+
[{
|
|
641
|
+
kind: 'mainpage',
|
|
642
|
+
readme: opts.readme,
|
|
643
|
+
longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'
|
|
644
|
+
}]
|
|
645
|
+
).concat(files), indexUrl);
|
|
646
|
+
|
|
647
|
+
Object.keys(helper.longnameToUrl).forEach(longname => {
|
|
648
|
+
const myClasses = members.classes.filter(obj => obj.longname === longname);
|
|
649
|
+
const myExternals = members.externals.filter(obj => obj.longname === longname);
|
|
650
|
+
const myInterfaces = members.interfaces.filter(obj => obj.longname === longname);
|
|
651
|
+
const myMixins = members.mixins.filter(obj => obj.longname === longname);
|
|
652
|
+
const myModules = members.modules.filter(obj => obj.longname === longname);
|
|
653
|
+
const myNamespaces = members.namespaces.filter(obj => obj.longname === longname);
|
|
654
|
+
|
|
655
|
+
const trimModuleName = (moduleName) => {
|
|
656
|
+
if (moduleName.includes('module:')) {
|
|
657
|
+
return moduleName.split(':')[1];
|
|
658
|
+
}
|
|
659
|
+
return moduleName;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (myModules.length) {
|
|
663
|
+
generate(`${myModules[0].name}`, myModules, helper.longnameToUrl[longname], { moduleName: myModules[0].name });
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (myClasses.length) {
|
|
667
|
+
generate(`Class: ${myClasses[0].name}`, myClasses, helper.longnameToUrl[longname], { moduleName: trimModuleName(myClasses[0].memberof) });
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
if (myNamespaces.length) {
|
|
671
|
+
generate(`Namespace: ${myNamespaces[0].name}`, myNamespaces, helper.longnameToUrl[longname], { moduleName: trimModuleName(myNamespaces[0].memberof) });
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if (myMixins.length) {
|
|
675
|
+
generate(`Mixin: ${myMixins[0].name}`, myMixins, helper.longnameToUrl[longname], { moduleName: trimModuleName(myMixins[0].memberof) });
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (myExternals.length) {
|
|
679
|
+
generate(`External: ${myExternals[0].name}`, myExternals, helper.longnameToUrl[longname], { moduleName: trimModuleName(myExternals[0].memberof) });
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
if (myInterfaces.length) {
|
|
683
|
+
generate(`Interface: ${myInterfaces[0].name}`, myInterfaces, helper.longnameToUrl[longname], { moduleName: trimModuleName(myInterfaces[0].memberof) });
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
// TODO: move the tutorial functions to templateHelper.js
|
|
688
|
+
function generateTutorial(title, tutorial, filename) {
|
|
689
|
+
const tutorialData = {
|
|
690
|
+
title: title,
|
|
691
|
+
header: tutorial.title,
|
|
692
|
+
content: tutorial.parse(),
|
|
693
|
+
children: tutorial.children
|
|
694
|
+
};
|
|
695
|
+
const tutorialPath = path.join(outdir, filename);
|
|
696
|
+
let html = view.render('tutorial.tmpl', tutorialData);
|
|
697
|
+
|
|
698
|
+
// yes, you can use {@link} in tutorials too!
|
|
699
|
+
html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
|
|
700
|
+
|
|
701
|
+
fs.writeFileSync(tutorialPath, html, 'utf8');
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// tutorials can have only one parent so there is no risk for loops
|
|
705
|
+
function saveChildren({children}) {
|
|
706
|
+
children.forEach(child => {
|
|
707
|
+
generateTutorial(`Tutorial: ${child.title}`, child, helper.tutorialToUrl(child.name));
|
|
708
|
+
saveChildren(child);
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
saveChildren(tutorials);
|
|
713
|
+
};
|
|
Binary file
|