Skip to content

Commit 7674659

Browse files
committed
Fix documentation
1 parent af462db commit 7674659

6 files changed

Lines changed: 51 additions & 14 deletions

File tree

docs/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
'sphinx.ext.viewcode',
3636
'sphinx.ext.napoleon',
3737
'sphinx.ext.doctest',
38+
'sphinx.ext.intersphinx',
3839
]
3940

4041
# The master toctree document.
@@ -54,6 +55,11 @@
5455
# This pattern also affects html_static_path and html_extra_path.
5556
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
5657

58+
# Warn on broken cross references
59+
nitpicky = True
60+
61+
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
62+
5763

5864
# -- Options for HTML output -------------------------------------------------
5965

docs/elisp.rst

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.. py:currentmodule:: emacs.elisp.ast
2+
3+
14
Representing Emacs lisp code in Python
25
======================================
36

@@ -50,8 +53,18 @@ Python lists are converted to quoted Elisp lists, while tuples are left unquoted
5053
<el ("a" "b" "c")>
5154

5255

53-
Elements of lists/tuples are recursively converted using :meth:`to_elisp` if
54-
they are not already instances of :class:`ElispAstNode`.
56+
Python dicts and other mapping types are converted using :func:`make_alist` (see
57+
below):
58+
59+
.. doctest::
60+
61+
>>> el.to_elisp({'a': 1, 'b': 2})
62+
<el ((cons a 1) (cons b 2))>
63+
64+
65+
Elements of composite data types (lists, tuples, dicts) are recursively
66+
converted using :meth:`to_elisp` if they are not already instances of
67+
:class:`ElispAstNode`.
5568

5669
You can use :func:`quote` to quote a value. It will also convert strings to
5770
quoted symbols:
@@ -69,14 +82,22 @@ quoted symbols:
6982
<el 'foo>
7083

7184

72-
Other shortcuts are :func:`cons` to create a cons cell, or :func:`symbols` to
73-
create a list of symbols:
85+
A a form that must be constructed directly because it has no Python equivalent
86+
is the cons cell, represented with the class :class:`Cons`:
7487

7588
.. doctest::
7689

77-
>>> el.cons(el.Symbol('a'), 1)
90+
>>> el.Cons(el.Symbol('a'), 1)
7891
<el (cons a 1)>
7992

93+
>>> el.quote(el.Cons(el.Symbol('a'), 1))
94+
<el '(a . 1)>
95+
96+
97+
The :func:`symbols` function can be used to create a list of symbols:
98+
99+
.. doctest::
100+
80101
>>> el.symbols('a', 'b', 'c')
81102
<el (a b c)>
82103

@@ -109,17 +130,23 @@ be inserted verbatim in the given location:
109130
Using Elisp forms
110131
-----------------
111132

112-
Elisp forms can be passed to :meth:`Elisp.eval` and :meth:`Elisp.getresult` for
133+
.. py:currentmodule:: emacs.emacs
134+
135+
136+
Elisp forms can be passed to :meth:`Emacs.eval` and :meth:`Emacs.getresult` for
113137
execution. You can also convert them to strings to produce (hopefully)
114138
syntactically-correct Elisp code.
115139

116140

117141
Elisp DSL
118142
---------
119143

144+
.. py:currentmodule:: emacs.elisp.ast
145+
146+
120147
This package also includes an unholy abomination of a DSL that lets you write
121148
Elisp code in Python. The DSL is implemented through a singleton object which
122-
is importable as :data:`emacs.elisp.E`::
149+
is importable as :data:`emacs.elisp.E <emacs.elisp.dsl.E>`::
123150

124151
>>> from emacs.elisp import E
125152

@@ -163,7 +190,7 @@ Symbols can be called as functions, generating Elisp function calls:
163190

164191

165192
Additionally, the ``Q``, ``C``, ``S``, and ``R`` methods are aliases for the
166-
:func:`quote`, :func:`cons`, :func:`symbols`, and :class:`Raw`, respectively.
193+
:func:`quote`, :class:`Cons`, :func:`symbols`, and :class:`Raw`, respectively.
167194

168195
Using just the ``E`` object, it is possible to write complex Elisp forms:
169196

docs/usage.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.. py:currentmodule:: emacs.emacs
2+
3+
14
Basic usage
25
===========
36

emacs/elisp/ast.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ def quote(value):
211211
212212
Parameters
213213
----------
214-
value : Elisp value to quote.
214+
value
215+
Elisp value to quote.
215216
216217
Returns
217218
-------

emacs/elisp/dsl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88

99
class ElispSingleton:
10-
"""Singleton object which implements the Elisp DSL.
11-
12-
10+
"""Class of the singleton :data:`.E`.
1311
"""
1412

1513
__instance = None
@@ -44,4 +42,5 @@ def __call__(self, value):
4442
R = staticmethod(Raw)
4543

4644

45+
#: Singleton object which implements the Elisp DSL.
4746
E = ElispSingleton()

emacs/emacs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def from_calledprocess(cls, src, cpe):
6666
6767
Parameters
6868
----------
69-
src : str or emacs.elisp.ElispAstNode
69+
src : str or emacs.elisp.ast.ElispAstNode
7070
Source code which was to be evaluated.
7171
cpe : subprocess.CalledProcessError
7272
@@ -273,7 +273,8 @@ def getresult(self, source, is_json=False, **kwargs):
273273
274274
Returns
275275
-------
276-
Parsed value.
276+
object
277+
Parsed value.
277278
278279
Raises
279280
------

0 commit comments

Comments
 (0)