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

Commit d9bc9b1

Browse files
committed
Fix multiple references warnings using v0x01
This commit will fix sphinx warnings with more than one target found.
1 parent 51455ed commit d9bc9b1

25 files changed

Lines changed: 160 additions & 108 deletions

pyof/foundation/base.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
structs. You can realize that when you see a message class definition.
66
77
A **struct** here is a group of basic attributes and/or struct attributes (i.e.
8-
:class:`~.common.header.Header`). A **message** here is like a struct, but all
9-
messages have a header attribute (i.e.
10-
:class:`~.asynchronous.packet_in.PacketIn`).
8+
:class:`~pyof.v0x01.common.header.Header`). A **message** here is like a
9+
struct, but all messages have a header attribute (i.e.
10+
:class:`~pyof.v0x01.asynchronous.packet_in.PacketIn`).
11+
1112
1213
The main classes of this module are :class:`GenericStruct`,
1314
:class:`GenericMessage`, :class:`GenericBitMask` and :class:`GenericType`.
@@ -49,9 +50,9 @@ def __init__(self, value=None, enum_ref=None):
4950
"""The constructor takes the optional parameters below.
5051
5152
Args:
52-
value: The type's value.
53-
enum_ref (:class:`type`): If :attr:`value` is from an Enum, specify
54-
its type.
53+
value : The type's value.
54+
enum_ref (type): If :attr:`value` is from an Enum, specify
55+
its type.
5556
"""
5657
self._value = value
5758
self.enum_ref = enum_ref
@@ -219,10 +220,10 @@ def is_valid(self):
219220
return False
220221

221222
def isenum(self):
222-
"""Test whether it is an :class:`~Enum`.
223+
"""Test whether it is an :class:`~enum.Enum`.
223224
224225
Returns:
225-
bool: Whether it is an :class:`~Enum`.
226+
bool: Whether it is an :class:`~enum.Enum`.
226227
"""
227228
return self.enum_ref and issubclass(self.enum_ref, (Enum, IntEnum))
228229

@@ -346,8 +347,8 @@ def get_pyof_version(module_fullname):
346347
(e.g.: pyof.v0x01.common.header)
347348
348349
Returns:
349-
version (str): The module version, on the format 'v0x0?' if any. Or
350-
None (None): If there isn't a version on the fullname.
350+
str : The module version, on the format 'v0x0?' if any. Or None
351+
if there isn't a version on the fullname.
351352
"""
352353
ver_module_re = re.compile(r'(pyof\.)(v0x\d+)(\..*)')
353354
matched = ver_module_re.match(module_fullname)
@@ -366,15 +367,16 @@ def replace_pyof_version(module_fullname, version):
366367
367368
Args:
368369
module_fullname (str): The fullname of the module
369-
(e.g.: pyof.v0x01.common.header)
370+
(e.g.: pyof.v0x01.common.header)
370371
version (str): The version to be 'inserted' on the module fullname.
371372
372373
Returns:
373-
None (None): if the requested version is the same as the one of the
374-
module_fullname or if the module_fullname is not a 'OF version'
375-
specific module.
376-
new_module_fullname (str): The new module fullname, with the
377-
replaced version, on the format "pyof.v0x01.common.header".
374+
str : module fullname
375+
The new module fullname, with the replaced version,
376+
on the format "pyof.v0x01.common.header". If the requested
377+
version is the same as the one of the module_fullname or if
378+
the module_fullname is not a 'OF version' specific module
379+
the return is None.
378380
"""
379381
module_version = MetaStruct.get_pyof_version(module_fullname)
380382
if not module_version or module_version == version:
@@ -413,7 +415,7 @@ def get_pyof_obj_new_version(name, obj, new_version):
413415
'obj'.
414416
415417
Return:
416-
(name, obj): A tuple in which the first item is the name of the
418+
(str, obj): A tuple in which the first item is the name of the
417419
class attribute (the same that was passed), and the second item
418420
is a instance of the passed class attribute. If the class
419421
attribute is not a pyof versioned attribute, then the same
@@ -655,8 +657,9 @@ def is_valid(self):
655657
656658
This method will check whether all struct attributes have a proper
657659
value according to the OpenFlow specification. For instance, if you
658-
have a struct with an attribute of type :class:`UBInt8()`
659-
and you assign a string value to it, this method will return False.
660+
have a struct with an attribute of type
661+
:class:`~pyof.foundation.basic_types.UBInt8` and you assign a string
662+
value to it, this method will return False.
660663
661664
Returns:
662665
bool: Whether the struct is valid.

pyof/foundation/basic_types.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,11 @@ def is_broadcast(self):
401401
class BinaryData(GenericType):
402402
"""Class to create objects that represent binary data.
403403
404-
This is used in the ``data`` attribute from :class:`.PacketIn` and
405-
:class:`.PacketOut` messages. Both the :meth:`pack` and :meth:`unpack`
406-
methods will return the binary data itself. :meth:`get_size` method will
404+
This is used in the ``data`` attribute from
405+
:class:`~pyof.v0x01.asynchronous.packet_in.PacketIn` and
406+
:class:`~pyof.v0x01.controller2switch.packet_out.PacketOut` messages.
407+
Both the :meth:`pack` and :meth:`unpack` methods will return the
408+
binary data itself. :meth:`get_size` method will
407409
return the size of the instance using Python's :func:`len`.
408410
"""
409411

pyof/v0x01/asynchronous/error_msg.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class ErrorMsg(GenericMessage):
170170
This message does not contain a body in addition to the OpenFlow Header.
171171
"""
172172

