Template Literals:
All of the opts.jsdocp
configuration option values can also contain template literals (i.e. ${}
) that reference paths within the following objects:
${package}
: Thepackage.json
object which can allows access to any of it's property paths (e.g.${package.repository.url}
).${publish.lastVersionPublished}
: Evaluates to the last version published tonpm
or blank when nothing has been published yet.${publish.lastVersion}
: Evaluates to the last version published tonpm
or the currentpackage.version
when nothing has been published yet.${publish.moduleURL}
: Evaluates to thehomepage
inpackage.json
, but will also remove any hashes in the URL (e.g. assuming ahomepage
ofhttps://example.com/username/module#readme
would becomehttps://example.com/username/module
).${publish.date}
: The current date string formatted asYYYY-MM-DD
${env}
: Evaluates to theprocess.env
forjsdocp
(e.g.${env.SOME_ENV_VAR}
)
NOTE: Only placeholders within the conf.opts
section will be evaluated
Tutorials Markdown Extensions
For ease of use an additional markdown extension can be used throughout any of the tutorials markdown to include code
snippets from resource files. Let's say we want to include the configuration file located at ./jsdocp/conf.json
. This can be accomplish by adding a special jsdocp
fenced code block to the markdown in any of the tutorials:
```jsdocp ./some/path/to/file.js // file.js contents below ```
Which would be parsed into the following assuming that fileFunction
is the contents of ./some/path/to/file.js
:
```js // file.js contents below function fileFunction() { console.log('my function'); } ```
In particular, JSON files can include one or more path arguements so that only designated segments of a given JSON source will be included in the code
snippets. Each arguement can be separated by an @
symbol. Within each argement, a period delimited path can be defined that points to the JSON segment(s) that will be included in the code
snippet. In addition, each path can be prefixed with a ~
indicating that the extracted property name/value should reside on the root element of the JSON output. For example:
```jsdocp ./some/path/to/package.json @ devDependencies.jsdoc @ devDependencies.minami @ repository.url @~ repository.type @ bugs.nonExistentProperty ```
Would result in something like (using the package.json
from the jsdocp
module):
{
"devDependencies": {
"jsdoc": "^3.6.6",
"minami": "^1.2.3"
},
"repository": {
"url": "git+https://github.com/ugate/jsdocp.git"
},
"type": "git",
"bugs": {}
}