clean-jsdoc-theme 4.2.0 → 4.2.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/CHANGELOG.md +5 -1
- package/README.md +13 -1
- package/clean-jsdoc-theme-helper.js +27 -13
- package/jsdoc-config.json +6 -1
- package/package.json +2 -1
- package/publish.js +43 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
+
### In version 4.2.0
|
|
4
|
+
|
|
5
|
+
1. Add an option to include files list in homepage. Previously we are including it by default. From now the developer has to explicitly ask for it. For more [see](https:/github.com/ankitskvmdam/clean-jsdoc-theme#add-files-list-in-homepage)
|
|
6
|
+
|
|
3
7
|
### In version 4.0.0
|
|
4
8
|
|
|
5
9
|
This is the most performant version of `clean-jsdoc-theme`. Check
|
|
@@ -253,4 +257,4 @@ In this release we removed this template rule.
|
|
|
253
257
|
1. Fix typescript-eslint camelCase rule
|
|
254
258
|
issue [issue: [#37](https://github.com/ankitskvmdam/clean-jsdoc-theme/issues/37)]
|
|
255
259
|
2. Fix ordered list style [issue: [#40](https://github.com/ankitskvmdam/clean-jsdoc-theme/issues/40)]
|
|
256
|
-
3. Fix code overflow issue.
|
|
260
|
+
3. Fix code overflow issue.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# clean-jsdoc-theme
|
|
2
2
|
|
|
3
|
-
[](https://github.com/ankitskvmdam/clean-jsdoc-theme) [](https://github.com/ankitskvmdam/clean-jsdoc-theme/fork) ](https://github.com/ankitskvmdam/clean-jsdoc-theme) [](https://github.com/ankitskvmdam/clean-jsdoc-theme/fork)  [](https://github.com/ankitskvmdam/clean-jsdoc-theme/issues) [](https://github.com/ankitskvmdam/clean-jsdoc-theme/graphs/contributors) [](https://travis-ci.org/ankitskvmdam/clean-jsdoc-theme) [](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/master/LICENSE)
|
|
4
4
|
<br>
|
|
5
5
|
|
|
6
6
|
`clean-jsdoc-theme` is a beautifully crafted theme for JSDoc 3/JSDoc 4. It is a clean and fully responsive theme with loads of
|
|
@@ -177,6 +177,18 @@ example of this is below:
|
|
|
177
177
|
You can use [`static_dir`](#add-static-dir) option to copy all you static files to output dir and use that path in place
|
|
178
178
|
of `path/to/img`.
|
|
179
179
|
|
|
180
|
+
### Add files list in homepage
|
|
181
|
+
|
|
182
|
+
By default `clean-jsdoc-theme` will not include the list of files in the homepage. If you want to add them the do the following
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
"theme_opts": {
|
|
186
|
+
"includeFilesListInHomepage": true // by default it is false.
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
> Note: You need to add @file tag in the .js if you want to include it in the file list. For more details on `@file` visit: https://jsdoc.app/tags-file.html
|
|
191
|
+
|
|
180
192
|
### Add navbar menu
|
|
181
193
|
|
|
182
194
|
To render extra link(s) in navbar. It accepts an array of objects:
|
|
@@ -1,25 +1,38 @@
|
|
|
1
|
+
const has = require('lodash/has');
|
|
2
|
+
const klawSync = require('klaw-sync');
|
|
1
3
|
const path = require('path')
|
|
2
|
-
const fs = require('fs')
|
|
3
4
|
const fse = require('fs-extra')
|
|
4
5
|
const showdown = require('showdown');
|
|
5
6
|
|
|
6
|
-
|
|
7
7
|
const mdToHTMLConverter = new showdown.Converter();
|
|
8
8
|
|
|
9
|
+
function lsSync(dir, opts = {}) {
|
|
10
|
+
const depth = has(opts, 'depth') ? opts.depth : -1;
|
|
11
|
+
|
|
12
|
+
const files = klawSync(dir, {
|
|
13
|
+
depthLimit: depth,
|
|
14
|
+
filter: (f) => !path.basename(f.path).startsWith('.'),
|
|
15
|
+
nodir: true,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return files.map((f) => f.path);
|
|
19
|
+
};
|
|
20
|
+
|
|
9
21
|
function copyToOutputFolder(filePath, outdir) {
|
|
10
|
-
|
|
22
|
+
const resolvedPath = path.resolve(filePath);
|
|
23
|
+
const filename = path.basename(resolvedPath);
|
|
24
|
+
const out = path.join(outdir, filename);
|
|
11
25
|
|
|
12
|
-
|
|
26
|
+
fse.copyFileSync(resolvedPath, out);
|
|
13
27
|
}
|
|
14
28
|
|
|
15
29
|
function copyToOutputFolderFromArray(filePathArray, outdir) {
|
|
16
|
-
|
|
17
|
-
var outputList = [];
|
|
30
|
+
const outputList = [];
|
|
18
31
|
|
|
19
32
|
if (Array.isArray(filePathArray)) {
|
|
20
|
-
for (
|
|
21
|
-
copyToOutputFolder(
|
|
22
|
-
outputList.push(path.basename(
|
|
33
|
+
for (const filePath of filePathArray) {
|
|
34
|
+
copyToOutputFolder(filePath, outdir);
|
|
35
|
+
outputList.push(path.basename(filePath));
|
|
23
36
|
}
|
|
24
37
|
}
|
|
25
38
|
|
|
@@ -119,13 +132,13 @@ function getBaseURL(themeOpts) {
|
|
|
119
132
|
}
|
|
120
133
|
|
|
121
134
|
function copyStaticFolder(themeOpts, outdir) {
|
|
122
|
-
|
|
135
|
+
const staticDir = themeOpts.static_dir || undefined;
|
|
123
136
|
|
|
124
137
|
if (staticDir) {
|
|
125
|
-
for (
|
|
126
|
-
|
|
138
|
+
for (const dir of staticDir) {
|
|
139
|
+
const output = path.join(outdir, dir);
|
|
127
140
|
|
|
128
|
-
fse.copySync(
|
|
141
|
+
fse.copySync(dir, output);
|
|
129
142
|
}
|
|
130
143
|
}
|
|
131
144
|
}
|
|
@@ -164,4 +177,5 @@ module.exports = {
|
|
|
164
177
|
returnPathOfStyleSrc,
|
|
165
178
|
copyStaticFolder,
|
|
166
179
|
getProcessedYield,
|
|
180
|
+
lsSync
|
|
167
181
|
}
|
package/jsdoc-config.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"allowUnknownTags": true
|
|
4
4
|
},
|
|
5
5
|
"source": {
|
|
6
|
-
"include": ["./demo/src", "./README.md"
|
|
6
|
+
"include": ["./demo/src", "./README.md"]
|
|
7
7
|
},
|
|
8
8
|
"plugins": ["plugins/markdown"],
|
|
9
9
|
"opts": {
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"search": true,
|
|
18
18
|
"homepageTitle": "Clean JSDoc Theme",
|
|
19
19
|
"default_theme": "dark",
|
|
20
|
+
"include_css": ["./demo/src/assets/style.css"],
|
|
21
|
+
"include_js": ["./demo/src/assets/script.js"],
|
|
22
|
+
"static_dir": ["./demo/src/assets/png", "./example"],
|
|
23
|
+
"add_scripts": "function foo(){console.log('foo')} function bar() {console.log('bar')} bar(); foo();",
|
|
24
|
+
"create_style": ".test-create-style{ background: red}",
|
|
20
25
|
"displayModuleHeader": true,
|
|
21
26
|
"title": "clean-jsdoc-theme",
|
|
22
27
|
"footer": "<div style='margin-bottom: 0.5rem;'>clean-jsdoc-theme</div> Fork: <a href='https://github.com/ankitskvmdam/clean-jsdoc-theme'>https://github.com/ankitskvmdam/clean-jsdoc-theme</a>",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clean-jsdoc-theme",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "A beautifully crafted theme/template for JSDoc 3. This theme/template looks and feels like a premium theme/template. This is a fully mobile responsive theme and also fully customizable theme.",
|
|
5
5
|
"main": "publish.js",
|
|
6
6
|
"scripts": {
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"common-path-prefix": "^3.0.0",
|
|
50
50
|
"fs-extra": "^10.1.0",
|
|
51
51
|
"html-minifier": "^4.0.0",
|
|
52
|
+
"klaw-sync": "^6.0.0",
|
|
52
53
|
"lodash": "^4.17.21",
|
|
53
54
|
"nanoid": "^3.3.4",
|
|
54
55
|
"showdown": "^2.1.0"
|
package/publish.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
2
|
const commonPathPrefix = require('common-path-prefix');
|
|
3
3
|
const env = require('jsdoc/env');
|
|
4
|
-
const fs = require('
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
5
|
const helper = require('jsdoc/util/templateHelper');
|
|
6
6
|
const logger = require('jsdoc/util/logger');
|
|
7
7
|
const path = require('jsdoc/path');
|
|
@@ -27,6 +27,7 @@ const {
|
|
|
27
27
|
returnPathOfStyleSrc,
|
|
28
28
|
copyStaticFolder,
|
|
29
29
|
getProcessedYield,
|
|
30
|
+
lsSync,
|
|
30
31
|
} = require('./clean-jsdoc-theme-helper');
|
|
31
32
|
|
|
32
33
|
const {
|
|
@@ -49,10 +50,17 @@ const hasSearch =
|
|
|
49
50
|
themeOpts.search === undefined ? true : Boolean(themeOpts.search);
|
|
50
51
|
|
|
51
52
|
// eslint-disable-next-line no-restricted-globals
|
|
52
|
-
let outdir = path.normalize(env.opts.destination);
|
|
53
|
+
let outdir = path.resolve(path.normalize(env.opts.destination));
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
function mkdirSync(filepath) {
|
|
56
|
+
return fs.mkdirSync(filepath, { recursive: true });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function sourceToDestination(parentDir, sourcePath, destDir) {
|
|
60
|
+
const relativeSource = path.relative(parentDir, sourcePath);
|
|
61
|
+
|
|
62
|
+
return path.resolve(path.join(destDir, relativeSource));
|
|
63
|
+
}
|
|
56
64
|
|
|
57
65
|
function find(spec) {
|
|
58
66
|
return helper.find(data, spec);
|
|
@@ -93,7 +101,7 @@ function needsSignature({ kind, type, meta }) {
|
|
|
93
101
|
|
|
94
102
|
// typedefs that contain functions get a signature, too
|
|
95
103
|
else if (kind === 'typedef' && type && type.names && type.names.length) {
|
|
96
|
-
for (
|
|
104
|
+
for (let i = 0, l = type.names.length; i < l; i++) {
|
|
97
105
|
if (type.names[i].toLowerCase() === 'function') {
|
|
98
106
|
needsSig = true;
|
|
99
107
|
break;
|
|
@@ -171,7 +179,7 @@ function buildAttribsString(attribs) {
|
|
|
171
179
|
let attribsString = '';
|
|
172
180
|
|
|
173
181
|
if (attribs && attribs.length) {
|
|
174
|
-
htmlsafe(`(${attribs.join(', ')}) `);
|
|
182
|
+
attribsString = htmlsafe(`(${attribs.join(', ')}) `);
|
|
175
183
|
}
|
|
176
184
|
|
|
177
185
|
return attribsString;
|
|
@@ -224,7 +232,8 @@ function addSignatureReturns(f) {
|
|
|
224
232
|
)}}`;
|
|
225
233
|
}
|
|
226
234
|
|
|
227
|
-
|
|
235
|
+
|
|
236
|
+
let signatureOutput = '';
|
|
228
237
|
|
|
229
238
|
if (f.signature) {
|
|
230
239
|
signatureOutput =
|
|
@@ -236,6 +245,7 @@ function addSignatureReturns(f) {
|
|
|
236
245
|
}
|
|
237
246
|
|
|
238
247
|
f.signature = signatureOutput;
|
|
248
|
+
|
|
239
249
|
}
|
|
240
250
|
|
|
241
251
|
function addSignatureTypes(f) {
|
|
@@ -401,7 +411,7 @@ function buildSidebarMembers({
|
|
|
401
411
|
children: [],
|
|
402
412
|
};
|
|
403
413
|
|
|
404
|
-
|
|
414
|
+
const methods =
|
|
405
415
|
sectionName === SECTION_TYPE.Tutorials ||
|
|
406
416
|
sectionName === SECTION_TYPE.Global
|
|
407
417
|
? []
|
|
@@ -436,11 +446,11 @@ function buildSidebarMembers({
|
|
|
436
446
|
|
|
437
447
|
currentItem.children.push(itemChild);
|
|
438
448
|
|
|
439
|
-
|
|
449
|
+
let name = method.longname.split(
|
|
440
450
|
method.scope === 'static' ? '.' : '#'
|
|
441
451
|
);
|
|
442
|
-
|
|
443
|
-
|
|
452
|
+
const first = name[0];
|
|
453
|
+
const last = name[1];
|
|
444
454
|
|
|
445
455
|
name = first + ' ▸ ' + last;
|
|
446
456
|
|
|
@@ -502,11 +512,11 @@ function buildNavbar() {
|
|
|
502
512
|
* @return {string} The HTML for the navigation sidebar.
|
|
503
513
|
*/
|
|
504
514
|
function buildSidebar(members) {
|
|
505
|
-
|
|
515
|
+
const title = themeOpts.title || 'Home';
|
|
506
516
|
|
|
507
|
-
|
|
517
|
+
const isHTML = RegExp.prototype.test.bind(/(<([^>]+)>)/i);
|
|
508
518
|
|
|
509
|
-
|
|
519
|
+
const nav = {
|
|
510
520
|
sections: [],
|
|
511
521
|
};
|
|
512
522
|
|
|
@@ -522,13 +532,13 @@ function buildSidebar(members) {
|
|
|
522
532
|
};
|
|
523
533
|
}
|
|
524
534
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
535
|
+
const seen = {};
|
|
536
|
+
const seenTutorials = {};
|
|
537
|
+
const seenGlobal = {};
|
|
528
538
|
|
|
529
|
-
|
|
539
|
+
const sectionsOrder = themeOpts.sections || defaultSections;
|
|
530
540
|
|
|
531
|
-
|
|
541
|
+
const sections = {
|
|
532
542
|
[SECTION_TYPE.Modules]: buildSidebarMembers({
|
|
533
543
|
itemHeading: 'Modules',
|
|
534
544
|
items: members.modules,
|
|
@@ -606,7 +616,7 @@ function buildSidebar(members) {
|
|
|
606
616
|
if (SECTION_TYPE[section] !== undefined) {
|
|
607
617
|
nav.sections.push(sections[section]);
|
|
608
618
|
} else {
|
|
609
|
-
|
|
619
|
+
const errorMsg = `While building nav. Section name: ${section} is not recognized.
|
|
610
620
|
Accepted sections are: ${defaultSections.join(', ')}
|
|
611
621
|
`;
|
|
612
622
|
|
|
@@ -729,17 +739,21 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
729
739
|
if (packageInfo && packageInfo.name) {
|
|
730
740
|
outdir = path.join(outdir, packageInfo.name, packageInfo.version || '');
|
|
731
741
|
}
|
|
732
|
-
|
|
742
|
+
mkdirSync(outdir);
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
// copy external static folders
|
|
746
|
+
copyStaticFolder(themeOpts, outdir);
|
|
733
747
|
|
|
734
748
|
// copy the template's static files to outdir
|
|
735
749
|
fromDir = path.join(templatePath, 'static');
|
|
736
|
-
staticFiles =
|
|
750
|
+
staticFiles = lsSync(fromDir);
|
|
737
751
|
|
|
738
752
|
staticFiles.forEach((fileName) => {
|
|
739
|
-
const
|
|
753
|
+
const toPath = sourceToDestination(fromDir, fileName, outdir);
|
|
740
754
|
|
|
741
|
-
|
|
742
|
-
fs.copyFileSync(fileName,
|
|
755
|
+
mkdirSync(path.dirname(toPath));
|
|
756
|
+
fs.copyFileSync(fileName, toPath);
|
|
743
757
|
});
|
|
744
758
|
|
|
745
759
|
// copy user-specified static files to outdir
|
|
@@ -764,11 +778,10 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
764
778
|
);
|
|
765
779
|
|
|
766
780
|
extraStaticFiles.forEach((fileName) => {
|
|
767
|
-
const
|
|
768
|
-
const toDir = fs.toDir(fileName.replace(sourcePath, outdir));
|
|
781
|
+
const toPath = sourceToDestination(fromDir, fileName, outdir);
|
|
769
782
|
|
|
770
|
-
|
|
771
|
-
fs.copyFileSync(fileName,
|
|
783
|
+
mkdirSync(path.dirname(toPath));
|
|
784
|
+
fs.copyFileSync(fileName, toPath);
|
|
772
785
|
});
|
|
773
786
|
});
|
|
774
787
|
}
|
|
@@ -869,7 +882,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
869
882
|
// added by clean-jsdoc-theme-devs
|
|
870
883
|
// output search file if search
|
|
871
884
|
if (hasSearch) {
|
|
872
|
-
|
|
885
|
+
mkdirSync(path.join(outdir, 'data'));
|
|
873
886
|
fs.writeFileSync(
|
|
874
887
|
path.join(outdir, 'data', 'search.json'),
|
|
875
888
|
JSON.stringify({
|