more doc fixups

This commit is contained in:
John Cupitt 2014-11-13 22:01:42 +00:00
parent 865fd9da5e
commit b45e6b4ec8
1 changed files with 43 additions and 17 deletions

View File

@ -24,7 +24,8 @@
<code>Vips.py</code> file <code>Vips.py</code> file
needs to be copied to the overrides directory of your GOI install, needs to be copied to the overrides directory of your GOI install,
and you need to have the vips typelib on your and you need to have the vips typelib on your
<code>GI_TYPELIB_PATH</code>. <code>GI_TYPELIB_PATH</code>. This may already have happened, depending
on your platform.
</para> </para>
<example> <example>
@ -109,9 +110,9 @@ im = im.similarity(scale = 0.9, interpolate = Vips.Interpolate.new("bicubic"))
<para> <para>
The Python interface comes in two main parts. First, the C source code The Python interface comes in two main parts. First, the C source code
to libvips has been marked up with special comments describing the to libvips has been marked up with special comments describing the
internals in a standard way. These comments are read by interface in a standard way. These comments are read by
gobject-introspection when libvips is compiled and used to generate a gobject-introspection when libvips is compiled and used to generate a
typelib, a description of the library's internals. When your Python typelib, a description of how to call the library. When your Python
program starts, the import line: program starts, the import line:
<programlisting language="Python"> <programlisting language="Python">
@ -133,10 +134,9 @@ from gi.repository import Vips
These overrides do the following things: These overrides do the following things:
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para><emphasis> <para><emphasis>Automatic wrapping of vips operations</emphasis> </para>
Automatic wrapping of vips operations
</emphasis> </para>
<para> <para>
It intercepts member lookup It intercepts member lookup
@ -148,13 +148,32 @@ from gi.repository import Vips
</listitem> </listitem>
<listitem> <listitem>
<para><emphasis>Add docstrings</emphasis> </para>
<para> <para>
Automatic wrapping of operation arguments. The first input image Try <code>help(Vips.Image)</code>, or something like:
argument becomes the <code>self</code> argument. If there are no
input image arguments, the operation appears as a class member. <programlisting language="Python">
Optional input image = Vips.Image.new_from_file("x.jpg")
arguments become keyword arguments. The result is a list of all help(image.add)
the output arguments, or a single output if there is only one. </programlisting>
For any operator it'll list the required and optional input and
output arguments, using all the rules listed below. This plus the
C API docs should be enough to answer most questions. IDEs should
display the help text automatically as you work.
</para>
</listitem>
<listitem>
<para><emphasis>Automatic wrapping of operation arguments</emphasis> </para>
<para>
The first input image argument becomes the <code>self</code>
argument. If there are no input image arguments, the operation
appears as a class member. Optional input arguments become
keyword arguments. The result is a list of all the output
arguments, or a single output if there is only one.
</para> </para>
<para> <para>
@ -174,6 +193,9 @@ min_value = im.min()
<programlisting language="Python"> <programlisting language="Python">
min_value, x_pos, y_pos = im.min(x = True, y = True) min_value, x_pos, y_pos = im.min(x = True, y = True)
</programlisting> </programlisting>
Although in this case, the <code>.minpos()</code> convenience
function would be simpler.
</para> </para>
</listitem> </listitem>
@ -253,7 +275,8 @@ result_image = image1.bandjoin([image2, 255])
<para> <para>
The wrapper spots errors from vips operations and raises the The wrapper spots errors from vips operations and raises the
<code>Vips.Error</code> exception. You can catch it in the <code>Vips.Error</code> exception. You can catch it in the
usual way. usual way. The <code>.detail</code> member gives the detailed
error message.
</para> </para>
</listitem> </listitem>
@ -286,6 +309,8 @@ result_image = image.math(Vips.OperationMath.SIN)
<programlisting language="Python"> <programlisting language="Python">
result_image = image.sin() result_image = image.sin()
</programlisting> </programlisting>
See <code>help(Vips.Image)</code> for a list.
</para> </para>
</listitem> </listitem>
@ -297,6 +322,7 @@ result_image = image.sin()
<code>.get_value()</code>, <code>.set_value()</code> <code>.get_value()</code>, <code>.set_value()</code>
<code>.bandsplit()</code>, <code>.maxpos()</code> <code>.bandsplit()</code>, <code>.maxpos()</code>
<code>.minpos()</code>. <code>.minpos()</code>.
Again, see <code>help(Vips.Image)</code> for a list.
</para> </para>
</listitem> </listitem>