Coder Social home page Coder Social logo

inchjs's Introduction

InchJS

inchjs gives you hints where to improve your docs. One Inch at a time.

It is a wrapper for Inch for JavaScript. Take a look at the original Inch page with screenshots (live and in full color).

What can it do?

inchjs is a little bit like Code Climate, but for your inline code documentation (and not a webservice).

It is a command-line utility that suggests places in your codebase where documentation can be improved.

If there are no inline-docs yet, inchjs can tell you where to start.

Installation

To install simply run:

$ npm install inchjs

Usage

To run Inch, simply type

$ inchjs

Given a lib directory with the following code inside:

// A complicated function
var complicated(o, i, args) = function {
  // ... snip ...
}

/**
 *  An example of a function that takes a parameter (+param1+)
 *  and does nothing.
 *
 *  Returns null
 */
var nothing(param1) = function {
  // ... snip ...
}

var filename = function {
  // ... snip ...
}

Inch will suggest that the docs could be improved:

# Properly documented, could be improved:

┃  B  ↑  complicated
┃  B  ↑  nothing

# Undocumented:

┃  U  ↗  filename

You might want to look at these files:

┃ src/something.js

Grade distribution (undocumented, C, B, A):  █  ▁ ▄ ▄

Only considering priority objects: ↑ ↗ →  (use `--help` for options).

If you have Inch installed it will run locally. If not, it will use the API of inch-ci.org to display results. If you want to specify a certain Inch version you have installed (e.g. for testing), you can set the INCH_PATH environment variable.

Configuration

By default, InchJS looks into {lib,src}/**/*.js for JavaScript source files. You can customize this by either passing the desired files to the executable:

$ inchjs suggest plugins/**/*.js

or by creating a file named inch.json in your project directory:

{
  "files": {
    "included": [
      "plugins/**/*.js"
    ],
    "excluded": [
      "plugins/vendor/sparkr/sparkr.js",
      "plugins/vendor/**/*.js",
      "!regexp:/vendor/"
    ]
  }
}

As you would expect, included sets an array of included files (or globs) and excluded sets an array of files, globs or regexes of files to exclude from the evaluation.

Philosophy

Inch was created to help people document their code, therefore it may be more important to look at what it does not do than at what it does.

  • It does not aim for "fully documented" or "100% documentation coverage".
  • It does not tell you to document all your code (neither does it tell you not to).
  • It does not impose rules on how your documentation should look like.
  • It does not require that, e.g."every function's documentation should be a single line under 80 characters not ending in a period" or that "every class and module should provide a code example of their usage".

Inch takes a more relaxed approach towards documentation measurement and tries to show you places where your codebase could use more documentation.

The Grade System

Inch assigns grades to each class, module, constant or function in a codebase, based on how complete the docs are.

The grades are:

  • A - Seems really good
  • B - Properly documented, but could be improved
  • C - Needs work
  • U - Undocumented

Using this system has some advantages compared to plain coverage scores:

  • You can get an A even if you "only" get 90 out of 100 possible points.
  • Getting a B is basically good enough.
  • Undocumented objects are assigned a special grade, instead of scoring 0%.

The last point might be the most important one: If objects are undocumented, there is nothing to evaluate. Therefore you can not simply give them a bad rating, because they might be left undocumented intentionally.

Priorities ↑ ↓

Every module, constant and function in a codebase is assigned a priority which reflects how important Inch thinks it is to be documented.

This process follows some reasonable rules, like

  • it is more important to document public functions than private ones
  • it is more important to document functions with many parameters than functions without parameters
  • it is not important to document objects marked as @private

Priorities are displayed as arrows. Arrows pointing north mark high priority objects, arrows pointing south mark low priority objects.

No overall scores or grades

Inch does not give you a grade for your whole codebase.

"Why?" you might ask. Look at the example below:

Grade distribution (undocumented, C, B, A):  ▄  ▁ ▄ █

In this example there is a part of code that is still undocumented, but the vast majority of code is rated A or B.

This tells you three things:

  • There is a significant amount of documentation present.
  • The present documentation seems good.
  • There are still undocumented functions.

Inch does not really tell you what to do from here. It suggests objects and files that could be improved to get a better rating, but that is all. This way, it is perfectly reasonable to leave parts of your codebase undocumented.

Instead of reporting

coverage: 67.1%  46 ouf of 140 checks failed

and leaving you with a bad feeling, Inch tells you there are still undocumented objects without judging.

This provides a lot more insight than an overall grade could, because an overall grade for the above example would either be an A (if the evaluation ignores undocumented objects) or a weak C (if the evaluation includes them).

The grade distribution does a much better job of painting the bigger picture.

Features

Inch is build to parse JSDoc, AtomDoc and TomDoc style documentation comments, but works reasonably well with unstructured comments.

These inline-docs below all score an A despite being written in different styles:

/**
 *  Detects the size of the blob.
 *
 *  @example
 *    getBlobSize(filename, blob)  *  => some value
 *
 *  @param filename {String} the filename
 *  @param blob {String} the blob data
 *  @param mode {String, null} optional String mode
 *  @return {Number, null}
 */
var getBlobSize = function(filename, blob, mode) { }
/**
 *  Public: Detects the size of the blob.
 *
 *  * `count` {Number} representing count
 *
 *  * `filename` {String} the filename
 *  * `blob` {String} the blob data
 *  * `mode` {String,null} optional String mode
 *
 *  ## Example
 *
 *    getBlobSize(filename, blob)  *  => some value
 *
 *  Returns Number or null.
 */
var getBlobSize = function(filename, blob, mode) { }
// Public: Detects the size of the blob.
//
// filename - String filename
// blob - String blob data
// mode - Optional String mode (defaults to null)
//
// Examples
//
//   getBlobSize(filename, blob)
//   // => some value
//
// Returns Number or null.
var getBlobSize = function(filename, blob, mode) { }

But you don't have to adhere to any specific syntax. This gets an A as well:

// Returns the size of a +blob+ for a given +filename+ (+mode+ is optional).
//
//   getBlobSize(filename, blob)
//   // => some value
//
var getBlobSize = function(filename, blob, mode = null)

Inch let's you write your documentation the way you want.

Subcommands

It comes with four sub-commands: suggest, stats, show, and list

inchjs suggest

Suggests places where a codebase suffers a lack of documentation.

$ inchjs suggest

# Properly documented, could be improved:

┃  B  ↑  BaseList#prepare_list
┃  B  ↑  FunctionParameterObject#initialize
┃  B  ↗  Stats#run
┃  B  ↗  CommandParser#run

# Not properly documented:

┃  C  ↑  NodocHelper#implicit_nodoc_comment?
┃  C  ↑  Suggest#initialize
┃  C  ↑  Suggest#initialize

# Undocumented:

┃  U  ↑  ConstantObject#evaluate
┃  U  ↑  FunctionObject#evaluate
┃  U  ↑  SourceParser#find_object

You might want to look at these files:

┃ src/code_object/proxy/base.js
┃ src/code_object/proxy/function_object.js
┃ src/evaluation/role/object.js

Grade distribution (undocumented, C, B, A):  █  ▃ ▁ ▄

Only considering priority objects: ↑ ↗ →  (use `--help` for options).

inchjs stats

Shows you an overview of the codebase.

$ inchjs stats

Grade distribution: (undocumented, C, B, A)

  Overall:  █  ▂ ▁ ▃    439 objects

Grade distribution by priority:

        ↑   ▁  ▄ █ ▁     10 objects

        ↗   █  ▃ ▁ ▃    302 objects

        →   ▆  ▂ ▁ █     73 objects

        ↘   █  ▁ ▁ ▁     54 objects

        ↓   ▁  ▁ ▁ ▁      0 objects

Priority distribution in grades: (low to high)

      ↓      ↘      →      ↗      ↑
  U:  ▁ ▁ ▁ ▁ ▁ ▁ ▂ ▂ ▁ █ ▁ ▁ ▁ ▁ ▁   243 objects

  C:  ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ █ ▁ ▁ ▁ ▁ ▁    73 objects

  B:  ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ █ ▂ ▄ ▁ ▁ ▁    19 objects

  A:  ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▄ ▁ █ ▁ ▁ ▁ ▁ ▁   104 objects


Try `--format json|yaml` for raw numbers.

inchjs list

Lists all objects in your codebase with their grades.

$ inchjs list

# Seems really good

┃  A  ↑  Console#object
┃  A  ↗  Proxy#depth
┃  A  ↗  Base#description
┃  A  ↗  NodocHelper#nodoc?
┃ ...  (omitting 75 objects)

# Proper documentation present

