clean-jsdoc-theme 4.1.8 → 4.1.10

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/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.1.8-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.1.10-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. It is a clean and fully responsive theme with loads of
@@ -424,26 +424,27 @@ This will remove all symbols (members, methods ...) that come from inherited par
424
424
 
425
425
  ## Cheat sheet
426
426
 
427
- | name | default | use case | expected value(s) |
428
- | ------------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- | --------------------- |
429
- | `default_theme` | `"dark"` | To set the default theme | `"light" or "dark"` |
430
- | `homepageTitle` | "Home" | To set the title of homepage | `string` |
431
- | `title` | `null` | To set the title | `HTML` or `string` |
432
- | `base_url` | `/` | To set the base URL | `string` |
433
- | `menu` | `null` | To render extra link in navbar | Array of Object(s) |
434
- | `meta` | `null` | Meta tag attributes | Array of Object(s) |
435
- | `search` | `true` | To render search or not | `true` or `false` |
436
- | `codepen` | `{}` | To open code in codepen | `Object` |
437
- | `static_dir` | `null` | To include static dir | Array of string |
438
- | `create_style` | `null` | To create custom style rules | `string` |
439
- | `add_style_path` | `null` | To add external css libraries/files | Array of Object(s) |
440
- | `include_css` | `null` | To include css files | Array of string |
441
- | `add_scripts` | `null` | To create custom script | `string` |
442
- | `add_script_path` | `null` | To add external js libraries/files | Array of Object(s) |
443
- | `include_js` | `null` | To include js files | `string` |
444
- | `footer` | `null` | To render footer | `HTML` or `string` |
445
- | `exclude_inherited` | `false` | To exclude inherited symbols | `boolean` |
446
- | `sections` | `["Modules", "Classes", "Externals", "Events", "Namespaces", "Mixins", "Tutorials", "Interfaces", "Global"]` | To order navbar/sidebar sections or to hide/remove navbar/sidebar sections | `Array<SECTION_TYPE>` |
427
+ | name | default | use case | expected value(s) |
428
+ | --------------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- | --------------------- |
429
+ | `default_theme` | `"dark"` | To set the default theme | `"light" or "dark"` |
430
+ | `homepageTitle` | "Home" | To set the title of homepage | `string` |
431
+ | `title` | `null` | To set the title | `HTML` or `string` |
432
+ | `base_url` | `/` | To set the base URL | `string` |
433
+ | `menu` | `null` | To render extra link in navbar | Array of Object(s) |
434
+ | `meta` | `null` | Meta tag attributes | Array of Object(s) |
435
+ | `search` | `true` | To render search or not | `true` or `false` |
436
+ | `codepen` | `{}` | To open code in codepen | `Object` |
437
+ | `static_dir` | `null` | To include static dir | Array of string |
438
+ | `create_style` | `null` | To create custom style rules | `string` |
439
+ | `add_style_path` | `null` | To add external css libraries/files | Array of Object(s) |
440
+ | `include_css` | `null` | To include css files | Array of string |
441
+ | `add_scripts` | `null` | To create custom script | `string` |
442
+ | `add_script_path` | `null` | To add external js libraries/files | Array of Object(s) |
443
+ | `include_js` | `null` | To include js files | `string` |
444
+ | `footer` | `null` | To render footer | `HTML` or `string` |
445
+ | `exclude_inherited` | `false` | To exclude inherited symbols | `boolean` |
446
+ | `sections` | `["Modules", "Classes", "Externals", "Events", "Namespaces", "Mixins", "Tutorials", "Interfaces", "Global"]` | To order navbar/sidebar sections or to hide/remove navbar/sidebar sections | `Array<SECTION_TYPE>` |
447
+ | `displayModuleHeader` | `false` | If you want the module name to appear on its page | `boolean` |
447
448
 
448
449
  Don't forget to add the following in your jsdoc config file, otherwise toc will not work on some pages.
449
450
 
package/jsdoc-config.json CHANGED
@@ -16,6 +16,7 @@
16
16
  "search": true,
17
17
  "homepageTitle": "Clean JSDoc Theme",
18
18
  "default_theme": "dark",
19
+ "displayModuleHeader": true,
19
20
  "title": "clean-jsdoc-theme",
20
21
  "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>",
21
22
  "meta": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clean-jsdoc-theme",
3
- "version": "4.1.8",
3
+ "version": "4.1.10",
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": {
@@ -47,6 +47,7 @@
47
47
  "dependencies": {
48
48
  "fs-extra": "^10.1.0",
49
49
  "html-minifier": "^4.0.0",
50
- "nanoid": "^3.3.4"
50
+ "nanoid": "^3.3.4",
51
+ "showdown": "^2.1.0"
51
52
  }
52
53
  }
package/publish.js CHANGED
@@ -11,12 +11,15 @@ var util = require('util');
11
11
  var fse = require('fs-extra');
12
12
  var nanoid = require('nanoid').nanoid;
13
13
  var htmlMinify = require('html-minifier');
14
+ var showdown = require('showdown');
14
15
 
16
+ var mdToHTMLConverter = new showdown.Converter()
15
17
  var htmlsafe = helper.htmlsafe;
16
18
  var linkto = helper.linkto;
17
19
  var resolveAuthorLinks = helper.resolveAuthorLinks;
18
20
  var hasOwnProp = Object.prototype.hasOwnProperty;
19
21
 
22
+
20
23
  /* prettier-ignore-start */
21
24
  // eslint-disable-next-line
22
25
  var themeOpts = (env && env.opts && env.opts['theme_opts']) || {};
@@ -232,18 +235,19 @@ function addSignatureParams(f) {
232
235
  }
233
236
 
