From 86e01885b4db7950c40ba5ff6d063670bd5d447f Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Sat, 11 Jun 2022 12:38:04 -0700 Subject: [PATCH] working on docs (pcapkit.const.ipv6) --- .editorconfig | 3 + doc/sphinx/source/pcapkit/const/ipv6.rst | 77 ++++++++++++++++-------- pcapkit/const/ipv6/__init__.py | 35 ++++++++++- pcapkit/const/ipv6/extension_header.py | 10 ++- pcapkit/vendor/ipv6/extension_header.py | 18 ++++-- pcapkit/vendor/ipv6/smf_dpd_mode.py | 2 +- 6 files changed, 109 insertions(+), 36 deletions(-) diff --git a/.editorconfig b/.editorconfig index 153216992..e58b3b500 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,3 +16,6 @@ indent_size = 2 [Makefile] indent_style = tab + +[*.rst] +indent_size = 3 diff --git a/doc/sphinx/source/pcapkit/const/ipv6.rst b/doc/sphinx/source/pcapkit/const/ipv6.rst index 8e823b052..f81ab252d 100644 --- a/doc/sphinx/source/pcapkit/const/ipv6.rst +++ b/doc/sphinx/source/pcapkit/const/ipv6.rst @@ -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 ` + - IPv6 Extension Header Types [*]_ + * - :class:`IPv6_Option ` + - Destination Options and Hop-by-Hop Options [*]_ + * - :class:`IPv6_QSFunction ` + - IPv6 QS Functions + * - :class:`IPv6_RouterAlert ` + - IPv6 Router Alert Option Values [*]_ + * - :class:`IPv6_Routing ` + - Routing Types [*]_ + * - :class:`IPv6_SeedID ` + - Seed-ID Types + * - :class:`IPv6_SMFDPDMode ` + - Simplified Multicast Forwarding Duplicate Packet Detection (``SMF_DPD``) Options + * - :class:`IPv6_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: diff --git a/pcapkit/const/ipv6/__init__.py b/pcapkit/const/ipv6/__init__.py index d2dacd4cb..5a0effcf6 100644 --- a/pcapkit/const/ipv6/__init__.py +++ b/pcapkit/const/ipv6/__init__.py @@ -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 ` + - IPv6 Extension Header Types [*]_ + * - :class:`IPv6_Option ` + - Destination Options and Hop-by-Hop Options [*]_ + * - :class:`IPv6_QSFunction ` + - IPv6 QS Functions + * - :class:`IPv6_RouterAlert ` + - IPv6 Router Alert Option Values [*]_ + * - :class:`IPv6_Routing ` + - Routing Types [*]_ + * - :class:`IPv6_SeedID ` + - Seed-ID Types + * - :class:`IPv6_SMFDPDMode ` + - Simplified Multicast Forwarding Duplicate Packet Detection (``SMF_DPD``) Options + * - :class:`IPv6_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 diff --git a/pcapkit/const/ipv6/extension_header.py b/pcapkit/const/ipv6/extension_header.py index 5ae456ea1..db09872c5 100644 --- a/pcapkit/const/ipv6/extension_header.py +++ b/pcapkit/const/ipv6/extension_header.py @@ -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 diff --git a/pcapkit/vendor/ipv6/extension_header.py b/pcapkit/vendor/ipv6/extension_header.py index 00a2d791b..9ba1d53bb 100644 --- a/pcapkit/vendor/ipv6/extension_header.py +++ b/pcapkit/vendor/ipv6/extension_header.py @@ -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 @@ -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): @@ -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: @@ -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__': diff --git a/pcapkit/vendor/ipv6/smf_dpd_mode.py b/pcapkit/vendor/ipv6/smf_dpd_mode.py index 480467576..fbbdc843a 100644 --- a/pcapkit/vendor/ipv6/smf_dpd_mode.py +++ b/pcapkit/vendor/ipv6/smf_dpd_mode.py @@ -11,7 +11,7 @@ __all__ = ['SMFDPDMode'] -#: QS function registry. +#: ``SMF_DPD`` mode registry. DATA = { 0: 'I-DPD', 1: 'H-DPD',