Skip to content

Commit

Permalink
Documentation for define_nls function
Browse files Browse the repository at this point in the history
  • Loading branch information
daveraja committed Oct 21, 2019
1 parent caca645 commit a59a364
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions clorm/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,20 @@ def __repr__(self):
# ------------------------------------------------------------------------------

def define_nls(name,arity):
"""Helper function to dynamically define a predicate or complex-term.
It takes a name and an arity and creates a predicate/complex-term object
that is associated with that predicate name and the given arity. It's
parameters are all specified as RawFields.
This function is particularly useful when used for debugging ASP programs as
it provides output flexibility.
Args:
name: the name of the predicate to match against
arity: the arity for the predicate
"""

# Use an OrderedDict to ensure the correct order of the field arguments
proto = collections.OrderedDict([("arg{}".format(i+1), RawField())
Expand Down Expand Up @@ -1500,6 +1514,7 @@ def _simplify_fact_comparator(comparator):
# an abstract class that exposes no API other than its existence.
# ------------------------------------------------------------------------------
class Placeholder(abc.ABC):

"""An abstract class for defining parameterised queries.
Currently, Clorm supports 4 placeholders: ph1\_, ph2\_, ph3\_, ph4\_. These
Expand Down
2 changes: 2 additions & 0 deletions docs/clorm/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ more intuitive Python objects.

.. autofunction:: clorm.refine_field

.. autofunction:: clorm.define_nls

.. _api_predicates:

Predicates and Complex Terms
Expand Down

0 comments on commit a59a364

Please sign in to comment.