173-
#: :class:`~.header.Header`: OpenFlow Header
173+
#: :class:`~pyof.v0x01.common.header.Header`: OpenFlow Header
174174
header = Header(message_type=Type.OFPT_ERROR)
175175
error_type = UBInt16(enum_ref=ErrorType)
176176
code = UBInt16()
@@ -181,10 +181,9 @@ def __init__(self, xid=None, error_type=None, code=None, data=b''):
181181
182182
Args:
183183
xid (int): To be included in the message header.
184-
error_type (ErrorType): Error type.
185-
code (Enum): Error code.
186-
data (:func:`bytes` or packable): Its content is based on the error
187-
type and code.
184+
error_type (:class:`ErrorType`): Error type.
185+
code (enum.IntEnum): Error code.
186+
data (bytes): Its content is based on the error type and code.
188187
"""
189188
super().__init__(xid)
190189
self.error_type = error_type
@@ -198,7 +197,7 @@ def pack(self, value=None):
198197
After that, :attr:`data`'s value is restored.
199198
200199
Returns:
201-
bytes: The binary representation.
200+
bytes : The binary representation.
202201
"""
203202
if value is None:
204203
data_backup = None
@@ -217,7 +216,18 @@ def pack(self, value=None):
217216
raise PackException(msg)
218217

219218
def unpack(self, buff, offset=0):
220-
"""Unpack binary data into python object."""
219+
"""Unpack *buff* into this object.
220+
221+
This method will convert a binary data into a readable value according
222+
to the attribute format.
223+
224+
Args:
225+
buff (bytes): Binary buffer.
226+
offset (int): Where to begin unpacking.
227+
228+
Raises:
229+
:exc:`~.exceptions.UnpackException`: If unpack fails.
230+
"""
221231
super().unpack(buff, offset)
222232
CodeClass = ErrorType(self.error_type).get_class()
223233
self.code = CodeClass(self.code)

pyof/v0x01/asynchronous/flow_removed.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class FlowRemovedReason(IntEnum):
2929
class FlowRemoved(GenericMessage):
3030
"""Flow removed (datapath -> controller)."""
3131

32-
#: :class:`~.header.Header`: OpenFlow Header
32+
#: :class:`~pyof.v0x01.common.header.Header`: OpenFlow Header
3333
header = Header(message_type=Type.OFPT_FLOW_REMOVED)
34-
#: :class:`~.flow_match.Match`: OpenFlow Header
34+
#: :class:`~pyof.v0x01.common.flow_match.Match`: OpenFlow Header
3535
match = Match()
3636
cookie = UBInt64()
3737

