Skip to content

Commit 33e72a2

Browse files
authored
Merge pull request #209 from joar/fix/escape-square-brackets
Escape square brackets when they're not references
2 parents 3e7d528 + 47bbe8c commit 33e72a2

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

src/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl PyBuffer {
257257
}
258258

259259
/// An array of length ndim.
260-
/// If suboffsets[n] >= 0, the values stored along the nth dimension are pointers and the suboffset value dictates how many bytes to add to each pointer after de-referencing.
260+
/// If `suboffsets[n] >= 0`, the values stored along the nth dimension are pointers and the suboffset value dictates how many bytes to add to each pointer after de-referencing.
261261
/// A suboffset value that is negative indicates that no de-referencing should occur (striding in a contiguous memory block).
262262
///
263263
/// If all suboffsets are negative (i.e. no de-referencing is needed), then this field must be NULL (the default value).

src/objectprotocol.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@ use typeob::PyTypeInfo;
1616
/// Python object model helper methods
1717
pub trait ObjectProtocol {
1818
/// Determines whether this object has the given attribute.
19-
/// This is equivalent to the Python expression 'hasattr(self, attr_name)'.
19+
/// This is equivalent to the Python expression `hasattr(self, attr_name)`.
2020
fn hasattr<N>(&self, attr_name: N) -> PyResult<bool>
2121
where
2222
N: ToPyObject;
2323

2424
/// Retrieves an attribute value.
25-
/// This is equivalent to the Python expression 'self.attr_name'.
25+
/// This is equivalent to the Python expression `self.attr_name`.
2626
fn getattr<N>(&self, attr_name: N) -> PyResult<&PyObjectRef>
2727
where
2828
N: ToPyObject;
2929

3030
/// Sets an attribute value.
31-
/// This is equivalent to the Python expression 'self.attr_name = value'.
31+
/// This is equivalent to the Python expression `self.attr_name = value`.
3232
fn setattr<N, V>(&self, attr_name: N, value: V) -> PyResult<()>
3333
where
3434
N: ToBorrowedObject,
3535
V: ToBorrowedObject;
3636

3737
/// Deletes an attribute.
38-
/// This is equivalent to the Python expression 'del self.attr_name'.
38+
/// This is equivalent to the Python expression `del self.attr_name`.
3939
fn delattr<N>(&self, attr_name: N) -> PyResult<()>
4040
where
4141
N: ToPyObject;
4242

4343
/// Compares two Python objects.
4444
///
45-
/// On Python 2, this is equivalent to the Python expression 'cmp(self, other)'.
45+
/// On Python 2, this is equivalent to the Python expression `cmp(self, other)`.
4646
///
4747
/// On Python 3, this is equivalent to:
4848
/// ```python,ignore
@@ -73,35 +73,35 @@ pub trait ObjectProtocol {
7373
O: ToPyObject;
7474

7575
/// Compute the string representation of self.
76-
/// This is equivalent to the Python expression 'repr(self)'.
76+
/// This is equivalent to the Python expression `repr(self)`.
7777
fn repr(&self) -> PyResult<&PyString>;
7878

7979
/// Compute the string representation of self.
80-
/// This is equivalent to the Python expression 'str(self)'.
80+
/// This is equivalent to the Python expression `str(self)`.
8181
fn str(&self) -> PyResult<&PyString>;
8282

8383
/// Determines whether this object is callable.
8484
fn is_callable(&self) -> bool;
8585

8686
/// Calls the object.
87-
/// This is equivalent to the Python expression: 'self(*args, **kwargs)'
87+
/// This is equivalent to the Python expression: `self(*args, **kwargs)`
8888
fn call<A, K>(&self, args: A, kwargs: K) -> PyResult<&PyObjectRef>
8989
where
9090
A: IntoPyTuple,
9191
K: IntoPyDictPointer;
9292

9393
/// Calls the object.
94-
/// This is equivalent to the Python expression: 'self()'
94+
/// This is equivalent to the Python expression: `self()`
9595
fn call0(&self) -> PyResult<&PyObjectRef>;
9696

9797
/// Calls the object.
98-
/// This is equivalent to the Python expression: 'self(*args)'
98+
/// This is equivalent to the Python expression: `self(*args)`
9999
fn call1<A>(&self, args: A) -> PyResult<&PyObjectRef>
100100
where
101101
A: IntoPyTuple;
102102

103103
/// Calls a method on the object.
104-
/// This is equivalent to the Python expression: 'self.name(*args, **kwargs)'
104+
/// This is equivalent to the Python expression: `self.name(*args, **kwargs)`
105105
///
106106
/// # Example
107107
/// ```rust,ignore
@@ -116,43 +116,43 @@ pub trait ObjectProtocol {
116116
K: IntoPyDictPointer;
117117

118118
/// Calls a method on the object.
119-
/// This is equivalent to the Python expression: 'self.name()'
119+
/// This is equivalent to the Python expression: `self.name()`
120120
fn call_method0(&self, name: &str) -> PyResult<&PyObjectRef>;
121121

122122
/// Calls a method on the object with positional arguments only .
123-
/// This is equivalent to the Python expression: 'self.name(*args)'
123+
/// This is equivalent to the Python expression: `self.name(*args)`
124124
fn call_method1<A: IntoPyTuple>(&self, name: &str, args: A) -> PyResult<&PyObjectRef>;
125125

126126
/// Retrieves the hash code of the object.
127-
/// This is equivalent to the Python expression: 'hash(self)'
127+
/// This is equivalent to the Python expression: `hash(self)`
128128
fn hash(&self) -> PyResult<isize>;
129129

130130
/// Returns whether the object is considered to be true.
131-
/// This is equivalent to the Python expression: 'not not self'
131+
/// This is equivalent to the Python expression: `not not self`
132132
fn is_true(&self) -> PyResult<bool>;
133133

134134
/// Returns whether the object is considered to be None.
135-
/// This is equivalent to the Python expression: 'is None'
135+
/// This is equivalent to the Python expression: `is None`
136136
fn is_none(&self) -> bool;
137137

138138
/// Returns the length of the sequence or mapping.
139-
/// This is equivalent to the Python expression: 'len(self)'
139+
/// This is equivalent to the Python expression: `len(self)`
140140
fn len(&self) -> PyResult<usize>;
141141

142-
/// This is equivalent to the Python expression: 'self[key]'
142+
/// This is equivalent to the Python expression: `self[key]`
143143
fn get_item<K>(&self, key: K) -> PyResult<&PyObjectRef>
144144
where
145145
K: ToBorrowedObject;
146146

147147
/// Sets an item value.
148-
/// This is equivalent to the Python expression 'self[key] = value'.
148+
/// This is equivalent to the Python expression `self[key] = value`.
149149
fn set_item<K, V>(&self, key: K, value: V) -> PyResult<()>
150150
where
151151
K: ToBorrowedObject,
152152
V: ToBorrowedObject;
153153

154154
/// Deletes an item.
155-
/// This is equivalent to the Python expression 'del self[key]'.
155+
/// This is equivalent to the Python expression `del self[key]`.
156156
fn del_item<K>(&self, key: K) -> PyResult<()>
157157
where
158158
K: ToBorrowedObject;

src/objects/sequence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl PySequence {
198198
}
199199
}
200200

201-
/// Return the first index i for which o[i] == value.
201+
/// Return the first index `i` for which `o[i] == value`.
202202
/// This is equivalent to the Python expression `o.index(value)`
203203
#[inline]
204204
pub fn index<V>(&self, value: V) -> PyResult<usize>

src/typeob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl PyObjectWithToken for PyRawObject {
210210
}
211211
}
212212

213-
/// A Python object allocator that is usable as a base type for #[pyclass]
213+
/// A Python object allocator that is usable as a base type for `#[pyclass]`
214214
pub trait PyObjectAlloc<T> {
215215
/// Allocates a new object (usually by calling ty->tp_alloc),
216216
unsafe fn alloc(py: Python) -> PyResult<*mut ffi::PyObject>;

0 commit comments

Comments
 (0)