Skip to content

Commit

Permalink
Improvements to the documentation formatting and internal links
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed Aug 25, 2015
1 parent 4f428b2 commit 4c13fce
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 127 deletions.
31 changes: 31 additions & 0 deletions docs/api/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ Resources are high level abstractions to managing specific sessions. An instance
of one of these classes is returned by the :meth:`~pyvisa.highlevel.ResourceManager.open_resource`
depending on the resource type.

Generic classes
~~~~~~~~~~~~~~~

- :class:`~pyvisa.resources.Resource`
- :class:`~pyvisa.resources.MessageBasedResource`
- :class:`~pyvisa.resources.RegisterBasedResource`


Specific Classes
~~~~~~~~~~~~~~~~

- :class:`~pyvisa.resources.SerialInstrument`
- :class:`~pyvisa.resources.TCPIPInstrument`
- :class:`~pyvisa.resources.TCPIPSocket`
Expand All @@ -23,6 +34,26 @@ depending on the resource type.

.. currentmodule::`pyvisa.resources`
.. autoclass:: pyvisa.resources.Resource
:members:
:inherited-members:
:undoc-members:


.. autoclass:: pyvisa.resources.MessageBasedResource
:members:
:inherited-members:
:exclude-members: ask_delay, ask_for_values, ask
:undoc-members:


.. autoclass:: pyvisa.resources.RegisterBasedResource
:members:
:inherited-members:
:undoc-members:


.. autoclass:: pyvisa.resources.SerialInstrument
:members:
:inherited-members:
Expand Down
42 changes: 21 additions & 21 deletions docs/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PyVISA implements convenient and Pythonic programming in three layers:
You will normally not need to access these functions directly. If you do,
it probably means that we need to improve layer 2.

All level 1 functions are **static methods** of `VisaLibrary`.
All level 1 functions are **static methods** of :class:`pyvisa.highlevel.VisaLibrary`.

.. warning:: Notice however that low-level functions might not be present in all backends.
For broader compatibility, do no use this layer. All the functionality should
Expand All @@ -30,47 +30,47 @@ PyVISA implements convenient and Pythonic programming in three layers:
aspects of the VISA library which are not implemented by the corresponding
resource class.

All level 2 functions are **bound methods** of `VisaLibrary`.
All level 2 functions are **bound methods** of :class:`pyvisa.highlevel.VisaLibrary`.

3. High-level: An object-oriented layer for `ResourceManager` and `Resource`
3. High-level: An object-oriented layer for :class:`pyvisa.highlevel.ResourceManager` and :class:`pyvisa.resources.Resource`

The `ResourceManager` implements methods to inspect connected resources. You also
use this object to open other resources instantiating the appropriate `Resource`
The ``ResourceManager`` implements methods to inspect connected resources. You also
use this object to open other resources instantiating the appropriate ``Resource``
derived classes.

`Resource` and the derived classes implement functions and attributes access
``Resource`` and the derived classes implement functions and attributes access
to the underlying resources in a Pythonic way.

Most of the time you will only need to instantiate a `ResourceManager`. For a given resource,
you will use the `open_resource` method to obtain the appropriate object. If needed, you will
be able to access the `VisaLibrary` object directly using the `visalib` attribute.
Most of the time you will only need to instantiate a ``ResourceManager``. For a given resource,
you will use the :meth:`pyvisa.highlevel.ResourceManager.open_resource` method to obtain the appropriate object. If needed, you will
be able to access the ``VisaLibrary`` object directly using the :attr:`pyvisa.highlevel.ResourceManager.visalib` attribute.

The `VisaLibrary` does the low-level calls. In the default NI Backend, levels 1 and 2 are
implemented in the same package called `ctwrapper` (which stands for ctypes wrapper).
The ``VisaLibrary`` does the low-level calls. In the default NI Backend, levels 1 and 2 are
implemented in the same package called :mod:`pyvisa.ctwrapper` (which stands for ctypes wrapper).
This package is included in PyVISA.

Other backends can be used just by passing the name of the backend to `ResourceManager`
Other backends can be used just by passing the name of the backend to ``ResourceManager``
after the `@` symbol. See more information in :ref:`backends`.


Calling middle- and low-level functions
---------------------------------------

After you have instantiated the `ResourceManager`::
After you have instantiated the ``ResourceManager``::

>>> import visa
>>> rm = visa.ResourceManager()

you can access the corresponding `VisaLibrary` instance under the `visalib` attribute.
you can access the corresponding ``VisaLibrary`` instance under the ``visalib`` attribute.

As an example, consider the VISA function `viMapAddress`. It appears in the low-level
layer as the static method `viMapAddress` of `visalib` attributed and also appears
in the middle-level layer as `map_address`.
As an example, consider the VISA function ``viMapAddress``. It appears in the low-level
layer as the static method ``viMapAddress`` of ``visalib`` attributed and also appears
in the middle-level layer as ``map_address``.

