简体   繁体   中英

How do I generate Javadoc Style Documentation for SAHI scripts?

I have written all my tests using sahi-script, because it is the recommended way of working with this tool: https://sahipro.com/docs/using-sahi/recommended-usage.html#Language%20Recommendation

Now I need to do a documentation in Javadoc style and I tried to run Javadoc. I thought maybe, because: "The JS version can also call and reuse any Java code or libraries, so you can have the simplicity of JS but also use the power of Java when needed." it would work, but instead I got this:

>javadoc baum.sah
>Loading source files for package baum.sah...
>javadoc warning: No source files for package baum.sah
>Constructing Javadoc information...
>javadoc warning: No source files for package baum.sah
>javadoc error: No public or protected classes found to document.
>1 error
>2 warnings

My questions are:

1.) Is there any way to get a Javadoc style documentation without having to rewrite all the SAHI-script code in Java?

2.) If yes, how did you do it step by step?

Sahi code is in Javascript, well a wrapper over javascript. You can use jsdoc3 ( https://github.com/jsdoc3/jsdoc ) to generate javadoc style documentation for your sahi scripts. If you check in older versions of Sahi (around 5.2), there is a file called apis.sah where jsdoc3 style documentation is present.

Here is my step by step answer how I did it, since running jsdoc-toolkit did not work on .sah-files. Precondition is that you have downloaded and installed java: http://www.java.com/de/download/windows_xpi.jsp

1.)convert .sah-files into .js-files 

Sahi' s .sah-files can be converted to .js-files: https://sahipro.com/docs/faq/eclipse-integration.html

2.)download a js-toolkit and unzip it

It is best you follow these easy instructions: https://code.google.com/p/jsdoc-toolkit/wiki/InstallJsdoc

I do not recommend to download node.js and using npm to install jsdoc on Windows 7, because you will run into a lot of issues like I did: https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows

3.)open a cmd and run the command where you unzipped the jsdoc-toolkit

path_where_unzipped_folder\jsdoc_toolkit-2.4.0\jsdoc-toolkit>java -jar jsrun.jar app/run.js your_path_to_file\anyfile.js -t=templates\jsdoc 


4.)look up your generated documentation html files here:

path_where_unzipped_folder\jsdoc_toolkit-2.4.0\jsdoc-toolkit\out\jsdoc

Look up JSDoc docmentation usage here: http://usejsdoc.org/index.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM