Skip to content

Commit

Permalink
working on docs (pcapkit.const.ipv6)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarryShaw committed Jun 11, 2022
1 parent 391ab87 commit 86e0188
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ indent_size = 2

[Makefile]
indent_style = tab

[*.rst]
indent_size = 3
77 changes: 51 additions & 26 deletions doc/sphinx/source/pcapkit/const/ipv6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,91 @@ IPv6 Constant Enumerations

.. module:: pcapkit.const.ipv6

IPv6 Extension Header Types [*]_
--------------------------------
This module contains all constant enumerations of
:class:`~pcapkit.protocols.internet.ipv6.IPv6` implementations. Available
enumerations include:

.. list-table::
:widths: auto

* - :class:`IPv6_Extension_Header <pcapkit.const.ipv6.extension_header.ExtensionHeader>`
- IPv6 Extension Header Types [*]_
* - :class:`IPv6_Option <pcapkit.const.ipv6.option.Option>`
- Destination Options and Hop-by-Hop Options [*]_
* - :class:`IPv6_QSFunction <pcapkit.const.ipv6.qs_function.QSFunction>`
- IPv6 QS Functions
* - :class:`IPv6_RouterAlert <pcapkit.const.ipv6.router_alert.RouterAlert>`
- IPv6 Router Alert Option Values [*]_
* - :class:`IPv6_Routing <pcapkit.const.ipv6.routing.Routing>`
- Routing Types [*]_
* - :class:`IPv6_SeedID <pcapkit.const.ipv6.seed_id.SeedID>`
- Seed-ID Types
* - :class:`IPv6_SMFDPDMode <pcapkit.const.ipv6.smf_dpd_mode.SMFDPDMode>`
- Simplified Multicast Forwarding Duplicate Packet Detection (``SMF_DPD``) Options
* - :class:`IPv6_TaggerID <pcapkit.const.ipv6.tagger_id.TaggerID>`
- Tagger-ID Types [*]_

.. automodule:: pcapkit.const.ipv6.extension_header
:no-members:

.. autoclass:: pcapkit.const.ipv6.extension_header.ExtensionHeader
:members:
:undoc-members:
:private-members:
:show-inheritance:

Destination Options and Hop-by-Hop Options [*]_
-----------------------------------------------

.. automodule:: pcapkit.const.ipv6.option
:no-members:

.. autoclass:: pcapkit.const.ipv6.option.Option
:members:
:undoc-members:
:private-members:
:show-inheritance:

IPv6 QS Functions
-----------------

.. automodule:: pcapkit.const.ipv6.qs_function
:no-members:

.. autoclass:: pcapkit.const.ipv6.qs_function.QSFunction
:members:
:undoc-members:
:private-members:
:show-inheritance:

IPv6 Router Alert Option Values [*]_
------------------------------------

.. automodule:: pcapkit.const.ipv6.router_alert
:no-members:

.. autoclass:: pcapkit.const.ipv6.router_alert.RouterAlert
:members:
:undoc-members:
:private-members:
:show-inheritance:

Routing Types [*]_
------------------

.. automodule:: pcapkit.const.ipv6.routing
:no-members:

.. autoclass:: pcapkit.const.ipv6.routing.Routing
:members:
:undoc-members:
:private-members:
:show-inheritance:

Seed-ID Types
-------------

.. automodule:: pcapkit.const.ipv6.seed_id
:no-members:

.. autoclass:: pcapkit.const.ipv6.seed_id.SeedID
:members:
:undoc-members:
:private-members:
:show-inheritance:

TaggerId Types [*]_
-------------------
.. automodule:: pcapkit.const.ipv6.smf_dpd_mode
:no-members:

.. autoclass:: pcapkit.const.ipv6.smf_dpd_mode.SMFDPDMode
:members:
:private-members:
:show-inheritance:

.. automodule:: pcapkit.const.ipv6.tagger_id
:no-members:

.. autoclass:: pcapkit.const.ipv6.tagger_id.TaggerID
:members:
:undoc-members:
:private-members:
:show-inheritance:

