Re: How to build the documentation

Daniel James <[email protected]>
Newsgroups gmane.comp.lib.boost.documentation
Message-ID <CAHOE3yeaeGowSjdmPcTMj5jbjbFt0Y0bgpW8J=wmJn2wAnCc_g@mail.gmail.com>
On 25 December 2011 18:35, Pedro Larroy <[email protected]> wrote:
> Hi
>
> I created a small patch for libs/python/doc/tutorial/doc/tutorial.qbk
>
> How can I check that it builds correctly and generates propper html?

I tried building it, and added a little extra markup, see the attached patch.

To build it you'll need to setup boost build and then set up the
documentation toolchain as detailed at:

https://svn.boost.org/trac/boost/wiki/BoostDocs/GettingStarted

Then you can build by running 'b2' in the documentation directory.

_______________________________________________
Boost-docs mailing list
[email protected]
http://lists.boost.org/mailman/listinfo.cgi/boost-docs
python.patch (application/octet-stream, 6.9 KB)
Index: libs/python/doc/tutorial/doc/tutorial.qbk
===================================================================
--- libs/python/doc/tutorial/doc/tutorial.qbk	(revision 76195)
+++ libs/python/doc/tutorial/doc/tutorial.qbk	(working copy)
@@ -1302,6 +1302,23 @@
 [def PyModule_GetDict       [@http://www.python.org/doc/current/api/moduleObjects.html#l2h-594   PyModule_GetDict]]
 
 [endsect]
+
+[section:creating_python_object Creating `boost::python::object` from `PyObject*`]
+
+When you want a `boost::python::object` to manage a pointer to `PyObject*` pyobj one does:
+
+    boost::python::object o(boost::python::handle<>(pyobj));
+
+In this case, the `o` object, manages the `pyobj`, it won’t increase the reference count on construction.
+
+Otherwise, to use a borrowed reference:
+
+    boost::python::object o(boost::python::handle<>(boost::python::borrowed(pyobj)));
+
+In this case, `Py_INCREF` is called, so `pyobj` is not destructed when object o goes out of scope.
+
+[endsect] [/ creating_python_object ]
+
 [endsect] [/ Object Interface]
 
 [section Embedding]
Index: libs/python/doc/tutorial/doc/html/python/object.html
===================================================================
--- libs/python/doc/tutorial/doc/html/python/object.html	(revision 76196)
+++ libs/python/doc/tutorial/doc/html/python/object.html	(working copy)
@@ -30,6 +30,7 @@
 <dt><span class="section"><a href="object.html#python.derived_object_types">Derived Object types</a></span></dt>
 <dt><span class="section"><a href="object.html#python.extracting_c___objects">Extracting C++ objects</a></span></dt>
 <dt><span class="section"><a href="object.html#python.enums">Enums</a></span></dt>
+<dt><span class="section"><a href="object.html#python.creating_python_object">Creating <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span></code> from <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code></a></span></dt>
 </dl></div>
 <p>
       Python is dynamically typed, unlike C++ which is statically typed. Python variables
@@ -314,7 +315,33 @@
     <span class="special">;</span>
 </pre>
 </div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="python.creating_python_object"></a>Creating <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span></code> from <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code>
+</h3></div></div></div>
+<p>
+        When you want a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span></code> to manage a pointer to <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code>
+        pyobj one does:
+      </p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span> <span class="identifier">o</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;&gt;(</span><span class="identifier">pyobj</span><span class="special">));</span>
+</pre>
+<p>
+        In this case, the <code class="computeroutput"><span class="identifier">o</span></code> object,
+        manages the <code class="computeroutput"><span class="identifier">pyobj</span></code>, it won&#8217;t
+        increase the reference count on construction.
+      </p>
+<p>
+        Otherwise, to use a borrowed reference:
+      </p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span> <span class="identifier">o</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">handle</span><span class="special">&lt;&gt;(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">borrowed</span><span class="special">(</span><span class="identifier">pyobj</span><span class="special">)));</span>
+</pre>
+<p>
+        In this case, <code class="computeroutput"><span class="identifier">Py_INCREF</span></code> is
+        called, so <code class="computeroutput"><span class="identifier">pyobj</span></code> is not destructed
+        when object o goes out of scope.
+      </p>
 </div>
+</div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
 <td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005 Joel
Index: libs/python/doc/tutorial/doc/html/index.html
===================================================================
--- libs/python/doc/tutorial/doc/html/index.html	(revision 76196)
+++ libs/python/doc/tutorial/doc/html/index.html	(working copy)
@@ -66,6 +66,7 @@
 <dt><span class="section"><a href="python/object.html#python.derived_object_types">Derived Object types</a></span></dt>
 <dt><span class="section"><a href="python/object.html#python.extracting_c___objects">Extracting C++ objects</a></span></dt>
 <dt><span class="section"><a href="python/object.html#python.enums">Enums</a></span></dt>
+<dt><span class="section"><a href="python/object.html#python.creating_python_object">Creating <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span></code> from <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code></a></span></dt>
 </dl></dd>
 <dt><span class="section"><a href="python/embedding.html">Embedding</a></span></dt>
 <dd><dl><dt><span class="section"><a href="python/embedding.html#python.using_the_interpreter">Using the interpreter</a></span></dt></dl></dd>
@@ -132,7 +133,7 @@
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: December 26, 2011 at 21:51:27 GMT</small></p></td>
+<td align="left"><p><small>Last revised: December 26, 2011 at 21:58:39 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.