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 .. code-block:: hy
(defclass Container [object] (defclass Container [object]
[__init__ (fn [self value] (defn __init__ (fn [self value]
(setv self.value value))]) (setv self.value value))))
(hy-repr-register Container :placeholder "HY THERE" (fn [x] (hy-repr-register Container :placeholder "HY THERE" (fn [x]
(+ "(Container " (hy-repr x.value) ")"))) (+ "(Container " (hy-repr x.value) ")")))
(setv container (Container 5)) (setv container (Container 5))

View File

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

View File

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