Expand Down
35 changes: 34 additions & 1 deletion pcapkit/const/ipv6/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
# -*- coding: utf-8 -*-
# pylint: disable=unused-import
"""IPv6 constant enumerations."""
""":class:`~pcapkit.protocols.internet.ipv6.IPv6` Constant Enumerations
===========================================================================
This module contains all constant enumerations of
:class:`~pcapkit.protocols.internet.ipv6.IPv6` implementations. Available
enumerations include:
.. list-table::
:widths: auto
* - :class:`IPv6_Extension_Header <pcapkit.const.ipv6.extension_header.ExtensionHeader>`
- IPv6 Extension Header Types [*]_
* - :class:`IPv6_Option <pcapkit.const.ipv6.option.Option>`
- Destination Options and Hop-by-Hop Options [*]_
* - :class:`IPv6_QSFunction <pcapkit.const.ipv6.qs_function.QSFunction>`
- IPv6 QS Functions
* - :class:`IPv6_RouterAlert <pcapkit.const.ipv6.router_alert.RouterAlert>`
- IPv6 Router Alert Option Values [*]_
* - :class:`IPv6_Routing <pcapkit.const.ipv6.routing.Routing>`
- Routing Types [*]_
* - :class:`IPv6_SeedID <pcapkit.const.ipv6.seed_id.SeedID>`
- Seed-ID Types
* - :class:`IPv6_SMFDPDMode <pcapkit.const.ipv6.smf_dpd_mode.SMFDPDMode>`
- Simplified Multicast Forwarding Duplicate Packet Detection (``SMF_DPD``) Options
* - :class:`IPv6_TaggerID <pcapkit.const.ipv6.tagger_id.TaggerID>`
- Tagger-ID Types [*]_
.. [*] https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#extension-header
.. [*] https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#ipv6-parameters-2
.. [*] https://www.iana.org/assignments/ipv6-routeralert-values/ipv6-routeralert-values.xhtml#ipv6-routeralert-values-1
.. [*] https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#ipv6-parameters-3
.. [*] https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#taggerId-types
"""

from pcapkit.const.ipv6.extension_header import ExtensionHeader as IPv6_ExtensionHeader
from pcapkit.const.ipv6.option import Option as IPv6_Option
Expand Down
10 changes: 8 additions & 2 deletions pcapkit/const/ipv6/extension_header.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# -*- coding: utf-8 -*-
# pylint: disable=line-too-long
"""IPv6 Extension Header Types"""
# pylint: disable=line-too-long,consider-using-f-string
"""IPv6 Extension Header Types
=================================
This module contains the constant enumeration for **IPv6 Extension Header Types**,
which is automatically generated from :class:`pcapkit.vendor.ipv6.extension_header.ExtensionHeader`.
"""

from aenum import IntEnum, extend_enum

Expand Down
18 changes: 12 additions & 6 deletions pcapkit/vendor/ipv6/extension_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@

__all__ = ['ExtensionHeader']

LINE = lambda NAME, DOCS, ENUM: f'''\
LINE = lambda NAME, DOCS, ENUM, MODL: f'''\
# -*- coding: utf-8 -*-
# pylint: disable=line-too-long
"""{DOCS}"""
# pylint: disable=line-too-long,consider-using-f-string
"""{(name := DOCS.split(' [', maxsplit=1)[0])}
{'=' * (len(name) + 6)}
This module contains the constant enumeration for **{name}**,
which is automatically generated from :class:`{MODL}.{NAME}`.
"""
from aenum import IntEnum, extend_enum
Expand All @@ -35,7 +41,7 @@ def get(key: 'int | str', default: 'int' = -1) -> '{NAME}':
if isinstance(key, int):
return {NAME}(key)
return {NAME}[key] # type: ignore[misc]
''' # type: Callable[[str, str, str], str]
''' # type: Callable[[str, str, str, str], str]


class ExtensionHeader(Vendor):
Expand All @@ -44,7 +50,7 @@ class ExtensionHeader(Vendor):
#: Link to registry.
LINK = 'https://www.iana.org/assignments/protocol-numbers/protocol-numbers-1.csv'

def count(self, data: 'list[str]') -> 'Counter[str]': # pylint: disable=no-self-use
def count(self, data: 'list[str]') -> 'Counter[str]':
"""Count field records.
Args:
Expand Down Expand Up @@ -141,7 +147,7 @@ def context(self, data: 'list[str]') -> 'str':
"""
enum, _ = self.process(data)
ENUM = '\n\n '.join(map(lambda s: s.rstrip(), enum))
return LINE(self.NAME, self.DOCS, ENUM)
return LINE(self.NAME, self.DOCS, ENUM, self.__module__)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion pcapkit/vendor/ipv6/smf_dpd_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

__all__ = ['SMFDPDMode']

#: QS function registry.
#: ``SMF_DPD`` mode registry.
DATA = {
0: 'I-DPD',
1: 'H-DPD',
Expand Down

0 comments on commit 86e0188

Please sign in to comment.