Skip to content

Commit

Permalink
Merge pull request #116 from axelwalter/feature/wrap-statement-tutorial
Browse files Browse the repository at this point in the history
update readme with multi line docstring
  • Loading branch information
timosachsenberg authored Jan 13, 2022
2 parents 0b9da3f + d023b73 commit 19942c1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ Example declaration for releasing the GIL (in the pxd):
```
void Compile() nogil # wrap-with-no-gil
```

Example for multiple wrap statements in a method directive:

```
size_t countSomething(libcpp_vector[double] inpVec) nogil # wrap-attach:Counter wrap-as:count
```

In addition you have to declare the function as nogil. For further details see
http://docs.cython.org/src/userguide/external_C_code.html
Expand Down Expand Up @@ -230,6 +236,29 @@ Additionally, TemplatedClass[U,V] gets additional methods from C[U] and from D w

Finally, the object is hashable in Python (assuming it has a function `getName()` that returns a string).

### Docstrings

Docstrings can be added to classes and methods using the `wrap-doc` statement. Multi line docs are supported with
empty lines and indentation. Note that every line of the docstring needs to begin with # and two spaces, even the empty lines.
Methods still support single line doctrings directly after the declaration. However, if there is a multi line docstring it is
taken with priority.

```
cdef cppclass Counter:
# wrap-doc:
# Multi line docstring for class
# with indentation
#
# and empty line
size_t count(libcpp_vector[double] inpVec) # wrap-doc:Single line docstring that will be overwritten by multi line wrap-doc
# wrap-doc:
# Multi line docstring for method
# with indentation
#
# and empty line
```

Test examples
-------------

Expand Down

0 comments on commit 19942c1

Please sign in to comment.