Git Product home page Git Product logo

rhino's Introduction

Rhino 1.7R3 for JSDoc3

This fork of Mozilla Rhino is intended for use with JSDoc 3 (https://github.com/jsdoc3/jsdoc). The fork incorporates the changes described below.

JSDoc Comment Attachment

The fork modifies the behavior of the parser as it relates to JSDoc comment attachment. Specifically, the parser attaches comments to function calls when present.

Traditionally, there may have not been much reason to do so since JSDoc comments are intended to be used to documentation generation and function calls do not provide any interfaces. However, there are many JavaScript frameworks that use a factory pattern that uses a function call to create classes. For instance jQuery UI has a widget factory for creating plugins. An example call might look something like:

$.widget("ui.mywidget", {
    options: {
        firstOption: true,
        secondOption: "Hello",
        thirdOption: null
    },
    _create: function() {
        this.element.html(this.options.secondOption + " World!");
    },
    destroy: function() {
        this.element.html();
    }
});

Here, the first parameter provides a name for the class and the second provides a prototype that will be used by the factory when creating the class. It would be nice to be able to add a JSDoc comment above the call to provide information about the mywidget class:

/**
 * This widget takes a div element and makes it classic
 * @require UI Core
 * @require UI Widget
 * @example
 *      $('<div/>').mywidget({secondOption: "Hola"});
 */
$.widget("ui.mywidget", ...);

Of course, there are workarounds like assigning the prototype to a variable first and commenting that, but, let's face it, no one really likes to document and making folks change their code just to do so would be asking a bit much.

Node.js/CommonJS Package Support

Although Rhino 1.7R3 included support for loading CommonJS modules, it did not recognize CommonJS/ Node.js packages. This fork adds a new module provider with package support.

For example, suppose the module directory is organized as follows:

|-- foo.js
`-- bar
|   |-- package.json
|   `-- bar.js
`-- baz
    `-- index.js

In Rhino 1.7R3, if a JavaScript file requires the foo, bar, and baz modules, only the foo module will be loaded successfully.

However, in this fork:

  • The foo module will still load successfully.
  • The bar module will load successfully as long as its package.json file includes a main property that is set to ./bar.js.
  • The baz module will load successfully, since the new module provider finds its index.js file.

rhino's People

Contributors

alagopus avatar anba avatar cronik avatar ebourg avatar hegemonic avatar hns avatar ianso avatar ibukanov avatar jannon avatar jbevain avatar mbd-dbc-dk avatar mguillem avatar msmhrt avatar norrisboyd avatar rapha avatar szegedi avatar travisennis avatar tschaub avatar vadimv avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

acidburn0zzz

rhino's Issues

Package implementation needs to look for submodules

If a module has its own node_modules subdirectory, that subdirectory should be part of the module lookup chain. Right now it isn't, which means npm packages with dependencies don't work correctly.

It would be much easier to implement this if we changed the Require class to store the entire module path in the module's id property.

Originally filed as hegemonic#1.

Can't build with ant script

This project can't build since XMLBeans was retired in June 2014. I was able to find the required files to build XMLBeans 2.6.0 and eventually build this project with xbeans.jar and jsr173_1.0_api.jar.

Note: ant will not build with Java 1.8.

  • Builds on Windows 7 JDK 1.7
  • Builds on Windows 8 JDK 1.7
  • Builds on OS X 10.10 JDK 1.7

Here's some info on running ant with the java command: https://ant.apache.org/manual/running.html

For anyone wishing to do this follow here:

  1. Clone XMLBeans: git clone git://git.apache.org/xmlbeans.git or svn checkout http://svn.apache.org/repos/asf/xmlbeans/tags/2.6.0/
  2. Download jsr173_1.0
  3. Move jsr173_1.0.jar to external/lib.
  4. Make a copy of jsr173_1.0.jar and rename the copy to jsr173_1.0_api_bundle.jar
  5. Rename jsr173_1.0.jar to jsr173_1.0_api.jar
  6. Run ant and all files will be in build/lib

To build this jar do the following:

  1. Clone this project git clone https://github.com/jsdoc3/rhino
  2. Copy xbean.jar and jsr173_1.0_api.jar into /lib
  3. Run ant jar

Kind of a hacky way to go about it but I tested js.jar and everything seemed to be working just as well โ€“ all of the tests passed.

Update README

It has the wrong version number, and it doesn't reflect the most recent changes in our fork.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.