┃  B  ↑  Suggest#run
┃  B  ↑  FunctionParameterObject#initialize
┃  B  ↗  Stats#run
┃  B  ↗  CommandParser#run

# Needs work

┃  C  ↑  NodocHelper#implicit_nodoc_comment
┃  C  ↑  Console#initialize
┃  C  ↑  ConstantObject#evaluate
┃  C  ↑  SourceParser#find_object
┃ ...  (omitting 248 objects)

This output omitted 323 objects. Use `--all` to display all objects.

Limitations

How you document your code is up to you and Inch can't actually tell you how good your docs are.

It can't tell if your code examples work or if you described parameters correctly or if you have just added # TODO: write docs to each and every function.

It is just a tool, that you can use to find parts in your codebase that are lacking documentation.

How is this different from ...?

Documentation coverage

Documentation coverage checks look at all code objects and determine if the found documentation meets a certain threshold/expectation.

Inch takes a different approach as it aims for "properly documented" rather than "100% coverage".

Ideas

Measuring documentation coverage is not an easy task, as my experience in developing Inch for Ruby has shown. I wanted to write down some ideas for InchJS to see how they look on paper.

  • Although there are standards like JSDoc, where comments are formatted in a specific way, InchJS should recognize any kind of comment as inline-docs.
  • Docs that only contain "TODO: ..." or "FIXME" are not sufficient documentation.
  • But some docs are better than none, so in most cases a singleline comment will suffice and is therefore enough for a "not bad"-rating.
  • If otherwise sufficient docs contain "TODO: ..." or "FIXME" this is considered fair-game and does not impact the evaluation.

If you want to contribute to this list open an issue!

Contributing

  1. Fork it!
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Author

René Föhring (@rrrene)

License

InchJS is released under the MIT License. See the LICENSE.txt file for further details.

inchjs's People

Contributors

leoaref avatar rrrene avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

inchjs's Issues

Problems running InchJS

Hi,

I'm running into problems running InchJS. When I run

yarn add inchjs
yarn global add inchjs
node node_modules/.bin/inchjs
node /home/***/.yarn/bin/inchjs 

I get the following

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.2.1</center>
</body>
</html>

The files contain the following content:

#!/usr/bin/env node

(function() {
  'use strict';

  var Inch = require('../lib/inch'),
      options = {},
      inch_args = process.argv.slice(2, process.argv.length);

  if( inch_args == '-v' || inch_args == '--version' ) {
    console.log("inchjs "+Inch.version)
  } else if( inch_args == '--dry-run' ) {
    options.dry_run = true;
    inch_args = [];
  }

  if( inch_args == '--report' ) {
    Inch.report();
  } else {
    Inch.run(inch_args, options);
  }
})();

Do you know what caused this problem?

Getting "Could not find jsdoc executable" even if jsdoc exists

Currently, we are finding the jsdoc manually inside the node_modules directory inside the lib:

function getJSDocCommand() {
  var inchjs_dir = Path.join(__dirname, '..', '..');
  var finder = "find "+inchjs_dir+" -type l -name jsdoc";
  var out = sh.exec(finder, {silent: true}).output;
  var found = out.split("\n")[0].trim();
  if( found == "" ) {
    throw("Could not find jsdoc executable");
  } else {
    return found;
  }
}

But with the new version of npm we have flat dependencies, so jsdoc will be installed in the root node_modules directory

So we need to update it and just check if jsdoc exists or not

function getJSDocCommand() {
  try {
    return require('jsdoc/package.json');
  } catch(e) {
    throw("Could not find jsdoc executable");
  }
}

Improve show command

Will be great, if inchjs could support show command more in depth, like it done in inch.

When I'm calling inchjs show, I'm expecting to get an output similar to this one:

$ inch show Inch::SourceParser#find_object

# Inch::SourceParser#find_object

┃ -> lib/inch/source_parser.rb:16
┃ ------------------------------------------------------
┃ Grade: C - Needs work
┃ ------------------------------------------------------
┃ + Add a comment describing the method
┃ + Describe the parameter 'path'
┃ + Describe the return type of 'find_object'
┃ + Add a code example (optional)
┃ ------------------------------------------------------

SyntaxError: Unexpected end of input

Just installed inchjs and I got :

