Skip to content

Commit

Permalink
minor revision for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JarryShaw committed May 7, 2023
1 parent 814c874 commit 0079c3c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ docs:
PCAPKIT_SPHINX=1 pipenv run $(MAKE) -C docs html

docs-clean:
rm -rf docs/build/html
PCAPKIT_SPHINX=1 pipenv run $(MAKE) -C docs clean

isort:
pipenv run isort -l100 -ppcapkit --skip-glob '**/__init__.py' pcapkit temp/sort.py
Expand Down
18 changes: 16 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
os.environ['PCAPKIT_SPHINX'] = '1'

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.INFO)

# -- Path setup --------------------------------------------------------------

Expand Down Expand Up @@ -102,6 +102,8 @@
napoleon_use_rtype = True
napoleon_use_keyword = True
napoleon_custom_sections = None
napoleon_preprocess_types = True
napoleon_attr_annotations = True

manpages_url = 'https://linux.die.net/man/{section}/{page}'

Expand All @@ -112,6 +114,8 @@
always_document_param_types = False
typehints_document_rtype = True

toc_object_entries = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down Expand Up @@ -200,7 +204,16 @@ def process_docstring(app: 'Sphinx', what: str, name: str, # pylint: disable=un
importlib.reload(module)


def source_read(app: 'Sphinx', docname: str, source_text: str) -> None: # pylint: disable=unused-argument
def process_fields(app: 'Sphinx', what: str, name: str, obj: 'Any', options: 'Dict[str, Any]', lines: 'List[str]') -> 'None':
if what == 'attribute' \
and name.startswith('pcapkit.protocols.schema') \
and type(obj).__module__.startswith('pcapkit.corekit.fields'):

print(name, obj)
#lines.append(':param packet: Packet data.',)


def source_read(app: 'Sphinx', docname: str, source_text: str) -> 'None': # pylint: disable=unused-argument
print(docname, source_text)


Expand All @@ -209,6 +222,7 @@ def setup(app: 'Sphinx') -> None:
#app.connect("autodoc-process-docstring", remove_module_docstring)
app.connect('autodoc-skip-member', maybe_skip_member)
#app.connect('source-read', source_read)
#app.connect('autodoc-process-docstring', process_fields)

# typing.TYPE_CHECKING = True
# for name, module in sys.modules.copy().items():
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pcapkit/foundation/engines/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ support.

Implement support for `PCAP-NG`_ file format.

.. _PCAPNG: https://wiki.wireshark.org/Development/PcapNg
.. _PCAP-NG: https://wiki.wireshark.org/Development/PcapNg
7 changes: 7 additions & 0 deletions pcapkit/corekit/fields/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ def __call__(self, packet: 'dict[str, Any]') -> 'Self':
new_self._callback(new_self, packet)
return new_self

# NOTE: This method is created as a placeholder for the necessary attributes.
def __init__(self, *args: 'Any', **kwargs: 'Any') -> 'None':
self._name = f'<{type(self).__name__[:-5].lower()}>'
self._default = NoValue
self._template = '0s'
self._callback = lambda *_: None

def __repr__(self) -> 'str':
if not self.name.isidentifier():
return f'<{self.__class__.__name__}>'
Expand Down
2 changes: 1 addition & 1 deletion pcapkit/protocols/internet/hopopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class HOPOPT(Internet[Data_HOPOPT, Schema_HOPOPT],
#: DefaultDict[Enum_Option, str | tuple[OptionParser, OptionConstructor]]:
#: Option code to method mapping, c.f. :meth:`_read_hopopt_options` and/or
#: :meth:`_make_hopopt_options`. Method names are expected to be referred
#: to the class by ``_read_opt_${name}`` and/or ``_make_opt_${name}, and
#: to the class by ``_read_opt_${name}`` and/or ``_make_opt_${name}``, and
#: if such name not found, the value should then be a method that can parse
#: the option by itself.
__option__ = collections.defaultdict(
Expand Down
2 changes: 1 addition & 1 deletion pcapkit/protocols/internet/ipx.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def dst(self) -> 'str':
def read(self, length: 'Optional[int]' = None, **kwargs: 'Any') -> 'Data_IPX':
"""Read Internetwork Packet Exchange.
Args:
Args:
length: Length of packet data.
**kwargs: Arbitrary keyword arguments.
Expand Down

0 comments on commit 0079c3c

Please sign in to comment.