The configuration options documented here only contain add-on options for jsdoc. See the jsdoc configuration for the full list of configuration options. All of the jsdoc configuration works as described in the JSDoc configuration as it does in jsdocp. Only additions are made to the configuration opts.jsdocp (See Configuration for more details).
How It Works
At the core of jsdocp is a wrapper around jsdoc that provides all of the features listed in the README.
- The supplied configuration is sanitized and merged into a master configuration file (see Configuration)
- Previous
npmpublished versions are captured vianpm view versionsand stored in theopts.destinationdirectory asversions.json(see Documentation Versions) - Parameter substitutions are resolved within the master configuration's
opts(see Parameter Substitutions) - The internal
jsdocptemplates are injected into thelayout(the rest of the templates are supplied by the template of your choosing):
head: Placed in theheadof every page that supplies the user-definedlinks/CSS sources,meta, etc.nav: Placed as the first entry to every page'sbodythat contains all of the navigation links to thenpmmodule,CHANGELOG, source code, document version selection, etc.foot: Placed as the last entry to every page'sbodythat contains user-definedscripts
- The
jsdoccommand is ran using the internally processed master configuration file as input - The
CHANGELOG.mdand parsedCHANGELOG.htmlare generated in theopts.destinaitondirectory (generated/filtered viagit logusing the supplied rich set of configuration options) jsdocpmarkdown extensions are parsed on the tutorials (see the Parameter Substitutions section for more details)- Publishing control is transferred to the template designated by
opts.template
Setup (windows users can use git for windows)
npm install -D <template>- Replace
<template>with the desired template to use (seejsdoctemplates)
- Replace
npm install -D jsdocp- Install jsdocp as a
devdependency
- Install jsdocp as a
mkdir -p jsdocp/static jsdocp/tutorial && touch jsdocp/jsdoc.conf- Create the directories that will be used by
jsdocp - Add the desired
static/tutorialfiles (e.g. CSS, scripts, images, tutorials, etc.)
- Create the directories that will be used by
- Add the desired
jsdoc/jsdocpconfiguration options to thejsdocp/jsdoc.conffile. The examplejsdocpconfiguration can be used as a guide.
At minumum, ensure the follwing are set:source- All the source files that should be included in the docsopts.template- Set to a path to the actualjsdoctemplate being used. The template should be a module acceessible on npm and the path should be relative to the module thatjsdocis generating documentation for (e.g../node_modules/myCoolTemplateModuleName).
- Add the following:
- your
package.json...
"scripts": { "jsdocp": "jsdocp ./jsdocp/jsdoc.json", "jsdocp-deploy": "jsdocp -D ./jsdocp/jsdoc.json" } - your
npm run jsdocpwill generate the docs in the module's./docs(unless overridden in the Configuration)
Deployment (assumes setup has been completed)
There are a few different ways that deployment can be performed based upon opts.jsdocp.deploy options. Deployment can occur locally or using a different git hosting service and running npm run jsdocp-deploy, but it will require some minor changes to conf.opts.jsdocp.deploy in the jsdoc.conf file outlined in the setup. However, we'll cover the most common use case where GitHub Pages and travis-ci are being used.
- If the
gh-pagesbranch isn't already created/selected for GitHub Pages onhttps://github.com/<your_username>/<your_repo_name>/settings, the following script can be used to create thegh-pagesbranch. NOTE: Make sure to commit any changes to your currently checked out branch before proceeding to run the following script.git checkout --orphan gh-pages git rm -rf . touch README.md git add README.md git commit -m 'Initial gh-pages commit' git push origin gh-pages - Create a personal access token on GitHub.
- If you haven't already done so, go to travis-ci.com, setup an account and follow the instructions to enable/activate your repo. Copy the personal access token from GitHub in the previous step and paste it in a new Environment Variable called
GITHUB_TOKENonhttps://travis-ci.com/<your_username>/<your_repo_name>/settings. - While your at it, you may also want to do the same thing for
npmby creating an Access Token onhttps://www.npmjs.com/settings/<your_username>/tokensand copy/paste it in a new Environment Variable calledNPM_TOKENonhttps://travis-ci.com/<your_username>/<your_repo_name>/settingsand put quotes around the value pasted: "my-npm-token-value" (we'll use this in our.travis.ymlto deploy tonpm). - Create a
.travis.ymlin the root of your project using the.travis.ymlbelow as a guide. npm version patch -m "Deploying %s" && git push origin <tag_name>- replacingpatchwithmajor,minor, etc. as needed (see npm-version)
Now everytime that a new version is tagged/pushed a new version of the npm package will be updated on https://www.npmjs.com/package/<your_package_name> and the docs will get updated on https://<your_username>.github.io/<your_repo_name> automatically!
# .travis.yml
# When a tagged commit is pushed the documentation pages and npm module are published/deployed:
# npm version patch -m "%s Release"
language: node_js
node_js:
- "lts/*"
branches:
only:
- master
- "/v*/"
script:
# - printenv
- "npm test"
# Using before_deploy will run before every deploy resulting in running multiple times when there is
# one or more deploy providers and will run regardless of the "on" directive used on the desired
# provider. Instead, a single script provider handles any pre-deployment executions.
#before_deploy:
# - "npm run jsdocp"
deploy:
# Using the pages provider will wipe out previously deployed pages for prior versions. This makes it
# difficult to navigate version history and link to via documentation.
# - provider: pages
# skip-cleanup: true
# github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
# keep-history: true
# target-branch: gh-pages
# local-dir: docs
# on:
# tags: true # only on tagging commit
# all_branches: true
- provider: script
skip_cleanup: true
script: npm run jsdocp-deploy
on:
tags: true # only on tagging commit
branch:
- /v(\d+\.)?(\d+\.)?(\*|\d+)$/
- provider: npm
email: "ugate.public@gmail.com"
api_key: $NPM_TOKEN # Set in the settings page of your repository, as a secure variable
on:
tags: true # only on tagging commit
branch:
- /v(\d+\.)?(\d+\.)?(\*|\d+)$/