Using jsDoc in Notepad++ - javascript

I use notepad++ for my JavaScript development now. I am wondering if anyone has successfully integrated jsDoc with notepad++ for easy code commenting.
I was usint Aptana earlier and it was already integrated in it as ScriptDoc I believe but Aptana grew out to be painfully slow.

It it is possible to get jsDoc to work using the NppExec plugin. The steps are pretty straightforward, and should be a lot more straightforward after you read this.
In NPP (I'm using v. 5.9.3) open the plugin manager
Install NppExec plugin. (Npp restarts, I believe)
Go to the NppExec menu under plugins, choose the "Execute" menu option. A tiny scripting window opens.
Enter the following NppExec scriptlet:
NPP_SAVE
cls
SET jsDocPath = e:\javascript\jsdoc
cmd /c if "$(EXT_PART)"==".js" echo "Running JSDoc" && $(jsDocPath)\jsDocMe.cmd $(jsDocPath) "$(FULL_CURRENT_PATH)" "$(CURRENT_DIRECTORY)\jsDoc"
NPP_CONSOLE 0
(the line beginning with cmd and the following line should all appear on one line...)
Explanation: The set command sets a variable for where your jsDoc path is.
The cmd line first checks to see if the currently open file has a .js extension, and if so
it calls a .cmd file called jsDocMe.cmd, text below, passing in the jsDocPath, the full path of the current file, and the directory of the current file. The use of these variables can be seen in the .cmd file. The text of the .cmd file is below, a simple set of batch commands that changes to the jsDoc directory, runs the jsrun.jar file, and sends output to a new jsDoc folder beneath the current working directory.
cd /D %1
java -jar jsrun.jar app\run.js -d=%3 -a -p -t=templates/jsdoc %2
%3\index.html
exit

Notepad++ uses Scintilla, which does not parse inside comments, so I doubt there would be any plugins doing this. (See the comments for this feature request.)

I've been using N++ for JS development for years now, and I'm pretty sure there is no way to get JSDoc going, unless you write your own plugin.
You should always be aware that N++ is not an IDE. I've tested several, and I've always come to the same conclusion as you:
N++ == slim && fast; IDE == feature rich && slow;
IMHO, the IDE with the very best JSDoc support is WebStorm (commercial product).

Related

Embedding Mozilla's JavaScript Engine in C++

I want to embed Mozilla's SpiderMonkey in my standalone C++ program (in Visual Studio 2019). I went over all the documentation and whatnot but the problem is (or what I need is):
Execute a JavaScript script through C++. In pseudo code that'd be Value* result = SpiderMonkeyEvaluate(fileString);
And that's it. The thing is, in the documentation it says I need to build the entirety of Mozilla's Firefox browser (which is not less than a Gigabyte) and download Mercurial and open the command prompt and create directories etc. and all that disgusting stuff. I just need to be able to:
#include <jsapi.h>
And perform all the necessary C++-to-JS (and vice-versa) operations.
I do not think I need to download and build the entire FireFox browser to do this (I maybe wrong?).
If anyone is still interested the spider monkey on Windows, you would follow the build instructions here:
https://firefox-source-docs.mozilla.org/js/build.html
using the build tools here:
https://firefox-source-docs.mozilla.org/setup/windows_build.html
If you are very meticulous you don't need to download the entire FireFox code base but your life will be easier if you do. In order to only build spidermonkey only (plus js command line), be sure to activate a particular MOZCONFIG with
ac_add_options --enable-application=js
in it before calling any of the mach commands.
Note: if you plan to use the Visual C++ compiler and not clang-cl, you are limited to version 78 or you will have to figure out how to modify the header yourself.
for reference this is the config I used to successfully build spidermonkey 81.0.2 on Windows 10:
# Build only the JS shell
ac_add_options --enable-application=js
# Enable optimization for speed
ac_add_options --enable-optimize
# Enable the debugging tools: Assertions, debug only code etc.
# For performance testing you would probably want to change this
# to --disable-debug.
ac_add_options --disable-debug
ac_add_options --disable-jemalloc
ac_add_options --prefix=$MY_PREFIX
mk_add_options MOZ_MAKE_FLAGS="-j4"
# Use a separate objdir for optimized builds to allow easy
# switching between optimized and debug builds while developing.
mk_add_options MOZ_OBJDIR=#TOPSRCDIR#/obj-opt-#CONFIG_GUESS#
If you use this config, after you successfully build,
then navigate to #TOPSRCDIR#/obj-opt-#CONFIG_GUESS# and do mozmake install, it "install" all the files you need into $MY_PREFIX
UPDATE - This answer is wrong. sparse checkout actually downloads all the history. One would have to use the narrowhg ext, which isn't supported on the hg.mozilla.org repo.
the following answer is wrong.
You could use mercurial sparse checkout to just get the js/src folder.
(but with all the history of the js/src folder it will still likely be quite big)
This will just the history for js/src folder.
you need a version of mercurial which is newer then 3 years old (4.3 or newer)
mkdir spidermonkey
cd spirdermonkey
hg init
hg debugsparse --include js/src
hg pull https://hg.mozilla.org/releases/mozilla-release -u

How to run (or build then run?) this Mozilla Rhino Debugger?

Would like to try this Rhino Debugger however having problems
I downloaded latest from here according to doc it says just simply run:
java org.mozilla.javascript.tools.debugger.Main [options] [filename.js] [script-arguments]
however..it's source code, so I probably need to build it first...(unless there are precompiled download out there?). Assuming I need to build it to get the jar file for debugger, I assume just build the build.gradle file at the root dir. Or run gradle tasks build ? When I do that I get error:
Execution failed for task ':checkstyleMain'.Unable to create a Checker: configLocation {C:\rhino\rhino-1.7.8\checkstyle.xml}, classpath {C:\rhino\rhino-1.7.8\buil
dGradle\classes\java\main;C:\rhino\rhino-1.7.8\buildGradle\resources\main}.
So..I'm a bit lost. Been ten years since I've worked with Java, but hopefully I'm missing something simple.
Any experienced Rhino JavaScript devs out there that can point me in the right direction? Should I just stick with using Eclipse? (Had that working, but I'm still curious about this debugger)
Download the latest rhino from the link you provided, at this time it is "rhino-1.7.8.zip". Unzip that and change directory to "rhino1.7.8/lib"; you need the "rhino-1.7.8.jar" in your CLASSPATH. Assuming you are in "rhino1.7.8/lib" that should be in your current folder, and you can then do
java -cp rhino-1.7.8.jar org.mozilla.javascript.tools.debugger.Main
Which should render like

Unable to Run JavaScript in Atom with Script package

I am trying to run JavaScript code in Atom with Script package. It can run Python successfully, but with JS files it gives the following error message:
The system cannot find the file specified.
I had the same problem while analyzing some JavaScript code of an extension for Chrome.
Using: Windows 7 64Bit Atom:1.24.0 x64
Since I my coding Folder is somewhere else I copied the files in that folder. Let’s say:
C:\Users\USER\CodingStuff\
then it started working. I have also tried adding the extension file the Sources via:
1 - CTRL+SHIFT+I
2- Right click -> add folder to workspace
But that did not work.
Side note: node.js has to be installed on the system.
Hope it helps.
I know I am late, but if any other faces the same issue, my answer will be helpful.
Assumed that you want to run your javascript outside browser and you installed node.js.
There is a bug in "script" package of Atom. Check ur path of the script if there are spaces then this leads to the aforementioned error. Work around is remove spaces.
for ex:
E:\Java script\trial.js
change to:
E:\Javascript\trial.js

Is there a way to run JavaScript code inside Aptana Studio 3 IDE?

I created a Test.js file and wrote two lines of JS code in it:
var a = 5;
console.log("The result is = " + a);
The output should be:
"The result is = 5"
Is there a way I can see this in Aptana Scripting console, instead of integrating the JS code in a HTML file and saving/refreshing it?
Can any other IDE, say Netbeans help, if not Aptana?
Any advise would be highly appreciated.
Regards
Roy
I think that it would be best if you give Node.js a try. This way, you get to call node test.js on a console window and see the result.
I'm pretty sure that console is meant for viewing the output of Aptana's Ruby-based commands (installed under the Commands menu). It might be possible to follow the instructions here: http://www.chromium.org/for-testers/enable-logging and then tail the resulting log file in a Terminal panel (not the same as a console window).
I'm afraid it is not possible.
But What I did was to setup a simple workbench.html file, where in the header I put
[...]
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="js/myJsFile.js"></script>
and then modified the myJsFile.js and saved it.
Another very intersting possibility is given by http://www.developer.nokia.com/Community/Wiki/Aptana_WRT_Plugin:_Displaying_log_messages_in_Output_console
just check it
It's not exactly what you asked, but it might point you in the right direction. There's a project called EclipseMonkey ... I'm not sure the status. Here's a working (?) example. Your mileage will vary. http://blogs.edgehill.ac.uk/webservices/2008/10/16/aptana-outline-auto-expansion-monkeyed/
What you can do is you can download node.js from node.js, download the package and follow the installation instructions on the screen.
If using a Windows, the node.js package comes with its own interactive command prompt which you can open. To run a js file on windows, open the windows command prompt, type in node, then the name of your file e.g. test.js. Node.js should run your file.
If using a Mac, the node.js package runs through the terminal application on the mac. To run a file, type in node, then the name of your file e.g. test.js, node.js should run the file.
Aptana Studio 3 has the ability to open the terminal inside the IDE itself. Save your file in Aptana Studio and follow the instructions to run a file on the mac.
By the way, keep your files labelled in lowercase letters, I tried using Uppercase for the first letter and it did not work.
Hope that helps.

How do you automagically minify your JS and CSS on OS X or in Webstorm?

I use two different IDE's based on what I'm doing. My primary IDE is Visual Studio, whereby I use Chirpy to mash and minify my code. It works flawlessly and I love it. Problem is that when I'm not on my Windows box, I don't have access to it.
When not using Visual Studio, I'm usually writing Javascript apps in Webstorm on my Macbook Pro. Here in lies the problem. I haven't found a Webstorm plugin or any other app that I can configure to watch my scripts and mash/minify them.
How do you Mac users mash/minify your JS and CSS at design time with minimal effort?
For those who have now updated to WebStorm 6, this functionality is in-built. Simply go to File (or whatever the Mac equivalent is) -> Settings -> File Watchers and define a file watcher for the type of file you need to watch.
The relevant help documentation is here - http://www.jetbrains.com/webstorm/webhelp/using-file-watchers.html
You could use YUI Compressor without Command Line with these little Apps:
http://www.webmaster-source.com/minimus/ – free
http://www.matmartinez.net/delivery/ – free
I'm neither a Mac nor Webstorm user, but this might still be relevant.
For javascript I use the closure compiler as part of an upload script to minify. It doesn't monitor the files, it runs when I run the upload (a bash file).
If you wanted to keep it all in the IDE, it looks like Webstorm has an Ant plugin http://plugins.intellij.net/plugin/?webide&id=4526 that you could use to execute the closure compiler.
If you can find a command line css minifier then you could put that in the Ant script as well.
I use lessc and uglifyjs to concatenate and minify my css and js files. Here's a makefile from Twitter Bootstrap that I used a modified version of:
https://github.com/twitter/bootstrap/blob/master/Makefile
It's simple since all I do is type make in the command line whenever I want to compile.
I use Minify. It's on the Mac App Store.
I developed it to support my own workflow. minifyapp.com

Categories

Resources