twobob / jsdoc-toolkit

Automatically exported from code.google.com/p/jsdoc-toolkit
0 stars 0 forks source link

Allow object properties with quotes to be used for automatic documentation #293

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Try to document an object property with quote marks around it. This is not 
currently supported in v2 due to the possibility of encountering "hello.world": 
... - this is an ambiguous statement. However it can be useful:

- var o = { delete: "whatever" }; will fail in Safari since 'delete' 
is a key word. 

-
var name = "Allan"; 
var o = { name: "Allan" }; - is the 'name' property a variable or a 
literal. Easy to accidently call a local variable the same as a 
property name - in which case bad things will happen... 

- It's not valid JSON to not have double quotes :-)

What is the expected output? What do you see instead?
I would expect the quotes not to make any different to something like:

/** 
 * start point
 *  @property saveStart
 *  @type     int
 *  @default  -1
 */
saveStart: -1,

/** 
 * start point
 *  @property saveStart
 *  @type     int
 *  @default  -1
 */
"saveStart": -1,

What version of the product are you using? On what operating system?
2.3.2 on Mac OS X 10.5.6

Please provide any additional information below.
Discussion: 
http://groups.google.com/group/jsdoc-2/browse_thread/thread/887337b34d12957c

Original issue reported on code.google.com by allan.ja...@gmail.com on 25 Jun 2010 at 1:42

GoogleCodeExporter commented 8 years ago

Original comment by micmath on 25 Jun 2010 at 3:52

GoogleCodeExporter commented 8 years ago

Original comment by micmath on 25 Jun 2010 at 3:53

GoogleCodeExporter commented 8 years ago
Patch for revision 841 to allow quotes around an object property. The way it 
works is to make use of the existing qoute quotes string finding function and 
then 'look' to see if the next character is a colon - if so then it must be a 
property name, and is assigned as such (striped of the quote marks).

A small change has had to be made to the TextStream.look function to allow 
consideration of whitespace. For example '"a" :...' and '"a":...' are both 
perfectly valid. Furthermore a warning is generated if the object name as a 
literal string includes a dot in it.

Original comment by allan.ja...@gmail.com on 26 Jun 2010 at 2:12

Attachments:

GoogleCodeExporter commented 8 years ago
Committed in revision 842. Thank you for contributing!

Original comment by micmath on 27 Jun 2010 at 8:24