Skip to content

Commit

Permalink
Add documentation notes
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Jan 17, 2016
1 parent 7985653 commit 882faf0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
9 changes: 9 additions & 0 deletions docs/api_js.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,17 @@ NetworkTables Interface

:param key: A networktables key
:returns: true if a key is present in NetworkTables, false otherwise

.. warning:: This may not return correct results when the websocket is not
connected

.. js:function:: NetworkTables.getKeys()

:returns: all the keys in the NetworkTables

.. warning:: This may not return correct results when the websocket is not
connected

.. js:function:: NetworkTables.getValue(key[, defaultValue])

Returns the value that the key maps to. If the websocket is not
Expand All @@ -107,6 +113,9 @@ NetworkTables Interface
:param defaultValue: If the key isn't present in the table, return this instead
:returns: value of key if present, ``undefined`` or ``defaultValue`` otherwise

.. warning:: This may not return correct results when the websocket is not
connected

.. note:: To make a fully dynamic webpage that updates when the robot
updates values, it is recommended (and simpler) to use
:func:`addKeyListener` or :func:`addGlobalListener` to listen
Expand Down
17 changes: 15 additions & 2 deletions pynetworktables2js/js/networktables.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,22 @@ var NetworkTables = new function () {
}
};

// Returns true/false if key is in NetworkTables
/**
Returns true/false if key is in NetworkTables
.. warning:: This may not return correct results when the websocket is not
connected
*/
this.containsKey = function(key) {
return ntCache.has(key);
};

// Returns all the keys in the NetworkTables
/**
Returns all the keys in the NetworkTables
.. warning:: This may not return correct results when the websocket is not
connected
*/
this.getKeys = function() {
return ntCache.getKeys();
};
Expand All @@ -200,6 +210,9 @@ var NetworkTables = new function () {
:param defaultValue: If the key isn't present in the table, return this instead
:returns: value of key if present, ``undefined`` or ``defaultValue`` otherwise
.. warning:: This may not return correct results when the websocket is not
connected
.. note:: To make a fully dynamic webpage that updates when the robot
updates values, it is recommended (and simpler) to use
:func:`addKeyListener` or :func:`addGlobalListener` to listen
Expand Down

0 comments on commit 882faf0

Please sign in to comment.