Skip to content

Commit 83d9a13

Browse files
authored
Add documentation for Basilisp interfaces (#920)
Add some initial documentation around the Python interfaces which underpin most Basilisp collection functions.
1 parent 109add1 commit 83d9a13

File tree

11 files changed

+312
-90
lines changed

11 files changed

+312
-90
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323

2424
### Other
2525
* Add REPL documentation module (#205)
26+
* Add documentation module for Basilisp interfaces (#920)
2627
* Update Sphinx documentation theme (#909)
2728
* Update documentation to directly reference Python documentation and fix many other minor issues and misspellings (#907, #919)
2829

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ docs:
88

99
.PHONY: livedocs
1010
livedocs:
11-
@poetry run sphinx-autobuild "$(DOCSOURCEDIR)" "$(DOCBUILDDIR)" -b html
11+
@poetry run sphinx-autobuild "$(DOCSOURCEDIR)" "$(DOCBUILDDIR)" -b html --watch "./src"
1212

1313

1414
.PHONY: format

docs/interfaces.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Interfaces
2+
==========
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
:caption: Contents:
7+
8+
Basilisp (like Clojure) is defined by interfaces.
9+
All of the built-in data types are implement 0 or more of these Python interfaces and :lpy:ns:`basilisp.core` functions typically operate on these interfaces, rather than concrete data types (with some exceptions).
10+
11+
In day-to-day usage, you will not typically need to use these interfaces, but they are nevertheless helpful for understanding the abstractions Basilisp is built upon.
12+
13+
.. warning::
14+
15+
These interfaces are not considered part of the Basilisp public API and therefore are subject to change at any time without notice.
16+
This documentation is intended to help users understand the abstractions that underpin Basilisp.
17+
18+
.. class:: basilisp.lang.interfaces.ILispObject
19+
20+
Abstract base class for Lisp objects which would like to customize their ``__str__`` and Python ``__repr__`` representation.
21+
22+
.. automethod:: _lrepr
23+
.. automethod:: lrepr
24+
25+
.. lpy:currentns:: basilisp.core
26+
27+
.. automodule:: basilisp.lang.interfaces
28+
:members:
29+
:undoc-members:
30+
:exclude-members: seq_equals
31+
:show-inheritance:

docs/reference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Reference
66
:caption: Contents:
77

88
api
9+
interfaces
910
cli
1011
repl
1112
reader

src/basilisp/core.lpy

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -907,10 +907,10 @@
907907
(defn deref
908908
"Dereference a delay or atom and returns its contents.
909909

910-
If ``o`` is an object implementing ``IBlockingDeref`` and ``timeout-s`` and
911-
``timeout-val`` are supplied, ``deref`` will wait at most ``timeout-s`` seconds,
912-
returning ``timeout-val`` if ``timeout-s`` seconds elapse and ``o`` has not
913-
returned."
910+
If ``o`` is an object implementing :py:class:`basilisp.lang.interfaces.IBlockingDeref`
911+
and ``timeout-s`` and ``timeout-val`` are supplied, ``deref`` will wait at most
912+
``timeout-s`` seconds, returning ``timeout-val`` if ``timeout-s`` seconds elapse and
913+
``o`` has not returned."
914914
([o]
915915
(basilisp.lang.runtime/deref o))
916916
([o timeout-s timeout-val]
@@ -1208,7 +1208,7 @@
12081208
true)
12091209

12101210
(defn ^:inline associative?
1211-
"Return ``true`` if ``x`` implements ``IAssociative`` ."
1211+
"Return ``true`` if ``x`` implements :py:class:`basilisp.lang.interfaces.IAssociative`."
12121212
[x]
12131213
(instance? basilisp.lang.interfaces/IAssociative x))
12141214

@@ -1243,7 +1243,7 @@
12431243
(instance? python/type x))
12441244

12451245
(defn ^:inline coll?
1246-
"Return ``true`` if ``x`` implements ``IPersistentCollection``\\."
1246+
"Return ``true`` if ``x`` implements :py:class:`basilisp.lang.interfaces.IPersistentCollection`\\."
12471247
[x]
12481248
(instance? basilisp.lang.interfaces/IPersistentCollection x))
12491249

@@ -1325,7 +1325,7 @@
13251325
integer?)
13261326

13271327
(defn ^:inline map-entry?
1328-
"Return ``true`` if ``x`` implements ``IMapEntry``\\."
1328+
"Return ``true`` if ``x`` implements :py:class:`basilisp.lang.interfaces.IMapEntry`\\."
13291329
[x]
13301330
(instance? basilisp.lang.interfaces/IMapEntry x))
13311331

@@ -1440,17 +1440,18 @@
14401440
(or (integer? x) (float? x)))
14411441

14421442
(defn ^:inline reversible?
1443-
"Return ``true`` if x implements ``IReversible``\\."
1443+
"Return ``true`` if x implements :py:class:`basilisp.lang.interfaces.IReversible`\\."
14441444
[x]
14451445
(instance? basilisp.lang.interfaces/IReversible x))
14461446

14471447
(defn ^:inline seqable?
1448-
"Return ``true`` if an ``ISeq`` can be produced from ``x``\\."
1448+
"Return ``true`` if an :py:class:`basilisp.lang.interfaces.ISeq` can be produced from
1449+
``x``\\."
14491450
[x]
14501451
(instance? basilisp.lang.interfaces/ISeqable x))
14511452

14521453
(defn ^:inline sequential?
1453-
"Return ``true`` if ``x`` implements ``ISequential``\\."
1454+
"Return ``true`` if ``x`` implements :py:class:`basilisp.lang.interfaces.ISequential`\\."
14541455
[x]
14551456
(instance? basilisp.lang.interfaces/ISequential x))
14561457

@@ -2002,8 +2003,9 @@
20022003
(or (.- ex __cause__) (.- ex __context__))))
20032004

20042005
(defn ex-data
2005-
"Return the data map of ``ex`` if is an instance of ``IExceptionInfo``\\, otherwise
2006-
it returns ``nil``\\."
2006+
"Return the data map of ``ex`` if is an instance of
2007+
:py:class:`basilisp.lang.interfaces.IExceptionInfo`\\, otherwise it returns
2008+
``nil``\\."
20072009
[ex]
20082010
(when (instance? basilisp.lang.interfaces/IExceptionInfo ex)
20092011
(.-data ex)))

0 commit comments

Comments
 (0)