Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Commit

Permalink
Add support for injecting custom styles and scripts (#26)
Browse files Browse the repository at this point in the history
This allows the consumer to tweak styling and behaviour
by supplying their own custom .css and .js files to get
bundled into the docs when they're built.

Heavily influenced by the approach over at:
https://github.com/clenemt/docdash

Closes #25
  • Loading branch information
sanbornhilland authored Apr 4, 2020
1 parent 12dc84e commit 11a0fc7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 36 deletions.
74 changes: 40 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ npm install @pixi/jsdoc-template --save-dev
## Usage

If you already have JSDoc system, you can use this project as JSDoc template. More information about JSDoc command-line arguments can be found [here](http://usejsdoc.org/about-commandline.html).

```bash
jsdoc -c conf.json -R README.md
```
Expand All @@ -25,39 +25,45 @@ jsdoc -c conf.json -R README.md
You can set options for customizing your documentations. Notice the `"template"` field for setting the path to **pixi-jsdoc-template**.

```json
"templates": {
"applicationName": "Demo",
"disqus": "",
"googleAnalytics": "",
"favicon": "path/to/favicon.png",
"openGraph": {
"title": "",
"type": "website",
"image": "",
"site_name": "",
"url": ""
},
"meta": {
"title": "",
"description": "",
"keyword": ""
},
"linenums": true,
"source": {
"include": [
"./src/"
],
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_"
},
"opts": {
"encoding": "utf8",
"recurse": true,
"private": false,
"lenient": true,
"destination": "./docs",
"template": "./node_modules/@pixi/jsdoc-template"
}
{
"templates": {
"applicationName": "Demo",
"disqus": "",
"googleAnalytics": "",
"favicon": "path/to/favicon.png",
"openGraph": {
"title": "",
"type": "website",
"image": "",
"site_name": "",
"url": ""
},
"meta": {
"title": "",
"description": "",
"keyword": ""
},
"linenums": true,
"source": {
"include": [
"./src/"
],
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_"
},
"opts": {
"encoding": "utf8",
"recurse": true,
"private": false,
"lenient": true,
"destination": "./docs",
"template": "./node_modules/@pixi/jsdoc-template"
}
},
"pixi": {
"styles": ["path/to/custom/styles.css"],
"scripts": ["path/to/custom/script.js"]
}
}
```

Expand Down
18 changes: 16 additions & 2 deletions tmpl/layout.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="styles/main.css">

<?js if (env.conf.templates) { ?>
<script>
var config = <?js= JSON.stringify(env.conf.templates) ?>;
Expand All @@ -43,7 +43,7 @@
var _gaq = _gaq || [];
_gaq.push(['_setAccount', config.googleAnalytics]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
Expand Down Expand Up @@ -76,5 +76,19 @@
</div>
<script>prettyPrint();</script>
<script src="scripts/main.js"></script>
<?js if (env.conf.pixi && env.conf.pixi.styles && env.conf.pixi.styles.length) {
for (var i = 0; i < env.conf.pixi.styles.length; i++) {
?>
<link type="text/css" rel="stylesheet" href="<?js= env.conf.pixi.styles[i] ?>">
<?js
}
} ?>
<?js if (env.conf.pixi && env.conf.pixi.scripts && env.conf.pixi.scripts.length) {
for (var i = 0; i < env.conf.pixi.scripts.length; i++) {
?>
<script src="<?js= env.conf.pixi.scripts[i] ?>"></script>
<?js
}
} ?>
</body>
</html>

0 comments on commit 11a0fc7

Please sign in to comment.