clean-jsdoc-theme 4.2.0 → 4.2.1

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 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
- [![Stars](https://img.shields.io/github/stars/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme) [![Fork](https://img.shields.io/github/forks/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/fork) ![Version](https://img.shields.io/badge/version-4.2.0-005bff) [![Issues Open](https://img.shields.io/github/issues/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/issues) [![Contributors](https://img.shields.io/github/contributors/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/graphs/contributors) [![Build Status](https://travis-ci.org/ankitskvmdam/clean-jsdoc-theme.svg?branch=production)](https://travis-ci.org/ankitskvmdam/clean-jsdoc-theme) [![license](https://img.shields.io/github/license/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/master/LICENSE)
3
+ [![Stars](https://img.shields.io/github/stars/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme) [![Fork](https://img.shields.io/github/forks/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/fork) ![Version](https://img.shields.io/badge/version-4.2.1-005bff) [![Issues Open](https://img.shields.io/github/issues/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/issues) [![Contributors](https://img.shields.io/github/contributors/ankitskvmdam/clean-jsdoc-theme)](https://github.com/ankitskvmdam/clean-jsdoc-theme/graphs/contributors) [![Build Status](https://travis-ci.org/ankitskvmdam/clean-jsdoc-theme.svg?branch=production)](https://travis-ci.org/ankitskvmdam/clean-jsdoc-theme) [![license](https://img.shields.io/github/license/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
- var filePathNormalized = path.normalize(filePath);
22
+ const resolvedPath = path.resolve(filePath);
23
+ const filename = path.basename(resolvedPath);
24
+ const out = path.join(outdir, filename);
11
25
 
12
- fs.copyFileSync(filePathNormalized, outdir);
26
+ fse.copyFileSync(resolvedPath, out);
13
27
  }
14
28
 
15
29
  function copyToOutputFolderFromArray(filePathArray, outdir) {
16
- var i = 0;
17
- var outputList = [];
30
+ const outputList = [];
18
31
 
19
32
  if (Array.isArray(filePathArray)) {
20
- for (; i < filePathArray.length; i++) {
21
- copyToOutputFolder(filePathArray[i], outdir);
22
- outputList.push(path.basename(filePathArray[i]));
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
- var staticDir = themeOpts.static_dir || undefined;
135
+ const staticDir = themeOpts.static_dir || undefined;
123
136
 
124
137
  if (staticDir) {
125
- for (var i = 0; i < staticDir.length; i++) {
126
- var output = path.join(outdir, staticDir[i]);
138
+ for (const dir of staticDir) {
139
+ const output = path.join(outdir, dir);
127
140
 
128
- fse.copySync(staticDir[i], output);
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", "./static/scripts/core.js"]
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.0",
3
+ "version": "4.2.1",
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('jsdoc/fs');
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
- // copy static folders
55
- copyStaticFolder(themeOpts, outdir);
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);
@@ -729,17 +737,21 @@ exports.publish = function (taffyData, opts, tutorials) {
729
737
  if (packageInfo && packageInfo.name) {
730
738
  outdir = path.join(outdir, packageInfo.name, packageInfo.version || '');
731
739
  }
732
- fs.mkPath(outdir);
740
+ mkdirSync(outdir);
741
+
742
+
743
+ // copy external static folders
744
+ copyStaticFolder(themeOpts, outdir);
733
745
 
734
746
  // copy the template's static files to outdir
735
747
  fromDir = path.join(templatePath, 'static');
736
- staticFiles = fs.ls(fromDir, 3);
748
+ staticFiles = lsSync(fromDir);
737
749
 
738
750
  staticFiles.forEach((fileName) => {
739
- const toDir = fs.toDir(fileName.replace(fromDir, outdir));
751
+ const toPath = sourceToDestination(fromDir, fileName, outdir);
740
752
 
741
- fs.mkPath(toDir);
742
- fs.copyFileSync(fileName, toDir);
753
+ mkdirSync(path.dirname(toPath));
754
+ fs.copyFileSync(fileName, toPath);
743
755
  });
744
756
 
745
757
  // copy user-specified static files to outdir
@@ -764,11 +776,10 @@ exports.publish = function (taffyData, opts, tutorials) {
764
776
  );
765
777
 
766
778
  extraStaticFiles.forEach((fileName) => {
767
- const sourcePath = fs.toDir(filePath);
768
- const toDir = fs.toDir(fileName.replace(sourcePath, outdir));
779
+ const toPath = sourceToDestination(fromDir, fileName, outdir);
769
780
 
770
- fs.mkPath(toDir);
771
- fs.copyFileSync(fileName, toDir);
781
+ mkdirSync(path.dirname(toPath));
782
+ fs.copyFileSync(fileName, toPath);
772
783
  });
773
784
  });
774
785
  }
@@ -869,7 +880,7 @@ exports.publish = function (taffyData, opts, tutorials) {
869
880
  // added by clean-jsdoc-theme-devs
870
881
  // output search file if search
871
882
  if (hasSearch) {
872
- fs.mkPath(path.join(outdir, 'data'));
883
+ mkdirSync(path.join(outdir, 'data'));
873
884
  fs.writeFileSync(
874
885
  path.join(outdir, 'data', 'search.json'),
875
886
  JSON.stringify({