Skip to content

Commit

Permalink
Manually document enums
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorflahardy committed Aug 7, 2022
1 parent 7c471d3 commit 43c0d3c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 40 deletions.
43 changes: 37 additions & 6 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,51 @@ Enums
Region
~~~~~~

.. autoenum:: Region
:members:
.. class:: Region

Represents an upload region.

.. attribute:: us_east_one

Represents the US East region.

Premium
~~~~~~~

.. autoenum:: Premium
:members:
.. class:: Premium
Represents the premium tiers of Tixte.

.. attribute:: free

The free tier. All default members have this tier.

.. attribute:: turbo

Turbo tier. All members with this tier have an increased upload limit.

.. attribute:: turbo_charged

Turbo charged tier. This is the highest tier. All members with this tier have an increased upload limit.


UploadPermissionLevel
~~~~~~~~~~~~~~~~~~~~~

.. autoenum:: UploadPermissionLevel
:members:
.. class:: UploadPermissionLevel
Represents an upload permission level. This level determines
which members can view an upload.

.. attribute:: viewer

A viewer of this upload.

.. attribute:: manager

A manager of this upload. Can manage viewers.

.. attribute:: owner

The owner of this upload. Can manage everything.

.. _tixte-api-utils:

Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
'attributetable',
'resourcelinks',
'nitpick_file_ignorer',
'enum_tools.autoenum',
]

autodoc_member_order = 'bysource'
Expand Down
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
'sphinxcontrib_trio==1.1.2',
'sphinxcontrib-websupport',
'typing-extensions',
'enum-tools[sphinx]',
],
'test': ['pytest', 'pytest-asyncio', 'pytest-cov', 'enum-tools[sphinx]'],
'test': [
'pytest',
'pytest-asyncio',
'pytest-cov',
],
'speed': [
'orjson',
],
Expand Down
38 changes: 7 additions & 31 deletions tixte/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,19 @@
from __future__ import annotations

import enum
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
enum_tools: Any


class Region(enum.Enum):
"""Represents an upload region."""

us_east_one = 'us-east-1' # doc: Represents the US East region.
us_east_one = 'us-east-1'


class Premium(enum.Enum):
"""Represents the premium tiers of Tixte."""

free = 0 # doc: The free tier. All default members have this tier.
turbo = 1 # doc: Turbo tier. All members with this tier have an increased upload limit.
turbo_charged = (
2 # doc: Turbo charged tier. This is the highest tier. All members with this tier have an increased upload limit.
)
free = 0
turbo = 1
turbo_charged = 2


class UploadPermissionLevel(enum.Enum):
"""Represents an upload permission level. This level determines
which members can view an upload.
"""

viewer = 1 # doc: A viewer of this upload.
manager = 2 # doc: A manager of this upload. Can manage viewers.
owner = 3 # doc: The owner of this upload. Can manage everything.


try:
import enum_tools.documentation # pyright: ignore[reportMissingImports]

enum_tools.documentation.document_enum(Region)
enum_tools.documentation.document_enum(Premium)
enum_tools.documentation.document_enum(UploadPermissionLevel)
except ImportError:
pass
viewer = 1
manager = 2
owner = 3

0 comments on commit 43c0d3c

Please sign in to comment.