Skip to content

Commit

Permalink
Document NewTypes and ReaddirToken
Browse files Browse the repository at this point in the history
Sphinx autoclass is currently confused by NewTypes, so document those by
hand.

Also, Sphinx wants to document the NewTypes as coming from
pyfuse3._pyfuse3, and there doesn't seem to be a setting or rST directive
to convince it otherwise.  Work around this by mangling the types'
__module__ attributes from conf.py.
  • Loading branch information
bgilbert authored and Nikratio committed Dec 14, 2023
1 parent 9231528 commit 9cd9699
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rst/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

def setup(app):
# Mangle NewTypes re-exported from pyfuse3._pyfuse3 so they appear to
# come from their canonical location at the top of the package
import pyfuse3
for name in ('FileHandleT', 'FileNameT', 'FlagT', 'InodeT', 'ModeT',
'XAttrNameT'):
getattr(pyfuse3, name).__module__ = 'pyfuse3'


# -- Options for HTML output ---------------------------------------------------

Expand Down
35 changes: 35 additions & 0 deletions rst/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,37 @@

.. autoexception:: FUSEError

.. autoclass currently doesn't work for NewTypes
.. https://github.com/sphinx-doc/sphinx/issues/11552
.. class:: FileHandleT

A subclass of `int`, representing an integer file handle produced by a
`~Operations.create`, `~Operations.open`, or `~Operations.opendir` call.

.. class:: FileNameT

A subclass of `bytes`, representing a file name, with no embedded
zero-bytes (``\0``).

.. class:: FlagT

A subclass of `int`, representing flags modifying the behavior of an
operation.

.. class:: InodeT

A subclass of `int`, representing an inode number.

.. class:: ModeT

A subclass of `int`, representing a file mode.

.. class:: XAttrNameT

A subclass of `bytes`, representing an extended attribute name, with no
embedded zero-bytes (``\0``).

.. autoclass:: RequestContext

.. attribute:: pid
Expand Down Expand Up @@ -163,3 +194,7 @@
If this attribute is true, it signals the `Operations.setattr`
method that the `~EntryAttributes.st_size` field contains an
updated value.

.. autoclass:: ReaddirToken

An identifier for a particular `~Operations.readdir` invocation.

0 comments on commit 9cd9699

Please sign in to comment.