You can recognize low and middle-level functions by their names. Low-level functions
carry the same name as in the shared library, and they are prefixed by `vi`.
carry the same name as in the shared library, and they are prefixed by **vi**.
Middle-level functions have a friendlier, more pythonic but still recognizable name.
Typically, camelCase names where stripped from the leading `vi` and changed to underscore
Typically, camelCase names where stripped from the leading **vi** and changed to underscore
separated lower case names. The docs about these methods is located here :ref:`api`.


Expand All @@ -83,7 +83,7 @@ for example::
>>> rm.visalib.viMapAddress(<here goes the arguments>)

To call this functions you need to know the function declaration and how to
interface it to python. To help you out, the `VisaLibrary` object also contains
interface it to python. To help you out, the ``VisaLibrary`` object also contains
middle-level functions.

It is very likely that you will need to access the VISA constants using these methods.
Expand All @@ -93,7 +93,7 @@ You can find the information about these constants here :ref:`api_constants`
Middle-level
~~~~~~~~~~~~

The `VisaLibrary` object exposes the middle-level functions which are
The ``VisaLibrary`` object exposes the middle-level functions which are
one-to-one mapped from the foreign library as bound methods.

Each middle-level function wraps one low-level function.
Expand Down
12 changes: 6 additions & 6 deletions docs/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ their programs to use other packages with different API.
Since 1.6, PyVISA is a frontend to VISA. It provides a nice, Pythonic API and can
connect to multiple backends. Each backend exposes a class derived from VisaLibraryBase
that implements the low-level communication. The ctypes wrapper around NI-VISA is the
default backend (called `ni`) and is bundled with PyVISA for simplicity.
default backend (called **ni**) and is bundled with PyVISA for simplicity.

You can specify the backend to use when you instantiate the resource manager using the
`@` symbol. Remembering that `ni` is the default, this::
``@`` symbol. Remembering that **ni** is the default, this::

>>> import visa
>>> rm = visa.ResourceManager()
Expand All @@ -32,15 +32,15 @@ You can still provide the path to the library if needed::
>>> import visa
>>> rm = visa.ResourceManager('/path/to/lib@ni')

Under the hood, the `ResourceManager` looks for the requested backend and instantiate
Under the hood, the :class:`pyvisa.highlevel.ResourceManager` looks for the requested backend and instantiate
the VISA library that it provides.

PyVISA locates backends by name. If you do:

>>> import visa
>>> rm = visa.ResourceManager('@somename')

PyVISA will try to import a package/module named `pyvisa-somename` which should be
PyVISA will try to import a package/module named ``pyvisa-somename`` which should be
installed in your system. This is a loosly coupled configuration free method.
PyVISA does not need to know about any backend out there until you actually
try to use it.
Expand All @@ -63,7 +63,7 @@ What does a minimum backend looks like? Quite simple::
WRAPPER_CLASS = MyLibrary

Additionally you can provide a staticmethod named get_debug_info` that should return a
dictionary of debug information which is printed when you call `python -m visa info`
dictionary of debug information which is printed when you call ``python -m visa info``

An important aspect of developing a backend is knowing which VisaLibraryBase method to
implement and what API to expose.
Expand Down Expand Up @@ -95,7 +95,7 @@ If you need to start sending bytes to MessageBased instruments you will require:
For other usages or devices, you might need to implement other functions. Is really up to you
and your needs.

These functions should raise a `VisaIOError` or emit a `VisaIOWarning` if necessary.
These functions should raise a :class:`pyvisa.errors.VisaIOError` or emit a :class:`pyvisa.errors.VisaIOWarning` if necessary.


Complete list of level 2 functions to implement::
Expand Down
2 changes: 1 addition & 1 deletion docs/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Configuring the NI backend

In most cases PyVISA will be able to find the location of the shared visa library.
If this does not work or you want to use another one, you need to provide the library
path to the `ResourceManager` constructor::
path to the :class:`pyvisa.highlevel.ResourceManager` constructor::

>>> rm = ResourceManager('Path to library')

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Contributing to an existing backend

Backends are the central piece of PyVISA as they provide the low level communication
over the different interfaces. There a couple of backends in the wild which can use
your help. Look them up in PyPI_ (try `pyvisa` in the search box) and see where you
your help. Look them up in PyPI_ (try `pyvisa``` in the search box) and see where you
can help.


Expand Down
4 changes: 2 additions & 2 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Error: Could not found VISA library

This error occurs when you have not provided a path for the VISA library and PyVISA
is not able to find it for you. You can solve it by providing the library path to the
`VisaLibrary` or `ResourceManager` constructor::
``VisaLibrary`` or ``ResourceManager`` constructor::

>>> visalib = VisaLibrary('/path/to/library')

Expand Down Expand Up @@ -105,7 +105,7 @@ The solution is to:

1. Install and use a VISA library matching your Python 'bitness'

Download and install it from `National Instruments's VISA`. Run the debug
Download and install it from **National Instruments's VISA**. Run the debug
command again to see if the new library was found by PyVISA. If not,
create a configuration file as described in :ref:`configuring`.

Expand Down

0 comments on commit 4c13fce

Please sign in to comment.