A JSDoc plugin that adds recognition to the @sourcecode tag for using his data in your publish theme.
It can be used for demonstration part of codes in <pre> element
More info about jsdoc and publish theme:
npm install --save jsdoc-sourcecode-tag
# or using yarn cli
yarn add jsdoc-sourcecode-tag
---
Add plugin to jsdoc conf.json http://usejsdoc.org/about-configuring-jsdoc.html
{
"plugins": ["./node_modules/jsdoc-sourcecode-tag/index"]
}In your code
/**
* description
* @const {Function}
* @param {number} num
* @returns {boolean}
* @sourcecode
*/
const myFunction = function(num) {
// some cool code here
};In your publish theme data you will get data.sourcecode
lineno- where it's start in your codetype- definition type, alias ofdata.meta.code.typevalue- string with your code, start fromconst myFun...and to the end...};.
Add lines after ending of documented code
/**
* Want to show const declaration
* and same code part after that
* @const {number}
* @sourcecode +4
*/
const knockSeveralTimes = 10;
// 1
for (let i = 1; i <= knockSeveralTimes; i++) { // 2
console.log( `knock ${i}` ); // 3
} // 4It remove all lines of documented code and will start count from new line after
/**
* @name nowYouSeeMyLoop
* @sourcecode |+3
*/
for (let i = 1; i <= knockSeveralTimes; i++) { // 1
console.log( `knock ${i}` ); // 2
} // 3npm testfor testing js code style and test sorting methodnpm run fixfor automatically fix most of problems with js code style
Please read CHANGELOG.md
write tests and more examples
Please read CODE_OF_CONDUCT.md
Please read CONTRIBUTING.md