$ git clone [email protected]:FGRibreau/doxx.git
$ cd doxx
$ npm install inchjs -g
$ inchjs suggest **/**.js

undefined:0

^
SyntaxError: Unexpected end of input
    at Object.parse (native)
    at Socket.<anonymous> (/Users/fg/.nvm/v0.10.35/lib/node_modules/inchjs/lib/docs/jsdoc_runner.js:23:24)
    at Socket.emit (events.js:117:20)
    at Pipe.close (net.js:466:12)

inchjs: v0.1.6
nodejs : v0.10.35

Any idea @rrrene ?

Problem using inchjs . "Parsing failed."

Hi.

I am beginner in node js and want to use this module for jsdoc code coverage measurement.
It was used for this jsdoc

/**
 * @summary ثبت نام یک سامانه
 * @param {!Object} request.data 
 * @param {!String} request.data.username 
 * @param {!String} request.data.password 
 * @param {!Object} request.headers 
 * @param {!String} request.headers.user 
 * @return {undefined}
 */

and run in command line with "inches ... .js" but return " [InchJS] Parsing failed.".

Do you know what caused this problem?

Language not registered: javascript

I get the following error with inch and inchjs installed:

$ sudo npm install -g inchjs
[sudo] password for aureooms: 
/usr/bin/inchjs -> /usr/lib/node_modules/inchjs/bin/inchjs
[email protected] /usr/lib/node_modules/inchjs
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
$ sudo gem install inch
Fetching: yard-0.8.7.6.gem (100%)
Successfully installed yard-0.8.7.6
Fetching: tins-1.3.5.gem (100%)
Successfully installed tins-1.3.5
Fetching: term-ansicolor-1.3.0.gem (100%)
Successfully installed term-ansicolor-1.3.0
Fetching: sparkr-0.4.1.gem (100%)
Successfully installed sparkr-0.4.1
Fetching: method_source-0.8.2.gem (100%)
Successfully installed method_source-0.8.2
Fetching: slop-3.6.0.gem (100%)
Successfully installed slop-3.6.0
Fetching: coderay-1.1.0.gem (100%)
Successfully installed coderay-1.1.0
Fetching: pry-0.10.1.gem (100%)
Successfully installed pry-0.10.1
Fetching: inch-0.5.10.gem (100%)
Successfully installed inch-0.5.10
Parsing documentation for yard-0.8.7.6
Installing ri documentation for yard-0.8.7.6
Parsing documentation for tins-1.3.5
Installing ri documentation for tins-1.3.5
Parsing documentation for term-ansicolor-1.3.0
Installing ri documentation for term-ansicolor-1.3.0
Parsing documentation for sparkr-0.4.1
Installing ri documentation for sparkr-0.4.1
Parsing documentation for method_source-0.8.2
Installing ri documentation for method_source-0.8.2
Parsing documentation for slop-3.6.0
Installing ri documentation for slop-3.6.0
invalid options: -SNw2
(invalid options are ignored)
Parsing documentation for coderay-1.1.0
Installing ri documentation for coderay-1.1.0
Parsing documentation for pry-0.10.1
Installing ri documentation for pry-0.10.1
Parsing documentation for inch-0.5.10
Installing ri documentation for inch-0.5.10
Done installing documentation for yard, tins, term-ansicolor, sparkr, method_source, slop, coderay, pry, inch after 29 seconds
9 gems installed
$ ls js/src/**/*.js -1
js/src/attr/attr.js
js/src/attr/len.js
js/src/decreasing.js
js/src/fn.js
js/src/increasing.js
js/src/lexicographical/colexicographical.js
js/src/lexicographical/fixedcolexicographical.js
js/src/lexicographical/fixedlexicographical.js
js/src/lexicographical/lexicographical.js
js/src/lexicographical/quasicolexicographical.js
js/src/lexicographical/quasilexicographical.js
js/src/lexicographical/rangedcolexicographical.js
js/src/lexicographical/rangedlexicographical.js
js/src/reverse.js
js/src/sign.js
$ inchjs js/src/**/*.js
/var/lib/gems/2.1.0/gems/inch-0.5.10/lib/inch/config.rb:13:in `instance': Language not registered: javascript (RuntimeError)
    from /var/lib/gems/2.1.0/gems/inch-0.5.10/lib/inch/config.rb:38:in `for'
    from /var/lib/gems/2.1.0/gems/inch-0.5.10/lib/inch/cli/command/base.rb:117:in `to_config'
    from /var/lib/gems/2.1.0/gems/inch-0.5.10/lib/inch/cli/command/base_list.rb:24:in `prepare_codebase'
    from /var/lib/gems/2.1.0/gems/inch-0.5.10/lib/inch/cli/command/suggest.rb:24:in `run'
    from /var/lib/gems/2.1.0/gems/inch-0.5.10/lib/inch/cli/command/base.rb:50:in `run'
    from /var/lib/gems/2.1.0/gems/inch-0.5.10/lib/inch/cli/command_parser.rb:99:in `run_command'
    from /var/lib/gems/2.1.0/gems/inch-0.5.10/lib/inch/cli/command_parser.rb:62:in `run'
    from /var/lib/gems/2.1.0/gems/inch-0.5.10/lib/inch/cli/command_parser.rb:52:in `run'
    from /var/lib/gems/2.1.0/gems/inch-0.5.10/bin/inch:23:in `<top (required)>'
    from /usr/local/bin/inch:23:in `load'
    from /usr/local/bin/inch:23:in `<main>'

While the error looks like a complete crash, it is able to generate a docs.json file:

$ cat docs.json 
{"language":"javascript","client_name":"inchjs","args":[],"client_version":"0.2.17","git_repo_url":"https://[email protected]/aureooms/js-compare","branch_name":"master","objects":[{"comment":"","meta":{"range":[5,118],"filename":"attr.js","lineno":2,"path":"/js/src/attr","code":{"id":"astnode494753372","name":"attr","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare","key"]},"vars":{"":false}},"undocumented":true,"name":"attr","kind":"function","longname":"attr","scope":"global"},{"comment":"","meta":{"range":[5,115],"filename":"len.js","lineno":2,"path":"/js/src/attr","code":{"id":"astnode99403445","name":"len","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare"]},"vars":{"":false}},"undocumented":true,"name":"len","kind":"function","longname":"len","scope":"global"},{"comment":"","meta":{"range":[5,89],"filename":"decreasing.js","lineno":2,"path":"/js/src","code":{"id":"astnode1875923134","name":"decreasing","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["a","b"]}},"undocumented":true,"name":"decreasing","kind":"function","longname":"decreasing","scope":"global"},{"comment":"","meta":{"range":[5,135],"filename":"fn.js","lineno":2,"path":"/js/src","code":{"id":"astnode2064783959","name":"fn","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare","callable"]},"vars":{"":false}},"undocumented":true,"name":"fn","kind":"function","longname":"fn","scope":"global"},{"comment":"","meta":{"range":[5,89],"filename":"increasing.js","lineno":2,"path":"/js/src","code":{"id":"astnode278908925","name":"increasing","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["a","b"]}},"undocumented":true,"name":"increasing","kind":"function","longname":"increasing","scope":"global"},{"comment":"/**\n* Generates a binary colexicographical comparator\n* from a binary comparator.\n*\n* https://en.wikipedia.org/wiki/Lexicographical_order#Colexicographic_order\n*\n* compare( a, b ) should always return\n*   - a negative value if a < b\n*   - a positive value if a > b\n*   - zero if a === b\n*\n* compare should express an increasing ordering\n*/","meta":{"range":[358,716],"filename":"colexicographical.js","lineno":16,"path":"/js/src/lexicographical","code":{"id":"astnode99199079","name":"colexicographical","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare"]},"vars":{"":false}},"description":"Generates a binary colexicographical comparator\nfrom a binary comparator.\n\nhttps://en.wikipedia.org/wiki/Lexicographical_order#Colexicographic_order\n\ncompare( a, b ) should always return\n  - a negative value if a < b\n  - a positive value if a > b\n  - zero if a === b\n\ncompare should express an increasing ordering","name":"colexicographical","kind":"function","longname":"colexicographical","scope":"global"},{"comment":"/**\n* Generates a binary colexicographical comparator for fixed size arrays.\n*\n* https://en.wikipedia.org/wiki/Lexicographical_order#Colexicographic_order\n*\n* compare( a , b ) should always return\n*   - a negative value if a < b\n*   - a positive value if a > b\n*   - zero if a === b\n*\n*/","meta":{"range":[304,617],"filename":"fixedcolexicographical.js","lineno":14,"path":"/js/src/lexicographical","code":{"id":"astnode1085947180","name":"fixedcolexicographical","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare","len"]},"vars":{"":false}},"description":"Generates a binary colexicographical comparator for fixed size arrays.\n\nhttps://en.wikipedia.org/wiki/Lexicographical_order#Colexicographic_order\n\ncompare( a , b ) should always return\n  - a negative value if a < b\n  - a positive value if a > b\n  - zero if a === b","name":"fixedcolexicographical","kind":"function","longname":"fixedcolexicographical","scope":"global"},{"comment":"/**\n* Generates a binary lexicographical comparator for fixed size arrays.\n*\n* https://en.wikipedia.org/wiki/Lexicographical_order\n*\n* compare( a , b ) should always return\n*   - a negative value if a < b\n*   - a positive value if a > b\n*   - zero if a === b\n*\n*/","meta":{"range":[280,596],"filename":"fixedlexicographical.js","lineno":14,"path":"/js/src/lexicographical","code":{"id":"astnode1400175288","name":"fixedlexicographical","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare","len"]},"vars":{"":false}},"description":"Generates a binary lexicographical comparator for fixed size arrays.\n\nhttps://en.wikipedia.org/wiki/Lexicographical_order\n\ncompare( a , b ) should always return\n  - a negative value if a < b\n  - a positive value if a > b\n  - zero if a === b","name":"fixedlexicographical","kind":"function","longname":"fixedlexicographical","scope":"global"},{"comment":"/**\n* Generates a binary lexicographical comparator\n* from a binary comparator.\n*\n* https://en.wikipedia.org/wiki/Lexicographical_order\n*\n* compare( a, b ) should always return\n*   - a negative value if a < b\n*   - a positive value if a > b\n*   - zero if a === b\n*\n* compare should express an increasing ordering\n*/","meta":{"range":[334,683],"filename":"lexicographical.js","lineno":16,"path":"/js/src/lexicographical","code":{"id":"astnode204592882","name":"lexicographical","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare"]},"vars":{"":false}},"description":"Generates a binary lexicographical comparator\nfrom a binary comparator.\n\nhttps://en.wikipedia.org/wiki/Lexicographical_order\n\ncompare( a, b ) should always return\n  - a negative value if a < b\n  - a positive value if a > b\n  - zero if a === b\n\ncompare should express an increasing ordering","name":"lexicographical","kind":"function","longname":"lexicographical","scope":"global"},{"comment":"/**\n* Generates a binary quasicolexicographical comparator\n* from a binary comparator.\n*\n* https://en.wikipedia.org/wiki/Lexicographical_order#Quasi-lexicographic_order\n* https://en.wikipedia.org/wiki/Lexicographical_order#Colexicographic_order\n*\n* compare( a, b ) should always return\n*   - a negative value if a < b\n*   - a positive value if a > b\n*   - zero if a === b\n*\n* compare should express an increasing ordering\n*/","meta":{"range":[444,849],"filename":"quasicolexicographical.js","lineno":17,"path":"/js/src/lexicographical","code":{"id":"astnode546561740","name":"quasicolexicographical","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare"]},"vars":{"":false}},"description":"Generates a binary quasicolexicographical comparator\nfrom a binary comparator.\n\nhttps://en.wikipedia.org/wiki/Lexicographical_order#Quasi-lexicographic_order\nhttps://en.wikipedia.org/wiki/Lexicographical_order#Colexicographic_order\n\ncompare( a, b ) should always return\n  - a negative value if a < b\n  - a positive value if a > b\n  - zero if a === b\n\ncompare should express an increasing ordering","name":"quasicolexicographical","kind":"function","longname":"quasicolexicographical","scope":"global"},{"comment":"/**\n* Generates a binary quasilexicographical comparator\n* from a binary comparator.\n*\n* https://en.wikipedia.org/wiki/Lexicographical_order#Quasi-lexicographic_order\n*\n* compare( a, b ) should always return\n*   - a negative value if a < b\n*   - a positive value if a > b\n*   - zero if a === b\n*\n* compare should express an increasing ordering\n*/","meta":{"range":[365,761],"filename":"quasilexicographical.js","lineno":16,"path":"/js/src/lexicographical","code":{"id":"astnode764191203","name":"quasilexicographical","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare"]},"vars":{"":false}},"description":"Generates a binary quasilexicographical comparator\nfrom a binary comparator.\n\nhttps://en.wikipedia.org/wiki/Lexicographical_order#Quasi-lexicographic_order\n\ncompare( a, b ) should always return\n  - a negative value if a < b\n  - a positive value if a > b\n  - zero if a === b\n\ncompare should express an increasing ordering","name":"quasilexicographical","kind":"function","longname":"quasilexicographical","scope":"global"},{"comment":"/**\n* Generates a binary colexicographical comparator for ranges of arrays.\n*\n* https://en.wikipedia.org/wiki/Lexicographical_order#Colexicographic_order\n*\n* compare( a , b ) should always return\n*   - a negative value if a < b\n*   - a positive value if a > b\n*   - zero if a === b\n*\n*/","meta":{"range":[303,636],"filename":"rangedcolexicographical.js","lineno":14,"path":"/js/src/lexicographical","code":{"id":"astnode1219450701","name":"rangedcolexicographical","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare","begin","end"]},"vars":{"":false}},"description":"Generates a binary colexicographical comparator for ranges of arrays.\n\nhttps://en.wikipedia.org/wiki/Lexicographical_order#Colexicographic_order\n\ncompare( a , b ) should always return\n  - a negative value if a < b\n  - a positive value if a > b\n  - zero if a === b","name":"rangedcolexicographical","kind":"function","longname":"rangedcolexicographical","scope":"global"},{"comment":"/**\n* Generates a binary lexicographical comparator for ranges of arrays.\n*\n* https://en.wikipedia.org/wiki/Lexicographical_order\n*\n* compare( a , b ) should always return\n*   - a negative value if a < b\n*   - a positive value if a > b\n*   - zero if a === b\n*\n*/","meta":{"range":[279,610],"filename":"rangedlexicographical.js","lineno":14,"path":"/js/src/lexicographical","code":{"id":"astnode1227528003","name":"rangedlexicographical","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare","begin","end"]},"vars":{"":false}},"description":"Generates a binary lexicographical comparator for ranges of arrays.\n\nhttps://en.wikipedia.org/wiki/Lexicographical_order\n\ncompare( a , b ) should always return\n  - a negative value if a < b\n  - a positive value if a > b\n  - zero if a === b","name":"rangedlexicographical","kind":"function","longname":"rangedlexicographical","scope":"global"},{"comment":"","meta":{"range":[5,105],"filename":"reverse.js","lineno":2,"path":"/js/src","code":{"id":"astnode314589054","name":"reverse","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["compare"]},"vars":{"":false}},"undocumented":true,"name":"reverse","kind":"function","longname":"reverse","scope":"global"},{"comment":"","meta":{"range":[5,69],"filename":"sign.js","lineno":2,"path":"/js/src","code":{"id":"astnode158016789","name":"sign","type":"FUNCTION","node":"<Object>","value":"FUNCTION","paramnames":["v"]}},"undocumented":true,"name":"sign","kind":"function","longname":"sign","scope":"global"}]}

npm install inchjs

I'm tried adding InchJS to a grunt plugin project. After running "npm install inchjs" and trying "inchjs", I get "-bash: inch: command not found"

If I use the full path of the bin, it seems to work...

jd:grunt-jira-actions jd$ node_modules/inchjs/bin/inchjs

# Undocumented:
┃  U  →  group.createJiraIssue_asValidStoryDescrFromOption_should_PASS in /test/createJiraIssue_tests.js
┃  U  →  group.createJiraIssue_asValidStoryWithPriority_should_PASS in /test/createJiraIssue_tests.js
...

When I install globally, it works...

jd:grunt-jira-actions jd$ npm install inchjs -g
/usr/local/bin/inchjs -> /usr/local/lib/node_modules/inchjs/bin/inchjs
[email protected] /usr/local/lib/node_modules/inchjs
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
jd:grunt-jira-actions jd$ inchjs

# Undocumented:
┃  U  →  group.createJiraIssue_asValidStoryDescrFromOption_should_PASS in /test/createJiraIssue_tests.js
┃  U  →  group.createJiraIssue_asValidStoryWithPriority_should_PASS in /test/createJiraIssue_tests.js
┃  U  →  group.createJiraIssue_asValidTaskDescrFromFile_should_PASS in /test/createJiraIssue_tests.js
┃  U  →  group.createJiraIssue_asValidStoryMarkedDone_should_PASS in /test/createJiraIssue_tests.js

Any idea why the --save-dev install isn't working?

Getting "301 Moved Permanently" when run locally

When I'm trying to run inchjs locally, I'm getting the following:

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.2.1</center>
</body>
</html>

After some debugging I found that the issue is with using http module, and now the API endpoint is moved to https://inch-ci.org/api/v1/cli (http >> https)

es6 syntax support

Trying to run inchjs on the following file

$ cat js/src/map/map.js 

let map = function* ( callable , iterable ) {

    for ( let item of iterable ) yield callable( item ) ;

} ;

exports.map = map ;

I get a parsing error

$ inchjs js/src/map/map.js

[InchJS] Parsing failed.

How difficult would it be to allow es6 syntax in inch/inchjs?

[InchJS] Parsing failed using v10.16.0

Node version: v10.16.0
npm version: 6.9.0

I tried installing InchJS using

npm install inchjs --save-dev

But it gave me the following error

found 1 high severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

The result of npm audit

│ High │ Regular Expression Denial of Service
│ Package │ minimatch
│ Patched in │ >=3.0.2
│ Dependency of │ inchjs [dev]
│ Path │ inchjs > glob > minimatch
│ More info │ https://npmjs.com/advisories/118

When i tried to run npm audit fix as suggested, the issue was not fixed and i got:

npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but npm-shrinkwrap.json was generated for lockfileVersion@0. I'll try to do my best with it!
removed 4 packages in 17.92s
fixed 0 of 1 vulnerability in 886146 scanned packages
  1 vulnerability required manual review and could not be updated

Unify config syntax with Inch

Rather than using a specific inch.json file, use a .inch.yml config file.

Even though for InchJS itself, inch.json is more standard for JS projects, for Inch-CI, .inch.yml convention (invisible file, named after the name of a service, in YAML) is aligned with that of many other CI services.

[InchJS] Parsing failed with node v4.1.2 and v5.0.0

Note that I'm not running inchjs over any es6 code. Works fine with node v0.12.7.

[InchJS] Parsing failed.

npm ERR! Darwin 15.0.0
npm ERR! argv "/Users/boris/.nvm/versions/node/v4.1.2/bin/node" "/Users/boris/.nvm/versions/node/v4.1.2/bin/npm" "run" "inch" "echo" "1"
npm ERR! node v4.1.2
npm ERR! npm  v2.14.4
npm ERR! code ELIFECYCLE

Use "jsdoc-api" lib instead of "jsdoc" cli

Why jsdoc-api?

A programmatic interface for jsdoc3 with a few features:

Sync and async (Promise) interfaces on the two main jsdoc operations ('explain' and 'render documentation').
Input (source code) can supplied as a string or set of file names/globs.
Optional caching, dramatically speeding up future invocations with the same input.
Supports html input

[InchJS] Parsing failed. on windows

It is because find on windows is a different one. https://github.com/rrrene/inchjs/blob/master/lib/docs/jsdoc_runner.js#L49

Just tested simply return "jsdoc"; because i have installed this global. But then it returns only the js doc commandline help. Seems that shelljs does not pass parms correctly on windows.
Do you think it is possible to require("jsdocs") or something like that to avoid shell issues over different platforms? It is not optimal that {silent: true} eats all shell errors.

@example not identified

take a look at http://inch-ci.org/github/sagiegurari/angular-web-notification
specifically at function webNotification.showNotification
it has an example tag (see below), but i still get
Suggestions:
Add a code example (optional).

webNotification.showNotification('Example Notification', {
body: 'Notification Text...',
icon: 'my-icon.ico'
}, function onShow(error, hide) {
if (error) {
window.alert('Unable to show notification: ' + error.message);
} else {
setTimeout(function hideNotification() {
hide();
}, 5000);
}
});

Sending the parsed data directly to runner

So instead of writing to the file-system and passing the filename, then reading it again, it's better and much faster to directly passing the data

So instead of:

function runApiInch(inch_args, filename) {
  inch_args = inch_args || [];
  var json = JSON.parse( fs.readFileSync(filename) );
  json['args'] = inch_args;
  var data = JSON.stringify(json);
  var url = require('url').parse(getInchCliEndPoint());
  var options = {
    host: url.hostname,
    port: url.port,
    path: url.path,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Content-Length': Buffer.byteLength(data, 'utf8')
    }
  };

Do:

function runApiInch(inch_args, parsed_data) {
  ...
  ...

  var options = {
    host: url.hostname,
    port: url.port,
    path: url.path,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Content-Length': Buffer.byteLength(parsed_data, 'utf8')
    }
  };

  ...
  ...

  req.write(parsed_data);

And apply that in all other places.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.