"namespacing" methods on prototypes

43 views
Skip to first unread message

anutron

unread,
Apr 8, 2011, 1:54:17 PM4/8/11
to JSDoc Users
Hi all.

First time caller here. I'm doing some doc work and I've started using
JsDoc and so far I'm super impressed. I have a few questions and
apologies if these have been answered elsewhere. I've done my googling
and I've read through most of the posts here. On with the questions!

If I have an extension to a prototype (like, say, String) I have
something like this:

String.implement(/** @lends String */{
/** some docs */
fooify: function(){ return this + "foo"; }
});

First, is this the proper thing to do? If I have String extensions in
several files, I end up lending it more than once. I run the docs with
-m so that I don't get warnings and this seems to work. Is this
proper?

Second question:

Given that I have functionality to support Foo.FeatureA in
Foo.FeatureA.js and functionality for Foo.FeatureB in Foo.FeatureB.js,
it's annoying to me that I can't organize my docs that way if both
files alter a prototype that they share. Instead, all the methods for,
say, a shared Foo object, end up on the Foo page in the docs output.
This removes the context that I'd prefer to have with my docs; I want
the extension to the prototype to be in with the feature, or at least
to be grouped together on the same page. Is there a way to have all
the Foo stuff in FeatureA grouped? If not, can I have
Foo.FeatureA.FooStuff and Foo.FeatureB.FooStuff, so that the two
aren't intermingled?

Thanks in advance for any advice you might have.

Donny Viszneki

unread,
Apr 8, 2011, 4:14:33 PM4/8/11
to anutron, JSDoc Users
Extending standard Javascript objects is widely regarded as a very
troublesome practice. Object and Array are the ones I know are very
bad to extend. Perhaps there's nothing wrong with extending String,
but I just thought I would mention it since you asked!

Where does the implement() method come from?

> --
> You received this message because you are subscribed to the Google Groups "JSDoc Users" group.
> To post to this group, send email to jsdoc...@googlegroups.com.
> To unsubscribe from this group, send email to jsdoc-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jsdoc-users?hl=en.
>
>

--
http://codebad.com/

Aaron Newton

unread,
Apr 8, 2011, 4:27:16 PM4/8/11
to Donny Viszneki, JSDoc Users
String is an example here. Even if you aren't changing the prototype of a native object the question is the same.


Where does the implement() method come from?

Reply all
Reply to author
Forward
0 new messages