Skip to content

Commit

Permalink
add target option in include scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitskvmdam committed Nov 7, 2023
1 parent 4be3d79 commit 6f3c648
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# clean-jsdoc-theme

[![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.14-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)
[![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.15-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)
<br>

`clean-jsdoc-theme` is a beautifully crafted theme for JSDoc 3/JSDoc 4. It is a clean and fully responsive theme with loads of
Expand Down Expand Up @@ -480,6 +480,34 @@ Assuming the above js file is stored in `./static/showAlert.js`. To include you
It will include the js files to the output dir and also attach a script tag to the html pointing to the included js
file.

If you want to add some script for some pages then you can do the following:

```json
"include_js": [
"./demo/src/assets/script.js",
{
"filepath": "./demo/src/assets/random.js",
"targets": [
"MyClass",
"tutorial-MyClassTutorial"
]
}
],
```

Here target is the name of the generated html file (don't include `.html`).

The above config will add `./demo/src/assets/script.js` to all the generated html files. However, it will
add `./demo/src/assets/random.js` only to `MyClass.html` and `tutorial-MyClassTutorial.html` files.

The file name of the generated html generally follows the following convention:

- Class: class's name + `.html`. Ex `Alive.html`
- Module: `module-` + module's name + `.html`. Ex: `module-SqlJs.html`
- Tutorials: `tutorial-` + tutorial's filename + `.html`

If you are not sure about the target name, then generate html for the first time, then look at the urls.

### To ignore sorting

To ignore the sorting of members/methods/event in the page. If it is `false` then the order of
Expand Down
23 changes: 14 additions & 9 deletions clean-jsdoc-theme-helper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const has = require('lodash/has');
const klawSync = require('klaw-sync');
const path = require('path')
const fse = require('fs-extra')
const path = require('path');
const fse = require('fs-extra');
const showdown = require('showdown');

const mdToHTMLConverter = new showdown.Converter();
Expand All @@ -16,7 +16,7 @@ function lsSync(dir, opts = {}) {
});

return files.map((f) => f.path);
};
}

function copyToOutputFolder(filePath, outdir) {
const resolvedPath = path.resolve(filePath);
Expand All @@ -31,8 +31,15 @@ function copyToOutputFolderFromArray(filePathArray, outdir) {

if (Array.isArray(filePathArray)) {
for (const filePath of filePathArray) {
copyToOutputFolder(filePath, outdir);
outputList.push(path.basename(filePath));
if (typeof filePath === 'string') {
copyToOutputFolder(filePath, outdir);
outputList.push(path.basename(filePath));
} else if (typeof filePath === 'object') {
const { filepath, targets } = filePath;

copyToOutputFolder(filepath, outdir);
outputList.push({ filepath: path.basename(filepath), targets });
}
}
}

Expand Down Expand Up @@ -158,8 +165,6 @@ function getProcessedYield(yields) {
}));
}



module.exports = {
buildFooter,
moduleHeader,
Expand All @@ -177,5 +182,5 @@ module.exports = {
returnPathOfStyleSrc,
copyStaticFolder,
getProcessedYield,
lsSync
}
lsSync,
};
2 changes: 2 additions & 0 deletions publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ async function generate(title, docs, filename, resolveLinks) {
env: env,
title: title,
docs: docs,
filename,
};

outpath = path.join(outdir, filename);
Expand Down Expand Up @@ -1016,6 +1017,7 @@ exports.publish = async function (taffyData, opts, tutorials) {
header: tutorial.title,
content: tutorial.parse(),
children: tutorial.children,
filename,
};

const tutorialPath = path.join(outdir, filename);
Expand Down

0 comments on commit 6f3c648

Please sign in to comment.