Update documentation

This commit is contained in:
Kodi Arfer 2019-07-02 12:16:06 -04:00
parent c99360b294
commit 8b101d1214
3 changed files with 12 additions and 12 deletions

View File

@ -67,8 +67,8 @@ your choice to the keyword argument ``:placeholder`` of
.. code-block:: hy
(defclass Container [object]
[__init__ (fn [self value]
(setv self.value value))])
(defn __init__ (fn [self value]
(setv self.value value))))
(hy-repr-register Container :placeholder "HY THERE" (fn [x]
(+ "(Container " (hy-repr x.value) ")")))
(setv container (Container 5))

View File

@ -430,16 +430,16 @@ Whereas ``setv`` creates an assignment statement, ``setx`` creates an assignment
defclass
--------
New classes are declared with ``defclass``. It can take three optional parameters in the following order:
a list defining (a) possible super class(es), a string (:term:`py:docstring`) and another list containing
attributes of the new class along with their corresponding values.
New classes are declared with ``defclass``. It can take optional parameters in the following order:
a list defining (a) possible super class(es) and a string (:term:`py:docstring`).
.. code-block:: clj
(defclass class-name [super-class-1 super-class-2]
"docstring"
[attribute1 value1
attribute2 value2]
(setv attribute1 value1)
(setv attribute2 value2)
(defn method [self] (print "hello!")))
@ -449,8 +449,8 @@ below:
.. code-block:: clj
=> (defclass Cat []
... [age None
... colour "white"]
... (setv age None)
... (setv colour "white")
...
... (defn speak [self] (print "Meow")))

View File

@ -527,9 +527,9 @@ In Hy:
.. code-block:: clj
(defclass Customer [models.Model]
[name (models.CharField :max-length 255)
address (models.TextField)
notes (models.TextField)])
(setv name (models.CharField :max-length 255))
(setv address (models.TextField))
(setv notes (models.TextField)))
Macros
======