@@ -56,10 +56,11 @@ def __init__(self, xid=None, match=None, cookie=None, priority=None,
5656
5757
Args:
5858
xid (int): OpenFlow Header's xid.
59-
match (Match): Fields' description.
59+
match (~pyof.v0x01.common.flow_match.Match): Fields' description.
6060
cookie (int): Opaque controller-issued identifier.
6161
priority (int): Priority level of flow entry.
62-
reason (FlowRemovedReason): Why the flow was removed.
62+
reason (~pyof.v0x01.asynchronous.flow_removed.FlowRemovedReason):
63+
Why the flow was removed.
6364
duration_sec (int): Time the flow was alive in seconds.
6465
duration_nsec (int): Time the flow was alive in nanoseconds in
6566
addition to duration_sec.

pyof/v0x01/asynchronous/packet_in.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PacketInReason(IntEnum):
3232
class PacketIn(GenericMessage):
3333
"""Packet received on port (datapath -> controller)."""
3434

35-
#: :class:`~.header.Header`: OpenFlow Header
35+
#: :class:`~pyof.v0x01.common.header.Header`: OpenFlow Header
3636
header = Header(message_type=Type.OFPT_PACKET_IN)
3737
buffer_id = UBInt32()
3838
total_len = UBInt16()
@@ -51,7 +51,8 @@ def __init__(self, xid=None, buffer_id=NO_BUFFER, total_len=None,
5151
buffer_id (int): ID assigned by datapath.
5252
total_len (int): Full length of frame.
5353
in_port (int): Port on which frame was received.
54-
reason (PacketInReason): The reason why the packet is being sent
54+
reason (~pyof.v0x01.asynchronous.packet_in.PacketInReason):
55+
The reason why the packet is being sent
5556
data (bytes): Ethernet frame, halfway through 32-bit word, so the
5657
IP header is 32-bit aligned. The amount of data is inferred
5758
from the length field in the header. Because of padding,

pyof/v0x01/asynchronous/port_status.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PortReason(IntEnum):
3232
class PortStatus(GenericMessage):
3333
"""A physical port has changed in the datapath."""
3434

35-
#: :class:`~.header.Header`: OpenFlow Header
35+
#: :class:`~pyof.v0x01.common.header.Header`: OpenFlow Header
3636
header = Header(message_type=Type.OFPT_PORT_STATUS)
3737
reason = UBInt8(enum_ref=PortReason)
3838
#: Align to 32-bits.
@@ -44,7 +44,8 @@ def __init__(self, xid=None, reason=None, desc=None):
4444
4545
Args:
4646
xid (int): Header's xid.
47-
reason (PortReason): Addition, deletion or modification.
47+
reason (~pyof.v0x01.asynchronous.port_status.PortReason):
48+
Addition, deletion or modification.
4849
desc (PhyPort): Port description.
4950
"""
5051
super().__init__(xid)

pyof/v0x01/common/action.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def __init__(self, action_type=None, length=None):
6767
"""The following constructor parameters are optional.
6868
6969
Args:
70-
action_type (ActionType): The type of the action.
70+
action_type (~pyof.v0x01.common.action.ActionType):
71+
The type of the action.
7172
length (int): Length of action, including this header.
7273
"""
7374
super().__init__()
@@ -122,7 +123,8 @@ def __init__(self, port=None, max_length=UBINT16_MAX_VALUE):
122123
"""The following constructor parameters are optional.
123124
124125
Args:
125-
port (:class:`Port` or :class:`int`): Output port.
126+
port (:class:`~pyof.v0x01.common.phy_port.Port` or :class:`int`):
127+
Output port.
126128
max_length (int): Max length to send to controller.
127129
"""
128130
super().__init__(action_type=ActionType.OFPAT_OUTPUT, length=8)
@@ -218,7 +220,8 @@ def __init__(self, action_type=None, dl_addr=None):
218220
"""The following constructor parameters are optional.
219221
220222
Args:
221-
action_type (ActionType): :attr:`~ActionType.OFPAT_SET_DL_SRC` or
223+
action_type (~pyof.v0x01.common.action.ActionType):
224+
:attr:`~ActionType.OFPAT_SET_DL_SRC` or
222225
:attr:`~ActionType.OFPAT_SET_DL_DST`.
223226
dl_addr (:class:`~.HWAddress`): Ethernet address.
224227
Defaults to None.
@@ -238,7 +241,8 @@ def __init__(self, action_type=None, nw_addr=None):
238241
"""The following constructor parameters are optional.
239242
240243
Args:
241-
action_type (ActionType): :attr:`~ActionType.OFPAT_SET_NW_SRC` or
244+
action_type (~pyof.v0x01.common.action.ActionType):
245+
:attr:`~ActionType.OFPAT_SET_NW_SRC` or
242246
:attr:`~ActionType.OFPAT_SET_NW_DST`.
243247
nw_addr (int): IP Address.
244248
"""
@@ -263,7 +267,8 @@ def __init__(self, action_type=None, nw_tos=None):
263267
"""The following constructor parameters are optional.
264268
265269
Args:
266-
action_type (ActionType): :attr:`~ActionType.OFPAT_SET_NW_SRC` or
270+
action_type (~pyof.v0x01.common.action.ActionType):
271+
:attr:`~ActionType.OFPAT_SET_NW_SRC` or
267272
:attr:`~ActionType.OFPAT_SET_NW_DST`.
268273
nw_tos (int): IP ToS (DSCP field, 6 bits).
269274
"""
@@ -284,7 +289,8 @@ def __init__(self, action_type=None, tp_port=None):
284289
"""The following constructor parameters are optional.
285290
286291
Args:
287-
action_type (ActionType): :attr:`~ActionType.OFPAT_SET_TP_SRC` or
292+
action_type (~pyof.v0x01.common.action.ActionType):
293+
:attr:`~ActionType.OFPAT_SET_TP_SRC` or
288294
:attr:`~ActionType.OFPAT_SET_TP_DST`.
289295
tp_port (int): TCP/UDP/other port to set.
290296
"""

pyof/v0x01/common/header.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, message_type=None, length=None, xid=None):
7777
"""The constructor takes the optional parameters below.
7878
7979
Args:
80-
message_type (Type): Type of the message.
80+
message_type (~pyof.v0x01.common.header.Type): Type of the message.
8181
xid (int): ID of the message. Defaults to a random integer.
8282
length (int): Length of the message, including the header itself.
8383
"""

pyof/v0x01/common/phy_port.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,14 @@ class PhyPort(GenericStruct):
133133
134134
The port_no field is a value the datapath associates with a physical port.
135135
The hw_addr field typically is the MAC address for the port;
136-
:data:`.OFP_ETH_ALEN` is 6. The name field is a
136+
:data:`OFP_ETH_ALEN` is 6. The name field is a
137137
null-terminated string containing a human-readable name for the interface.
138-
The value of :data:`.OFP_MAX_PORT_NAME_LEN` is 16.
138+
The value of :data:`OFP_MAX_PORT_NAME_LEN` is 16.
139139
140140
:attr:`curr`, :attr:`advertised`, :attr:`supported` and :attr:`peer` are
141-
bitmaps of :class:`PortFeatures` enum values that describe features. If
142-
unsupported or unavailable, set all bits to zero.
141+
bitmaps of :class:`~pyof.v0x01.common.phy_port.PortFeatures` enum values
142+
that describe features. If unsupported or unavailable, set all bits to
143+
zero.
143144
"""
144145

145146
port_no = UBInt16()
@@ -161,12 +162,17 @@ def __init__(self, port_no=None, hw_addr=None, name=None, config=None,
161162
port_no (int): Port number.
162163
hw_addr (HWAddress): Hardware address.
163164
name(str): Null-terminated name.
164-
config (PortConfig): Bitmap of OFPPC* flags.
165-
state (PortState): Bitmap of OFPPS* flags.
166-
curr (PortFeatures): Current features.
167-
advertised (PortFeatures): Features being advertised by the port.
168-
supported (PortFeatures): Features supported by the port.
169-
peer (PortFeatures): Features advertised by peer.
165+
config (~pyof.v0x01.common.phy_port.PortConfig):
166+
Bitmap of OFPPC* flags.
167+
state (~pyof.v0x01.common.phy_port.PortState):
168+
Bitmap of OFPPS* flags.
169+
curr (~pyof.v0x01.common.phy_port.PortFeatures): Current features.
170+
advertised (~pyof.v0x01.common.phy_port.PortFeatures):
171+
Features being advertised by the port.
172+
supported (~pyof.v0x01.common.phy_port.PortFeatures):
173+
Features supported by the port.
174+
peer (~pyof.v0x01.common.phy_port.PortFeatures):
175+
Features advertised by peer.
170176
"""
171177
super().__init__()
172178
self.port_no = port_no
@@ -184,7 +190,9 @@ class ListOfPhyPorts(FixedTypeList):
184190
"""List of PhyPorts.
185191
186192
Represented by instances of PhyPort and used on
187-
:class:`.FeaturesReply`/:class:`.SwitchFeatures` objects.
193+
:class:`pyof.v0x01.common.phy_port.FeaturesReply`/
194+
:class:`pyof.v0x01.controller2switch.features_reply.SwitchFeatures`
195+
objects.
188196
"""
189197

190198
def __init__(self, items=None):

pyof/v0x01/common/queue.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def __init__(self, queue_property=None, length=None):
5858
"""The contructor takes the paremeters below.
5959
6060
Args:
61-
queue_property (QueueProperties): The queue property.
61+
queue_property (~pyof.v0x01.common.queue.QueueProperties):
62+
The queue property.
6263
length (int): Length of property, including this header.
6364
"""
6465
super().__init__()
@@ -81,8 +82,8 @@ def __init__(self, queue_id=None, length=None, properties=None):
8182
Args:
8283
queue_id (int): ID of the specific queue.
8384
length (int): Length in bytes of this queue desc.
84-
properties(ListOfProperties): Queue's list of properties. Default
85-
is an empty list.
85+
properties(~pyof.v0x01.common.queue.ListOfProperties):
86+
Queue's list of properties. Default is an empty list.
8687
"""
8788
super().__init__()
8889
self.queue_id = queue_id

0 commit comments

Comments
 (0)