From 032200bcb40a8d007bb1764516039f1ca4d06750 Mon Sep 17 00:00:00 2001 From: Bob Tolbert Date: Tue, 31 Dec 2013 16:14:05 -0700 Subject: [PATCH] Some small doc fixes This cleans up a number of doc warnings, including a bad underline for zero? While there, added a nil? function to match up with the new nil is None. Also un-hid myself from coreteam. --- docs/conf.py | 2 +- docs/index.rst | 20 ++++++++++---------- docs/language/core.rst | 32 +++++++++++++++++++++++++++++++- hy/core/language.hy | 6 +++++- scripts/update_coreteam.py | 1 - tests/native_tests/core.hy | 9 +++++++++ 6 files changed, 56 insertions(+), 14 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 6b45309..1d5b516 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -67,7 +67,7 @@ release = hy.__version__ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ['_build', 'coreteam.rst'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None diff --git a/docs/index.rst b/docs/index.rst index a8ad82f..2f568c4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,17 +19,17 @@ Meet our mascot, "Cuddles": .. image:: http://fc07.deviantart.net/fs70/i/2013/138/f/0/cuddles_the_hacker_by_doctormo-d65l7lq.png :alt: Paul riding cuddles into the distance - -.. Our old ascii art mascot version -.. Retained as an easter egg for those who read the docs via .rst! .. -.. LET'S CUDDLEFISH -.. ______ -.. _.----'#' # ' -.. ,' #' ,# ; -.. (' (w) _,-'_/ -.. /// / /'.____.' -.. \|\||/ + Our old ascii art mascot version + Retained as an easter egg for those who read the docs via .rst! + + LET'S CUDDLEFISH + ______ + _.----'#' # ' + ,' #' ,# ; + (' (w) _,-'_/ + /// / /'.____.' + \|\||/ You can try Hy `in your browser `_. diff --git a/docs/language/core.rst b/docs/language/core.rst index 9b24747..300da15 100644 --- a/docs/language/core.rst +++ b/docs/language/core.rst @@ -242,6 +242,36 @@ Raises ``TypeError`` if ``(not (numeric? x))``. => (neg? 0) False + +.. _nil?-fn: + +nil? +----- + +Usage: ``(nil? x)`` + +Return True if x is nil/None. + +.. code-block:: clojure + + => (nil? nil) + True + + => (nil? None) + True + + => (nil? 0) + False + + => (setf x nil) + => (nil? x) + True + + => ;; list.append always returns None + => (nil? (.append [1 2 3] 4)) + True + + .. _none?-fn: none? @@ -397,7 +427,7 @@ Return True if x is a string. .. _zero?-fn: zero? ----- +----- Usage: ``(zero? x)`` diff --git a/hy/core/language.hy b/hy/core/language.hy index 9ac2fee..5c69071 100644 --- a/hy/core/language.hy +++ b/hy/core/language.hy @@ -160,6 +160,10 @@ "Return true if x is None" (is x None)) +(defn nil? [x] + "Return true if x is nil (None)" + (is x None)) + (defn numeric? [x] (import numbers) (instance? numbers.Number x)) @@ -253,5 +257,5 @@ (def *exports* '[cycle dec distinct drop drop-while empty? even? filter flatten float? gensym inc instance? integer integer? iterable? iterate iterator? neg? - none? nth numeric? odd? pos? remove repeat repeatedly second + nil? none? nth numeric? odd? pos? remove repeat repeatedly second string string? take take-nth take-while zero?]) diff --git a/scripts/update_coreteam.py b/scripts/update_coreteam.py index dda9754..90f2d86 100644 --- a/scripts/update_coreteam.py +++ b/scripts/update_coreteam.py @@ -19,7 +19,6 @@ MISSING_NAMES = { # an owner of the organization. CONCEALED_MEMBERS = [ ('aldeka', 'Karen Rustad'), - ('rwtolbert', 'Bob Tolbert'), ('tuturto', 'Tuukka Turto'), ] diff --git a/tests/native_tests/core.hy b/tests/native_tests/core.hy index aedf99c..1427187 100644 --- a/tests/native_tests/core.hy +++ b/tests/native_tests/core.hy @@ -293,6 +293,15 @@ (assert-false (none? 0)) (assert-false (none? ""))) +(defn test-nil? [] + "NATIVE: testing for `is nil`" + (assert-true (nil? nil)) + (assert-true (nil? None)) + (setv f nil) + (assert-true (nil? f)) + (assert-false (nil? 0)) + (assert-false (nil? ""))) + (defn test-nth [] "NATIVE: testing the nth function" (assert-equal 2 (nth [1 2 4 7] 1))