234
237
  function addSignatureReturns(f) {
235
- var attribs = [];
236
- var attribsString = '';
237
- var returnTypes = [];
238
- var returnTypesString = '';
238
+ const attribs = [];
239
+ let attribsString = '';
240
+ let returnTypes = [];
241
+ let returnTypesString = '';
242
+ const source = f.yields || f.returns;
239
243
 
240
244
  // jam all the return-type attributes into an array. this could create odd results (for example,
241
245
  // if there are both nullable and non-nullable return types), but let's assume that most people
242
246
  // who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa.
243
- if (f.returns) {
244
- f.returns.forEach(function (item) {
245
- helper.getAttribs(item).forEach(function (attrib) {
246
- if (attribs.indexOf(attrib) === -1) {
247
+ if (source) {
248
+ source.forEach((item) => {
249
+ helper.getAttribs(item).forEach((attrib) => {
250
+ if (!attribs.includes(attrib)) {
247
251
  attribs.push(attrib);
248
252
  }
249
253
  });
@@ -252,24 +256,27 @@ function addSignatureReturns(f) {
252
256
  attribsString = buildAttribsString(attribs);
253
257
  }
254
258
 
255
- if (f.returns) {
256
- returnTypes = addNonParamAttributes(f.returns);
259
+ if (source) {
260
+ returnTypes = addNonParamAttributes(source);
257
261
  }
258
262
  if (returnTypes.length) {
259
- returnTypesString = util.format(
260
- ' &rarr; %s{%s}',
261
- attribsString,
262
- returnTypes.join('|')
263
- );
263
+ returnTypesString = ` &rarr; ${attribsString}{${returnTypes.join('|')}}`;
264
264
  }
265
265
 
266
- f.signature =
267
- '<span class="signature">' +
268
- (f.signature || '') +
269
- '</span>' +
270
- '<span class="type-signature">' +
271
- returnTypesString +
272
- '</span>';
266
+ var signatureOutput = ""
267
+
268
+ if (f.signature) {
269
+ signatureOutput = '<span class="signature">' +
270
+ (f.signature || '') +
271
+ '</span>'
272
+ }
273
+ if (returnTypesString) {
274
+ signatureOutput += '<span class="type-signature">' +
275
+ returnTypesString +
276
+ '</span>'
277
+ }
278
+
279
+ f.signature = signatureOutput
273
280
  }
274
281
 
275
282
  function addSignatureTypes(f) {
@@ -423,6 +430,12 @@ function buildFooter() {
423
430
  return footer;
424
431
  }
425
432
 
433
+ function moduleHeader() {
434
+ var displayModuleHeader = themeOpts.displayModuleHeader || false;
435
+
436
+ return displayModuleHeader;
437
+ }
438
+
426
439
  function getFavicon() {
427
440
  var favicon = themeOpts.favicon || undefined;
428
441
 
@@ -528,15 +541,15 @@ function buildSidebarMembers({
528
541
 
529
542
  var methods =
530
543
  sectionName === SECTION_TYPE.Tutorials ||
531
- sectionName === SECTION_TYPE.Global
544
+ sectionName === SECTION_TYPE.Global
532
545
  ? []
533
546
  : find({
534
- kind: 'function',
535
- memberof: item.longname,
536
- inherited: {
537
- '!is': Boolean(themeOpts.exclude_inherited)
538
- }
539
- });
547
+ kind: 'function',
548
+ memberof: item.longname,
549
+ inherited: {
550
+ '!is': Boolean(themeOpts.exclude_inherited)
551
+ }
552
+ });
540
553
 
541
554
  if (!hasOwnProp.call(itemsSeen, item.longname)) {
542
555
  currentItem.anchor = linktoFn(
@@ -733,6 +746,19 @@ function buildSidebar(members) {
733
746
  return nav;
734
747
  }
735
748
 
749
+ /**
750
+ * Currently for some reason yields markdown is
751
+ * not processed by jsdoc. So, we are processing it here
752
+ *
753
+ * @param {Array<{type: string, description: string}>} yields
754
+ */
755
+ function getProcessedYield(yields) {
756
+ if (!Array.isArray(yields)) return []
757
+
758
+ return yields.map((y) => ({ ...y, description: mdToHTMLConverter.makeHtml(y.description) }))
759
+ }
760
+
761
+
736
762
  /**
737
763
  @param {TAFFY} taffyData See <http://taffydb.com/>.
738
764
  @param {object} opts
@@ -762,15 +788,16 @@ exports.publish = function (taffyData, opts, tutorials) {
762
788
  // set up templating
763
789
  view.layout = conf.default.layoutFile
764
790
  ? path.getResourcePath(
765
- path.dirname(conf.default.layoutFile),
766
- path.basename(conf.default.layoutFile)
767
- )
791
+ path.dirname(conf.default.layoutFile),
792
+ path.basename(conf.default.layoutFile)
793
+ )
768
794
  : 'layout.tmpl';
769
795
 
770
796
  // set up tutorials for helper
771
797
  helper.setTutorials(tutorials);
772
798
 
773
799
  data = helper.prune(data);
800
+
774
801
  data.sort('longname, version, since');
775
802
  helper.addEventListeners(data);
776
803
 
@@ -825,6 +852,10 @@ exports.publish = function (taffyData, opts, tutorials) {
825
852
  sourceFilePaths.push(sourcePath);
826
853
  }
827
854
  }
855
+
856
+ if (doclet.yields) {
857
+ doclet.yields = getProcessedYield(doclet.yields)
858
+ }
828
859
  });
829
860
 
830
861
  // update outdir if necessary, then create outdir
@@ -952,6 +983,7 @@ exports.publish = function (taffyData, opts, tutorials) {
952
983
  view.htmlsafe = htmlsafe;
953
984
  view.outputSourceFiles = outputSourceFiles;
954
985
  view.footer = buildFooter();
986
+ view.displayModuleHeader = moduleHeader();
955
987
  view.favicon = getFavicon();
956
988
  view.dynamicStyle = createDynamicStyleSheet();
957
989
  view.dynamicStyleSrc = returnPathOfStyleSrc();