Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
conda:
file: docs/environment.yml
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ matrix:
env: DOCS STYLE LINT
install:
- pip install --upgrade sphinx sphinx_rtd_theme flake8 pep8-naming
- pip install docutils==0.12
- |
curl -fsSL ftp://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.12.linux.bin.tar.gz | tar xz
export PATH="$PWD/doxygen-1.8.12/bin:$PATH"
pip install https://github.com/michaeljones/breathe/archive/master.zip
script:
- make -C docs html SPHINX_OPTIONS=-W
- tools/check-style.sh
Expand Down
19 changes: 19 additions & 0 deletions docs/Doxyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PROJECT_NAME = pybind11
INPUT = ../include/pybind11/

GENERATE_HTML = NO
GENERATE_LATEX = NO
GENERATE_XML = YES
XML_OUTPUT = .build/doxygenxml
XML_PROGRAMLISTING = YES

MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
EXPAND_AS_DEFINED = PYBIND11_RUNTIME_EXCEPTION

ALIASES = "rst=\verbatim embed:rst"
ALIASES += "endrst=\endverbatim"

QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = NO
4 changes: 2 additions & 2 deletions docs/advanced/cast/chrono.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Chrono
When including the additional header file :file:`pybind11/chrono.h` conversions
from C++11 chrono datatypes to python datetime objects are automatically enabled.
This header also enables conversions of python floats (often from sources such
as `time.monotonic()`, `time.perf_counter()` and `time.process_time()`) into
durations.
as ``time.monotonic()``, ``time.perf_counter()`` and ``time.process_time()``)
into durations.

An overview of clocks in C++11
------------------------------
Expand Down
14 changes: 7 additions & 7 deletions docs/advanced/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lifetime of objects managed by them. This can lead to issues when creating
bindings for functions that return a non-trivial type. Just by looking at the
type information, it is not clear whether Python should take charge of the
returned value and eventually free its resources, or if this is handled on the
C++ side. For this reason, pybind11 provides a several `return value policy`
C++ side. For this reason, pybind11 provides a several *return value policy*
annotations that can be passed to the :func:`module::def` and
:func:`class_::def` functions. The default policy is
:enum:`return_value_policy::automatic`.
Expand All @@ -24,11 +24,11 @@ Just to illustrate what can go wrong, consider the following simple example:

.. code-block:: cpp

/* Function declaration */
/* Function declaration */
Data *get_data() { return _data; /* (pointer to a static data structure) */ }
...

/* Binding code */
/* Binding code */
m.def("get_data", &get_data); // <-- KABOOM, will cause crash when called from Python

What's going on here? When ``get_data()`` is called from Python, the return
Expand All @@ -44,7 +44,7 @@ silent data corruption.

In the above example, the policy :enum:`return_value_policy::reference` should have
been specified so that the global data instance is only *referenced* without any
implied transfer of ownership, i.e.:
implied transfer of ownership, i.e.:

.. code-block:: cpp

Expand Down Expand Up @@ -158,9 +158,9 @@ targeted arguments can be passed through the :class:`cpp_function` constructor:
Additional call policies
========================

In addition to the above return value policies, further `call policies` can be
specified to indicate dependencies between parameters. In general, call policies
are required when the C++ object is any kind of container and another object is being
In addition to the above return value policies, further *call policies* can be
specified to indicate dependencies between parameters. In general, call policies
are required when the C++ object is any kind of container and another object is being
added to the container.

There is currently just
Expand Down
2 changes: 2 additions & 0 deletions docs/advanced/pycpp/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ The reverse direction uses the following syntax:

When conversion fails, both directions throw the exception :class:`cast_error`.

.. _calling_python_functions:

Calling Python functions
========================

Expand Down
2 changes: 1 addition & 1 deletion docs/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The binding code for ``Pet`` looks as follows:
return m.ptr();
}

:class:`class_` creates bindings for a C++ `class` or `struct`-style data
:class:`class_` creates bindings for a C++ *class* or *struct*-style data
structure. :func:`init` is a convenience function that takes the types of a
constructor's parameters as template arguments and wraps the corresponding
constructor (see the :ref:`custom_constructors` section for details). An
Expand Down
28 changes: 26 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import sys
import os
import shlex
import subprocess

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -30,7 +31,11 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
extensions = ['breathe']

breathe_projects = {'pybind11': '.build/doxygenxml/'}
breathe_default_project = 'pybind11'
breathe_domain_by_extension = {'h': 'cpp'}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['.templates']
Expand Down Expand Up @@ -79,7 +84,7 @@

# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
default_role = 'any'

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
Expand Down Expand Up @@ -306,3 +311,22 @@

primary_domain = 'cpp'
highlight_language = 'cpp'


def generate_doxygen_xml(app):
build_dir = '.build'
if not os.path.exists(build_dir):
os.mkdir(build_dir)

try:
subprocess.call(['doxygen', '--version'])
retcode = subprocess.call(['doxygen'])
if retcode < 0:
sys.stderr.write("doxygen error code: {}\n".format(-retcode))
except OSError as e:
sys.stderr.write("doxygen execution failed: {}\n".format(e))


def setup(app):
"""Add hook for building doxygen xml when needed"""
app.connect("builder-inited", generate_doxygen_xml)
9 changes: 9 additions & 0 deletions docs/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: rtd
channels:
- dean0x7d
- defaults
dependencies:
- doxygen
- pip
- pip:
- https://github.com/michaeljones/breathe/archive/master.zip
Loading