Skip to content

Commit 92ad66a

Browse files
authored
small docs update, still many work to do remain (#88)
Nothing fixed, nothing important added, just some additional documentation with the help of sphinx. Signed-off-by: Alexander Piskun <[email protected]>
1 parent bedbdd8 commit 92ad66a

File tree

8 files changed

+52
-7
lines changed

8 files changed

+52
-7
lines changed

docs/conf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@
2121
"sphinx_inline_tabs",
2222
"sphinx_issues",
2323
"sphinx_rtd_theme",
24+
"sphinxcontrib.autodoc_pydantic",
2425
]
2526

2627
intersphinx_mapping = {
2728
"python": ("https://docs.python.org/3", None),
29+
# "sqlalchemy": ("https://docs.sqlalchemy.org/en/20/", None),
30+
# "redis": ("https://redis-py.readthedocs.io/en/stable/", None),
2831
}
2932

33+
autodoc_pydantic_model_show_json = False
34+
3035
# General information about the project.
3136
project = "NcPyApi"
3237
copyright = str(now.year) + " Nextcloud GmbH" # noqa
@@ -48,7 +53,7 @@
4853
"display_version": True,
4954
}
5055

51-
# If true, `todos` produce output, else they produce nothing.
56+
# If true, `todos` produce output. Else they produce nothing.
5257
todo_include_todos = False
5358

5459
# The name of the Pygments (syntax highlighting) style to use.

docs/reference/ExApp.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,23 @@ Constants
1111

1212
.. autoclass:: LogLvl
1313
:members:
14+
15+
User Interface(UI)
16+
------------------
17+
18+
UI methods should be accessed with the help of :class:`~nc_py_api.nextcloud.NextcloudApp`
19+
20+
.. code-block:: python
21+
22+
# this is an example, in most cases you will get `NextcloudApp` class instance as input param.
23+
nc = NextcloudApp()
24+
nc.ui.files_dropdown_menu.register(...)
25+
26+
.. autoclass:: nc_py_api.ex_app.ui.ui.UiApi
27+
:members:
28+
29+
.. automodule:: nc_py_api.ex_app.ui.files
30+
:members:
31+
32+
.. autoclass:: nc_py_api.ex_app.ui.files._UiFilesActionsAPI
33+
:members:

docs/reference/Session.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ Session Structures
1515
Internal
1616
^^^^^^^^
1717

18-
Currently Session API is private, and not exposed.
18+
.. note:: The Session API is currently private and subject to change without deprecation.
1919

2020
.. autoclass:: NcSessionBasic
2121
:members:
22+
23+
.. autoclass:: NcSessionApp
24+
:members:
25+
:inherited-members:

nc_py_api/ex_app/defs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class LogLvl(enum.IntEnum):
1919

2020

2121
class ApiScope(enum.IntEnum):
22-
"""Default API scopes."""
22+
"""Default API scopes. Should be used as a parameter to the :py:meth:`~.NextcloudApp.scope_allowed` method."""
2323

2424
SYSTEM = 2
2525
"""Allows access to the System APIs."""

nc_py_api/ex_app/ui/files.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,33 @@ class UiActionFileInfo(BaseModel):
1616
"""File Information Nextcloud sends to the External Application."""
1717

1818
fileId: int
19+
"""FileID without Nextcloud instance ID"""
1920
name: str
21+
"""Name of the file/directory"""
2022
directory: str
23+
"""Directory relative to the user's home directory"""
2124
etag: str
2225
mime: str
2326
fileType: str
27+
"""**file** or **dir**"""
2428
size: int
29+
"""size of file/directory"""
2530
favorite: str
31+
"""**true** or **false**"""
2632
permissions: int
33+
"""Combination of :py:class:`~nc_py_api.files.FilePermissions` values"""
2734
mtime: int
35+
"""Last modified time"""
2836
userId: str
37+
"""The ID of the user performing the action."""
2938
shared: str
39+
"""**true** or **false**"""
3040

3141
def to_fs_node(self) -> FsNode:
3242
"""Returns created ``FsNode`` from the file info given.
3343
34-
.. note:: :py:class:FsNode.file_id in this case is ``without`` **instance_id**
35-
and equal to :py:class:FsNode.info.fileid.
44+
.. note:: :py:attr:`~nc_py_api.files.FsNode.file_id` in this case is ``without`` **instance_id**
45+
and equal to :py:attr:`~nc_py_api.files.FsNodeInfo.fileid`.
3646
"""
3747
user_path = os.path.join(self.directory, self.name).rstrip("/")
3848
is_dir = bool(self.fileType.lower() == "dir")
@@ -68,12 +78,15 @@ class UiFileActionHandlerInfo(BaseModel):
6878
"""Action information Nextcloud sends to the External Application."""
6979

7080
actionName: str
81+
"""Name of the action, useful when App registers multiple actions for one handler."""
7182
actionHandler: str
83+
"""Callback url, which was called with this information."""
7284
actionFile: UiActionFileInfo
85+
"""Information about the file on which the action run."""
7386

7487

7588
class _UiFilesActionsAPI:
76-
"""API for the drop-down menu in Nextcloud ``Files`` app."""
89+
"""API for the drop-down menu in Nextcloud **Files app**."""
7790

7891
def __init__(self, session: NcSessionApp):
7992
self._session = session

nc_py_api/ex_app/ui/ui.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class UiApi:
1111
"""Class that encapsulates all UI functionality."""
1212

1313
files_dropdown_menu: _UiFilesActionsAPI
14+
"""File dropdown menu API."""
1415

1516
def __init__(self, session: NcSessionApp):
1617
self.files_dropdown_menu = _UiFilesActionsAPI(session)

nc_py_api/nextcloud.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class NextcloudApp(_NextcloudBasic):
107107
appconfig_ex: AppConfigExAPI
108108
"""Nextcloud App Preferences API for ExApps"""
109109
ui: UiApi
110+
"""Nextcloud UI API for ExApps"""
110111
preferences_ex: PreferencesExAPI
111112
"""Nextcloud User Preferences API for ExApps"""
112113

@@ -142,7 +143,7 @@ def users_list(self) -> list[str]:
142143
def scope_allowed(self, scope: ApiScope) -> bool:
143144
"""Check if API scope is avalaible for application.
144145
145-
Useful for applications which declare ``Optional`` scopes, to check if they are allowed for them.
146+
Useful for applications that declare optional scopes to check if they are allowed.
146147
"""
147148
if self.check_capabilities("app_ecosystem_v2"):
148149
return False

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ dev = [
7171
"selenium",
7272
]
7373
docs = [
74+
"autodoc_pydantic>=2.0.1",
7475
"nc_py_api[app]",
7576
"sphinx>=6.2",
7677
"sphinx-copybutton",

0 commit comments

Comments
 (0)