Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
e357ed3c
Commit
e357ed3c
authored
Aug 16, 2016
by
Wenzel Jakob
Committed by
GitHub
Aug 16, 2016
Browse files
Merge pull request #339 from dean0x7d/docfix
Fix sphinx doc missing code blocks and warnings
parents
94f2052d
aebca12b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
docs/advanced.rst
docs/advanced.rst
+6
-1
docs/conf.py
docs/conf.py
+1
-1
No files found.
docs/advanced.rst
View file @
e357ed3c
...
@@ -369,6 +369,7 @@ python classes. For example, suppose we extend the above ``Animal``/``Dog``
...
@@ -369,6 +369,7 @@ python classes. For example, suppose we extend the above ``Animal``/``Dog``
example as follows:
example as follows:
.. code-block:: cpp
.. code-block:: cpp
class Animal {
class Animal {
public:
public:
virtual std::string go(int n_times) = 0;
virtual std::string go(int n_times) = 0;
...
@@ -393,6 +394,7 @@ methods inherited from ``Animal`` (even though ``Dog`` doesn't directly
...
@@ -393,6 +394,7 @@ methods inherited from ``Animal`` (even though ``Dog`` doesn't directly
override the ``name()`` method):
override the ``name()`` method):
.. code-block:: cpp
.. code-block:: cpp
class PyAnimal : public Animal {
class PyAnimal : public Animal {
public:
public:
using Animal::Animal; // Inherit constructors
using Animal::Animal; // Inherit constructors
...
@@ -412,6 +414,7 @@ methods requires a similar trampoline class, *even if* it doesn't explicitly
...
@@ -412,6 +414,7 @@ methods requires a similar trampoline class, *even if* it doesn't explicitly
declare or override any virtual methods itself:
declare or override any virtual methods itself:
.. code-block:: cpp
.. code-block:: cpp
class Husky : public Dog {};
class Husky : public Dog {};
class PyHusky : public Husky {
class PyHusky : public Husky {
using Dog::Dog; // Inherit constructors
using Dog::Dog; // Inherit constructors
...
@@ -426,6 +429,7 @@ methods). The technique involves using template trampoline classes, as
...
@@ -426,6 +429,7 @@ methods). The technique involves using template trampoline classes, as
follows:
follows:
.. code-block:: cpp
.. code-block:: cpp
template <class AnimalBase = Animal> class PyAnimal : public AnimalBase {
template <class AnimalBase = Animal> class PyAnimal : public AnimalBase {
using AnimalBase::AnimalBase; // Inherit constructors
using AnimalBase::AnimalBase; // Inherit constructors
std::string go(int n_times) override { PYBIND11_OVERLOAD_PURE(std::string, AnimalBase, go, n_times); }
std::string go(int n_times) override { PYBIND11_OVERLOAD_PURE(std::string, AnimalBase, go, n_times); }
...
@@ -447,6 +451,7 @@ exposed, as above).
...
@@ -447,6 +451,7 @@ exposed, as above).
The classes are then registered with pybind11 using:
The classes are then registered with pybind11 using:
.. code-block:: cpp
.. code-block:: cpp
py::class_<Animal, std::unique_ptr<Animal>, PyAnimal<>> animal(m, "Animal");
py::class_<Animal, std::unique_ptr<Animal>, PyAnimal<>> animal(m, "Animal");
py::class_<Dog, std::unique_ptr<Dog>, PyDog<>> dog(m, "Dog");
py::class_<Dog, std::unique_ptr<Dog>, PyDog<>> dog(m, "Dog");
py::class_<Husky, std::unique_ptr<Husky>, PyDog<Husky>> husky(m, "Husky");
py::class_<Husky, std::unique_ptr<Husky>, PyDog<Husky>> husky(m, "Husky");
...
@@ -613,7 +618,7 @@ functions. The default policy is :enum:`return_value_policy::automatic`.
...
@@ -613,7 +618,7 @@ functions. The default policy is :enum:`return_value_policy::automatic`.
| | side deletes an object that is still referenced and used by Python. |
| | side deletes an object that is still referenced and used by Python. |
+--------------------------------------------------+----------------------------------------------------------------------------+
+--------------------------------------------------+----------------------------------------------------------------------------+
| :enum:`return_value_policy::reference_internal` | Like :enum:`return_value_policy::reference` but additionally applies a |
| :enum:`return_value_policy::reference_internal` | Like :enum:`return_value_policy::reference` but additionally applies a |
| |
:class:
`keep_alive<0,1>
()
` call policy (described next) that keeps the |
| |
`
`keep_alive<0,
1>
`
` call policy (described next) that keeps the
|
| | ``this`` argument of the function or property from being garbage collected |
| | ``this`` argument of the function or property from being garbage collected |
| | as long as the return value remains referenced. See the |
| | as long as the return value remains referenced. See the |
| | :class:`keep_alive` call policy (described next) for details. |
| | :class:`keep_alive` call policy (described next) for details. |
...
...
docs/conf.py
View file @
e357ed3c
...
@@ -75,7 +75,7 @@ language = None
...
@@ -75,7 +75,7 @@ language = None
# List of patterns, relative to source directory, that match files and
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# directories to ignore when looking for source files.
exclude_patterns
=
[
'.build'
]
exclude_patterns
=
[
'.build'
,
'release.rst'
]
# The reST default role (used for this markup: `text`) to use for all
# The reST default role (used for this markup: `text`) to use for all
# documents.
# documents.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment