Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit 40d1d14

Browse files
authored
Merge pull request #391 from macartur/improving_sphinx_docs_2017.1rc
Improving sphinx docs 2017.1rc
2 parents 68751fc + d2d5743 commit 40d1d14

43 files changed

Lines changed: 401 additions & 256 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/conf.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,47 @@
389389
# Order methods before attributes/properties on a class
390390
autodoc_member_order = 'groupwise'
391391
todo_include_todos = True
392+
393+
rst_epilog = """
394+
.. |PacketInReason_v0x04| replace::
395+
:class:`~pyof.v0x04.asynchronous.packet_in.PacketInReason`
396+
397+
.. |PortReason_v0x04| replace::
398+
:class:`~pyof.v0x04.asynchronous.port_status.PortReason`
399+
400+
.. |FlowRemoved_v0x04| replace::
401+
:class:`~pyof.v0x04.asynchronous.flow_removed.FlowRemoved`
402+
403+
.. |TableFeaturePropType_v0x04| replace::
404+
:class:`~pyof.v0x04.controller2switch.common.TableFeaturePropType`
405+
406+
.. |ListOfInstruction_v0x04| replace::
407+
:class:`~pyof.v0x04.common.flow_instructions.ListOfInstruction`
408+
409+
.. |GroupType_v0x04| replace::
410+
:class:`~pyof.v0x04.controller2switch.group_mod.GroupType`
411+
412+
.. |ListOfBuckets_v0x04| replace::
413+
:class:`~pyof.v0x04.controller2switch.group_mod.ListOfBuckets`
414+
415+
.. |MeterFlags_v0x04| replace::
416+
:class:`~pyof.v0x04.controller2switch.meter_mod.MeterFlags`
417+
418+
.. |Meter_v0x04| replace::
419+
:class:`~pyof.v0x04.controller2switch.meter_mod.Meter`
420+
421+
.. |MeterBandType_v0x04| replace::
422+
:class:`~pyof.v0x04.controller2switch.meter_mod.MeterBandType`
423+
424+
.. |BandStats_v0x04| replace::
425+
:class:`~.v0x04.controller2switch.multipart_reply.BandStats`
426+
427+
.. |ListOfActions_v0x04| replace::
428+
:class:`~pyof.v0x04.common.action.ListOfActions`
429+
430+
.. |ListOfOxmHeader_v0x04| replace::
431+
:class:`~pyof.v0x04.common.flow_match.ListOfOxmHeader`
432+
433+
.. |Property_v0x04| replace::
434+
:class:`~pyof.v0x04.controller2switch.common.Property`
435+
"""

pyof/foundation/base.py

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __rxor__(self, other):
119119
def value(self):
120120
"""Return this type's value.
121121
122-
The value of an enum, bitmask, etc.
122+
Returns: The value of an enum, bitmask, etc.
123123
"""
124124
if self.isenum():
125125
if isinstance(self._value, self.enum_ref):
@@ -347,14 +347,14 @@ def get_pyof_version(module_fullname):
347347
(e.g.: pyof.v0x01.common.header)
348348
349349
Returns:
350-
str: The module version, on the format 'v0x0?' if any. Or None
351-
if there isn't a version on the fullname.
350+
str: openflow version.
351+
The openflow version, on the format 'v0x0?' if any. Or None
352+
if there isn't a version on the fullname.
352353
"""
353354
ver_module_re = re.compile(r'(pyof\.)(v0x\d+)(\..*)')
354355
matched = ver_module_re.match(module_fullname)
355356
if matched:
356357
version = matched.group(2)
357-
# module = matched.group(3)
358358
return version
359359
return None
360360

@@ -386,7 +386,7 @@ def replace_pyof_version(module_fullname, version):
386386

387387
@staticmethod
388388
def get_pyof_obj_new_version(name, obj, new_version):
389-
"""Return a class atrribute on a different pyof version.
389+
r"""Return a class attribute on a different pyof version.
390390
391391
This method receives the name of a class attribute, the class attribute
392392
itself (object) and an openflow version.
@@ -399,14 +399,19 @@ def get_pyof_obj_new_version(name, obj, new_version):
399399
an instance of the new version of the 'obj'.
400400
401401
Example:
402-
>> from pyof.v0x01.common.header import Header
403-
>> name = 'header'
404-
>> obj = Header()
405-
>> obj
406-
<pyof.v0x01.common.header.Header at 0x...>
407-
>> new_version = 'v0x02'
408-
>> MetaStruct.get_pyof_new_version(name, obj, new_version)
409-
('header', <pyof.v0x02.common.header.Header at 0x...)
402+
403+
>>> from pyof.foundation.base import MetaStruct as ms
404+
>>> from pyof.v0x01.common.header import Header
405+
>>> name = 'header'
406+
>>> obj = Header()
407+
>>> new_version = 'v0x04'
408+
>>> header, obj2 = ms.get_pyof_obj_new_version(name, obj, new_version)
409+
>>> header
410+
'header'
411+
>>> obj.version
412+
UBInt8(1)
413+
>>> obj2.version
414+
UBInt8(4)
410415
411416
Args:
412417
name (str): the name of the class attribute being handled.
@@ -415,13 +420,14 @@ def get_pyof_obj_new_version(name, obj, new_version):
415420
'obj'.
416421
417422
Return:
418-
(str, obj): A tuple in which the first item is the name of the
419-
class attribute (the same that was passed), and the second item
420-
is a instance of the passed class attribute. If the class
421-
attribute is not a pyof versioned attribute, then the same
422-
passed object is returned without any changes. Also, if the obj
423-
is a pyof versioned attribute, but it is already on the right
424-
version (same as new_version), then the passed obj is return.
423+
(str, obj): Tuple with class name and object instance.
424+
A tuple in which the first item is the name of the class
425+
attribute (the same that was passed), and the second item is a
426+
instance of the passed class attribute. If the class attribute
427+
is not a pyof versioned attribute, then the same passed object
428+
is returned without any changes. Also, if the obj is a pyof
429+
versioned attribute, but it is already on the right version
430+
(same as new_version), then the passed obj is return.
425431
"""
426432
if new_version is None:
427433
return (name, obj)
@@ -469,6 +475,9 @@ def __eq__(self, other):
469475
470476
Args:
471477
other (GenericStruct): The struct to be compared with.
478+
479+
Returns:
480+
bool: Returns the result of comparation.
472481
"""
473482
return self.pack() == other.pack()
474483

@@ -488,9 +497,8 @@ def _is_pyof_attribute(obj):
488497
To be a kytos attribute the item must be an instance of either
489498
GenericType or GenericStruct.
490499
491-
returns:
492-
True: if the obj is a kytos attribute
493-
False: if the obj is not a kytos attribute
500+
Returns:
501+
bool: Returns TRUE if the obj is a kytos attribute, otherwise False
494502
"""
495503
return isinstance(obj, (GenericType, GenericStruct))
496504

pyof/foundation/basic_types.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __init__(self, dpid=None):
118118
"""Create an instance and optionally set its dpid value.
119119
120120
Args:
121-
dpid (str): E.g. 00:00:00:00:00:00:00:01.
121+
dpid (str): String with DPID value(e.g. `00:00:00:00:00:00:00:01`).
122122
"""
123123
super().__init__(value=dpid)
124124

@@ -127,7 +127,11 @@ def __str__(self):
127127

128128
@property
129129
def value(self):
130-
"""Return dpid value."""
130+
"""Return dpid value.
131+
132+
Returns:
133+
str: DataPath ID stored by DPID class.
134+
"""
131135
return self._value
132136

133137
def pack(self, value=None):
@@ -237,8 +241,7 @@ def __init__(self, address="0.0.0.0/32"):
237241
"""The constructor takes the parameters below.
238242
239243
Args:
240-
address (str): IP Address using ipv4.
241-
Defaults to '0.0.0.0/32'
244+
address (str): IP Address using ipv4. Defaults to '0.0.0.0/32'
242245
"""
243246
if address.find('/') >= 0:
244247
address, netmask = address.split('/')
@@ -256,7 +259,7 @@ def pack(self, value=None):
256259
Args:
257260
value (str): IP Address with ipv4 format.
258261
259-
Returns
262+
Returns:
260263
bytes: The binary representation.
261264
262265
Raises:

0 commit comments

Comments
 (0)