Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run jsdoc on whole directory in ubuntu

Tags:

jsdoc

jsdoc3

I just need to run jsdoc on ai whole directory containing .js files, I am doing this on individual files in ubuntu terminal by issuing command jsdoc abc.js but what I need is to apply this command on all files in the directory at once,so that all files in that directory containg js files would be generated by a single command. Thanks for any help you would give.

like image 374
SQA Avatar asked Nov 01 '16 04:11

SQA


People also ask

Does JSDoc work with TypeScript?

You can use most JSDoc type syntax and any TypeScript syntax, from the most basic like string to the most advanced, like conditional types.

What is the use of JSDoc?

JSDoc is a markup language used to annotate JavaScript source code files. Using comments containing JSDoc, programmers can add documentation describing the application programming interface of the code they're creating.


2 Answers

Even though it's only asked how to run JSDoc for a specific directory, I think this thread could use some more information so people reading this can be aware of other strategies that could be useful.

Running JSDoc for a specific directory

This is the simplest one and the direct answer to the question. You can run JSDoc for all files inside a directory using the --recurse or -r option.

Example:

$ jsdoc -r ./src/

This will run JSDoc for all files inside the src/ directory and its subdirectories.

Running JSDoc for multiple directories

This and the following sections aren't exactly what the question asked for but hopefully will be useful for people using a search engine that found this thread.

You'll probably need to run JSDoc for all the files located in different directories. For this you can just use multiple arguments with the --recurse option.

Example:

$ jsdoc -r ./client/ ./server/

This will run JSDoc for all files inside both client/ and server/ and its subdirectories.

NOT running JSDoc for some directories

This is slightly more complicated and will require use of JSDoc's configuration file. After creating the configuration file, you can run JSDoc using the --configure (or -c) option to select the configuration file you want to use.

Example: Create a file conf.json as shown bellow:

{
    "source": {
        "include": [ "." ],
        "exclude": [ "node_modules/" ]
    }
}

Then run JSDoc like that:

jsdoc -c ./conf.json -r

With that JSDoc will be run for all files inside your current directory and its subdirectories except for the ones located inside node_modules/ and its subdirectories.

Sources

For more info on the available options for the jsdoc command see here

For more info on the JSDoc configuration file see here

like image 128
Float07 Avatar answered Oct 12 '22 13:10

Float07


You can go recursive by passing -r parameter:

$ jsdoc -r .
like image 27
Dmitry Demidovsky Avatar answered Oct 12 '22 12:10

Dmitry Demidovsky