find-api

0.1.3 • Public • Published

node-find-api Travis-CI.org Build Status Coveralls.io Coverage Rating

Finds all of the API calls and docs in a source file

This package is a highly-specialized, glorified regex engine that finds all API calls in a file.

For most languages, the documentation comment block starts with a double-star block comment (e.g. /**), though languages that do not have these style of comments will require looking up the proper format in langs.js.

Example

var findAPI = require('find-api');
var fs = require('fs');
 
var testJs = fs.readFileSync('./test.js').toString();
var testC = fs.readFileSync('./test.c').toString();
 
var jsAPIs = findAPI(testJs, 'js');
var cAPIs = findAPI(testC, 'c');
 
/*
    test.js:
 
    [
        { doc: "This is a documented function.",
          api: "var bar = function (a, b, c);"
        }
    ]
 
    test.c:
 
    [
        { doc: "Documented function.",
          api: "struct some_struct_t *some_func(void);"
        }
    ]
*/

test.js

/**
 * This is a documented function.
 */
var bar = function (a, b, c) {
    return a + b + c;
};

test.c

/**
    Documented function.
 */
struct some_struct_t *
some_func(void) {
    return malloc(sizeof(some_struct_t));
}

License

Licensed under the MIT License. You can find a copy of it in LICENSE.

Package Sidebar

Install

npm i find-api

Weekly Downloads

1

Version

0.1.3

License

MIT

Last publish

Collaborators

  • qix