Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated code documentation #20

Merged
merged 7 commits into from Dec 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -9,6 +9,11 @@ https://commons.wikimedia.org/wiki/File:Wikibase_JavaScript_Data_Model_1.0.svg

## Release notes

### 1.0.2 (dev)

#### Enhancements
* Updated code documentation for being able to automatically generate a proper documentation using JSDuck.

### 1.0.1 (2014-11-05)
* Using DataValues JavaScript 0.6.x.

Expand Down
2 changes: 1 addition & 1 deletion init.php
@@ -1,6 +1,6 @@
<?php

define( 'WIKIBASE_DATAMODEL_JAVASCRIPT_VERSION', '1.0' );
define( 'WIKIBASE_DATAMODEL_JAVASCRIPT_VERSION', '1.0.2-dev' );

if ( defined( 'MEDIAWIKI' ) ) {
call_user_func( function() {
Expand Down
30 changes: 19 additions & 11 deletions src/Claim.js
@@ -1,18 +1,19 @@
/**
* @licence GNU GPL v2+
* @author Daniel Werner < daniel.werner@wikimedia.de >
*/
( function( wb, $ ) {
'use strict';

/**
* @constructor
* Object featuring a main snak and a list of qualifiers.
* @class wikibase.datamodel.Claim
* @since 0.3
* @licence GNU GPL v2+
* @author Daniel Werner < daniel.werner@wikimedia.de >
*
* @constructor
*
* @param {wikibase.datamodel.Snak} mainSnak
* @param {wikibase.datamodel.SnakList|null} [qualifiers]
* @param {string|null} [guid] The Global Unique Identifier of this Claim. Can be omitted or null
* if this is a new Claim, not yet stored in the database and associated with some entity.
* @param {wikibase.datamodel.SnakList|null} [qualifiers=new wikibase.datamodel.SnakList()]
* @param {string|null} [guid=null] The Global Unique Identifier of this Claim. Can be null if this
* is a new Claim, not yet stored in the database and associated with some entity.
*/
var SELF = wb.datamodel.Claim = function WbDataModelClaim( mainSnak, qualifiers, guid ) {
this.setMainSnak( mainSnak );
Expand All @@ -22,17 +23,20 @@ var SELF = wb.datamodel.Claim = function WbDataModelClaim( mainSnak, qualifiers,

$.extend( SELF.prototype, {
/**
* @type {wikibase.datamodel.Snak}
* @property {wikibase.datamodel.Snak}
* @private
*/
_mainSnak: null,

/**
* @type {wikibase.datamodel.SnakList}
* @property {wikibase.datamodel.SnakList}
* @private
*/
_qualifiers: null,

/**
* @type {string|null}
* @property {string|null}
* @private
*/
_guid: null,

Expand All @@ -59,6 +63,8 @@ $.extend( SELF.prototype, {
* Overwrites the current main Snak.
*
* @param {wikibase.datamodel.Snak} mainSnak
*
* @throws {Error} if parameter is not a Snak instance.
*/
setMainSnak: function( mainSnak ) {
if( !( mainSnak instanceof wb.datamodel.Snak ) ) {
Expand Down Expand Up @@ -88,6 +94,8 @@ $.extend( SELF.prototype, {

/**
* @param {wikibase.datamodel.SnakList} qualifiers
*
* @throws {Error} if parameter is not a SnakList instance.
*/
setQualifiers: function( qualifiers ) {
if( !( qualifiers instanceof wb.datamodel.SnakList ) ) {
Expand Down
15 changes: 8 additions & 7 deletions src/ClaimGroup.js
@@ -1,18 +1,19 @@
/**
* @licence GNU GPL v2+
* @author H. Snater < mediawiki@snater.com >
*/
( function( wb ) {
'use strict';

var PARENT = wb.datamodel.Group;

/**
* Ordered list of Claim objects, each featuring the same property id.
* @constructor
* List of Claim objects, constrained to a single property id.
* @class wikibase.datamodel.ClaimGroup
* @extends wikibase.datamodel.Group
* @since 1.0
* @licence GNU GPL v2+
* @author H. Snater < mediawiki@snater.com >
*
* @constructor
*
* @param {wikibase.datamodel.ClaimList} [claimList]
* @param {wikibase.datamodel.ClaimList} [claimList=new wikibase.datamodel.ClaimList()]
*/
wb.datamodel.ClaimGroup = util.inherit( 'wbClaimGroup', PARENT, function( propertyId, claimList ) {
PARENT.call( this, propertyId, wb.datamodel.ClaimList, 'getPropertyIds', claimList );
Expand Down
14 changes: 8 additions & 6 deletions src/ClaimGroupSet.js
@@ -1,17 +1,19 @@
/**
* @licence GNU GPL v2+
* @author H. Snater < mediawiki@snater.com >
*/
( function( wb ) {
'use strict';

var PARENT = wb.datamodel.Set;

/**
* @constructor
* Set of ClaimGroup objects.
* @class wikibase.datamodel.ClaimGroupSet
* @extends wikibase.datamodel.Set
* @since 1.0
* @licence GNU GPL v2+
* @author H. Snater < mediawiki@snater.com >
*
* @constructor
*
* @param {wikibase.datamodel.ClaimGroup[]} [claimGroups]
* @param {wikibase.datamodel.ClaimGroup[]} [claimGroups=new wikibase.datamodel.ClaimGroup]
*/
wb.datamodel.ClaimGroupSet = util.inherit( 'WbDataModelClaimGroupSet',
PARENT,
Expand Down
13 changes: 7 additions & 6 deletions src/ClaimList.js
@@ -1,17 +1,18 @@
/**
* @licence GNU GPL v2+
* @author H. Snater < mediawiki@snater.com >
*/
( function( wb, $ ) {
'use strict';

var PARENT = wb.datamodel.List;

/**
* @constructor
* List of Claim objects.
* @class wikibase.datamodel.ClaimList
* @since 1.0
* @licence GNU GPL v2+
* @author H. Snater < mediawiki@snater.com >
*
* @constructor
*
* @param {wikibase.datamodel.Claim[]} [claims]
* @param {wikibase.datamodel.Claim[]} [claims=[]]
*/
wb.datamodel.ClaimList = util.inherit( 'WbDataModelClaimList', PARENT, function( claims ) {
PARENT.call( this, wikibase.datamodel.Claim, claims );
Expand Down
28 changes: 19 additions & 9 deletions src/Entity.js
@@ -1,33 +1,39 @@
/**
* @licence GNU GPL v2+
* @author H. Snater < mediawiki@snater.com >
*/
( function( wb, $ ) {
'use strict';

/**
* @constructor
* Abstract Entity base class featuring an id and a fingerprint.
* @class wikibase.datamodel.Entity
* @abstract
* @since 0.3
* @licence GNU GPL v2+
* @author H. Snater < mediawiki@snater.com >
*
* @constructor
*
* @throws {Error} when trying to instantiate since Entity is abstract.
*/
var SELF = wb.datamodel.Entity = function WbDataModelEntity() {
throw new Error( 'Cannot construct abstract Entity object' );
};

/**
* String to identify this type of Entity.
* @type {string}
* @property {string} [TYPE=null]
* @static
*/
SELF.TYPE = null;

$.extend( SELF.prototype, {
/**
* @type {string}
* @property {string}
* @private
*/
_id: null,

/**
* @type {wikibase.datamodel.Fingerprint}
* @property {wikibase.datamodel.Fingerprint}
* @private
*/
_fingerprint: null,

Expand Down Expand Up @@ -62,12 +68,16 @@ $.extend( SELF.prototype, {
},

/**
* @abstract
*
* @return {boolean}
*/
isEmpty: util.abstractMember,

/**
* @param {*}
* @abstract
*
* @param {*} entity
* @return {boolean}
*/
equals: util.abstractMember
Expand Down
40 changes: 28 additions & 12 deletions src/EntityId.js
@@ -1,18 +1,22 @@
/**
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
( function( wb, dv, util ) {
'use strict';

var PARENT = dv.DataValue;

/**
* @constructor
* EntityId data value.
* @class wikibase.datamodel.EntityId
* @extends dataValues.DataValue
* @since 0.3
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*
* @constructor
*
* @param {string} entityType
* @param {number} numericId
*
* @throws {Error} if a required parameter is not specified properly.
*/
wb.datamodel.EntityId = util.inherit(
'WbDataModelEntityId',
Expand All @@ -32,12 +36,14 @@ wb.datamodel.EntityId = util.inherit(
},
{
/**
* @type {string}
* @property {string}
* @private
*/
_entityType: null,

/**
* @type {number}
* @property {number}
* @private
*/
_numericId: null,

Expand All @@ -60,6 +66,9 @@ wb.datamodel.EntityId = util.inherit(
* If the same entity type appears multiple times with different prefixes, the prefix
* found first will be applied.
* @return {string}
*
* @throws {Error} when the prefix map does not contain a prefix for the entity type set on the
* object.
*/
getPrefixedId: function( prefixMap ) {
var entityType = this._entityType;
Expand All @@ -76,7 +85,7 @@ wb.datamodel.EntityId = util.inherit(
},

/**
* @see dataValues.DataValue.equals
* @inheritdoc
*/
equals: function( entityId ) {
return entityId === this
Expand All @@ -86,7 +95,7 @@ wb.datamodel.EntityId = util.inherit(
},

/**
* @see dataValues.DataValue.getValue
* @inheritdoc
*
* @return {wikibase.datamodel.EntityId}
*/
Expand All @@ -95,14 +104,14 @@ wb.datamodel.EntityId = util.inherit(
},

/**
* @see dataValues.DataValue.getSortKey
* @inheritdoc
*/
getSortKey: function() {
return this._entityType + this._numericId;
},

/**
* @see dataValues.DataValue.toJSON
* @inheritdoc
*/
toJSON: function() {
return {
Expand All @@ -113,12 +122,19 @@ wb.datamodel.EntityId = util.inherit(
} );

/**
* @see dataValues.DataValue.newFromJSON
* @inheritdoc
* @static
*
* @return {wikibase.datamodel.EntityId}
*/
wb.datamodel.EntityId.newFromJSON = function( json ) {
return new wb.datamodel.EntityId( json['entity-type'], json['numeric-id'] );
};

/**
* @inheritdoc
* @property {string} [TYPE='wikibase-entityid']
*/
wb.datamodel.EntityId.TYPE = 'wikibase-entityid';

dv.registerDataValue( wb.datamodel.EntityId );
Expand Down