0.0.10 • Published 8 years ago

fundoc v0.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

###Fundoc (pre alpha)

npm.io

Fundoc is a library which allow you to parse docstring from js files in your project. It uses special type annotations (functinal style), like this map :: ( a -> b ) -> a -> b. It allows you to improve an expression of a documentation.

####Why you should care?

For exmaple. In a jsdoc style docstrings look line this:

/**
 * Takes a function and
 * an array, applies the function to each of 
 * the array's values, and returns an result array.
 * @param {Function} fn The function to be called on every element of the input array.
 * @param {Array} array The array to be iterated over.
 * @return {Array} The new array.
 */
const map => (func, array) => { /* some code */; return result }

Ok... Let's take a look on the Sort and Filter functions:

/**
 * Takes a function and
 * an array, applies the function to each of 
 * the array's values, and returns an result array.
 * @param {Function} fn The function to be called on every element of the input array.
 * @param {Array} array The array to be iterated over.
 * @return {Array} The new array.
 */
const sort => (func, array) => { /* some code */; return result }

/**
 * Takes a function and
 * an array, applies the function to each of 
 * the array's values, and returns an result array.
 * @param {Function} fn The function to be called on every element of the input array.
 * @param {Array} array The array to be iterated over.
 * @return {Array} The new array.
 */
const filter => (func, array) => { /* some code */; return result }

Wow! We can just copy whole dosctrings from the Map function and then paste it above the Sort and Filter functions.

What does that tell us? It tells that these docstrings are useless. You can say that it is because of silly description. But it is not.

If we remove these descriptions we will see that formal part of the docstrings tell us nothing too.

####What we can do?

Let's rewrite our docstring in the Fundoc style (and we even retain old descriptions).

/**
 * Takes a function and
 * an array, applies the function to each of 
 * the array's values, and returns an result array.
 * @ftype map :: ( a -> b ) -> [a] -> [b]
 */

const map => (func, array) => { /* some code */; return result }

/**
 * Takes a function and
 * an array, applies the function to each of 
 * the array's values, and returns an result array.
 * @ftype sort :: ( a -> a -> Number ) -> [a] -> [a]
 */

const sort => (func, array) => { /* some code */; return result }

/**
 * Takes a function and
 * an array, applies the function to each of 
 * the array's values, and returns an result array.
 * @ftype filter :: ( a -> Boolean ) -> [a] -> [a]
 */

const filter => (func, array) => { /* some code */; return result }

Now our functions' docstrings look more expressive, do they?

####How Fundoc works?

Now it's a CLI tool that you can use. First of all, you should install it:

npm i -g fundoc

After that you can see "help" of the Fundoc:

fundoc --help

  Usage: fundoc [options] <file> or <directory>

  Options:

    -h, --help             output usage information
    -V, --version          output the version number
    -d, --directory [dir]  A directory that contains source code
    -f, --file [file]      A source code file
    -p, --parse [text]     Parse type from a passed text
    -o, --output [file]    Save result as a JSON file
    --print                Print result in a terminal

And of course after that you can use it:

fundoc -d path/to/your/project

#NOTE This is only the beginning! Fundoc is not a standalone project. Yes, now it's a CLI tool, but in the future it will be only parser for a new documentation generator, which will able to create static web site, markdown documents, gitbook (etc.) from your documentaion.

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago