Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jehoshua02/2210eeea09d67ea58aee to your computer and use it in GitHub Desktop.
Save jehoshua02/2210eeea09d67ea58aee to your computer and use it in GitHub Desktop.
Example of using json for docblocks
Reusables.Breakpoints.Breakpoint.prototype.jsondoc = {
name: 'Breakpoint',
namespace: 'Reusables.Breakpoints',
type: 'Class',
description: 'Represents a breakpoint on a set of elements.',
params: [
{
name: '$elements',
description: 'Represents set of elements for this breakpoint.',
types: [
{
name: 'Function',
description: 'Function that returns a jquery object. Using a function guarantees dynamically
added elements will be considered when breakpoint is evaluated. For internal consistency,
all other value types will be converted to a function that returns a jQuery object.',
return: {
type: 'jQuery',
description: 'jQuery object representing a set of elements.'
}
},
{
name: 'String',
description: 'A jQuery selector string. Used as a selector string in a function that returns
a jQuery object.'
},
{
name: 'jQuery',
description: 'jQuery object. If the jQuery object has selector string (`$elements.selector`),
this string will be used instead and treated like a String value. Otherwise, jQuery object
is wrapped in a function that returns this jQuery object.'
}
]
},
{
name: 'range',
description: 'Breakpoint range.',
types: [
{
name: 'Reusables.Breakpoints.Range',
description: 'Breakpoint range. Used during evaluation to determine element width matches breakpoint.'
},
{
name: 'Array',
length: 2,
type: 'Integer',
description: 'Array with two values, min and max, as required by Reusables.Breakpoints.Range constructor.'
}
]
},
{
name: 'options',
description: 'An object containing options.',
type: 'Object',
keys: [
{
name: 'name',
description: 'Class name to be added to the element when it's width matches the breakpoint.',
type: 'String',
default: {
value: 'breakpoint-{range.min}-{range.max}',
description: 'Default class name built using min and max.'
}
},
{
name: 'enter',
description: 'Function to execute on each element upon entering breakpoint.',
type: 'Function',
params: [
{
name: '$element',
description: 'The element on which the breakpoint is being evaluated.',
type: 'jQuery'
}
],
default: {
value: 'function () {}',
description: 'Defaults to an empty function for internal consistency.'
}
},
{
name: 'exit',
description: 'Function to execute on each element upon exiting breakpoint.',
type: 'Function',
params: [
{
name: '$element',
description: 'The element on which the breakpoint is being evaluated.',
type: 'jQuery'
}
],
default: {
value: 'function () {}',
description: 'Defaults to an empty function for internal consistency.'
}
}
]
}
],
return: {
type: 'Breakpoint',
description: 'Returns a new Breakpoint instance.'
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment