jsdoc-sourcecode-tag

1.0.2 • Public • Published

jsdoc-sourcecode-tag

jsdoc3 license Build Status

js happiness style

What is this?

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:


Installing

npm install --save jsdoc-sourcecode-tag
# or using yarn cli 
yarn add jsdoc-sourcecode-tag
 
---
 

Usage

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 code
  • type - definition type, alias of data.meta.code.type
  • value - string with your code, start from const myFun... and to the end ...};.

tag value

+{number}

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
}                                              // 4

|+{number}

It 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
}                                               // 3

Tests

  1. npm test for testing js code style and test sorting method
  2. npm run fix for automatically fix most of problems with js code style

Changelog

Please read CHANGELOG.md


To Do

write tests and more examples


Code of Conduct

Please read CODE_OF_CONDUCT.md

Contributing

Please read CONTRIBUTING.md

After that - you know what to do -> issues and pulls

Package Sidebar

Install

npm i jsdoc-sourcecode-tag

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • dutchenkooleg