mirror of
https://github.com/ModOrganizer2/pystubs-generation.git
synced 2026-07-27 14:07:13 -07:00
Fix stubs generator for documentation.
This commit is contained in:
@@ -18,8 +18,7 @@ jobs:
|
||||
python-version: 3.12
|
||||
- uses: abatilo/actions-poetry@v2
|
||||
- name: Install
|
||||
run: |
|
||||
poetry install
|
||||
run: poetry install
|
||||
- name: Install libgl1
|
||||
run: sudo apt install -y libgl1 libegl1 libglib2.0-0 libxkbcommon0 libdbus-1-3
|
||||
- name: Copy stubs
|
||||
|
||||
@@ -109,7 +109,6 @@ import mobase
|
||||
import mobase.widgets
|
||||
```
|
||||
|
||||
|
||||
**Note:** Most classes in `mobase` cannot be instantiated, so this is mostly intended
|
||||
for MO2 developers.
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
sphinx-rtd-theme
|
||||
sphinx-autodoc-typehints
|
||||
sphinx-automodapi
|
||||
PyQt6
|
||||
@@ -64,10 +64,8 @@ These plugins (shall eventually) implement all the game specific features and fu
|
||||
able to add support for further games.
|
||||
The plugin is also responsible to help MO determine if (and where) the game is installed in the first place.
|
||||
Since supporting a game properly requires extensions in many places of the UI.
|
||||
To allow this without creating one huge plugin interface that involves every aspect of MO, game plugins
|
||||
expose a *feature list*.
|
||||
The list of possible features can be found in the "game_features" project and each feature can itself be
|
||||
considered a plugin interface.
|
||||
To allow this without creating one huge plugin interface that involves every aspect of MO,
|
||||
game plugins can register only the features they need to MO2 using :meth:`registerFeature<mobase.IGameFeatures.registerFeature>`
|
||||
|
||||
As an example for a game feature take BSA invalidation: If the game requires BSA invalidation it will implement
|
||||
this feature.
|
||||
|
||||
@@ -8,7 +8,7 @@ from pathlib import Path
|
||||
from typing import Callable
|
||||
|
||||
from .loader import load_mobase
|
||||
from .mtypes import Class, Constant, PyTyping
|
||||
from .mtypes import Class, Constant, Enum, Function, PyTyping
|
||||
from .parser import is_enum
|
||||
from .register import MobaseRegister
|
||||
from .utils import Settings, clean_class
|
||||
@@ -198,6 +198,21 @@ def main() -> None:
|
||||
# create directory if required
|
||||
output_folder.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# sort the stubs
|
||||
def _key_fn(o: Class | Constant | list[Function] | PyTyping) -> tuple[int, ...]:
|
||||
# order is PyTyping -> Constant -> Function -> Enum -> Top-Level Class -> Child Level Classes
|
||||
return (
|
||||
not isinstance(o, PyTyping),
|
||||
not isinstance(o, Constant),
|
||||
not isinstance(o, list),
|
||||
not isinstance(o, Enum),
|
||||
isinstance(o, Class) and len(o.all_bases),
|
||||
)
|
||||
|
||||
stub_objects = sorted(
|
||||
(register.get_object(n) for n, _o in objects), key=_key_fn
|
||||
)
|
||||
|
||||
# write everything
|
||||
with open(output_folder.joinpath("__init__.pyi"), "w") as output:
|
||||
writer = Writer(package=name, output=output, settings=settings)
|
||||
@@ -208,10 +223,7 @@ def main() -> None:
|
||||
|
||||
module_headers[name](writer)
|
||||
|
||||
for n, _o in objects:
|
||||
# Get the corresponding object:
|
||||
c = register.get_object(n)
|
||||
|
||||
for c in stub_objects:
|
||||
writer.print_object(c)
|
||||
|
||||
subprocess.run(
|
||||
|
||||
+1718
-1525
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,17 @@ class TaskDialog:
|
||||
Customizable choice dialog.
|
||||
"""
|
||||
|
||||
def __init__(self: TaskDialog, parent: PyQt6.QtWidgets.QWidget | None = None, title: str = '', main: str = '', content: str = '', details: str = '', icon: PyQt6.QtWidgets.QMessageBox.Icon = PyQt6.QtWidgets.QMessageBox.Icon.NoIcon, buttons: list[TaskDialogButton] = [], remember: Union[str, tuple[str, str]] = '') -> None:
|
||||
def __init__(
|
||||
self: TaskDialog,
|
||||
parent: PyQt6.QtWidgets.QWidget | None = None,
|
||||
title: str = "",
|
||||
main: str = "",
|
||||
content: str = "",
|
||||
details: str = "",
|
||||
icon: PyQt6.QtWidgets.QMessageBox.Icon = PyQt6.QtWidgets.QMessageBox.Icon.NoIcon,
|
||||
buttons: list[TaskDialogButton] = [],
|
||||
remember: Union[str, tuple[str, str]] = "",
|
||||
) -> None:
|
||||
"""
|
||||
Construct a new TaskDialog.
|
||||
|
||||
@@ -91,7 +101,7 @@ class TaskDialog:
|
||||
main: Main message of the dialog.
|
||||
"""
|
||||
...
|
||||
def setRemember(self: TaskDialog, action: str, file: str = '') -> TaskDialog:
|
||||
def setRemember(self: TaskDialog, action: str, file: str = "") -> TaskDialog:
|
||||
"""
|
||||
Configure the dialog to remember user-choice.
|
||||
"""
|
||||
@@ -113,7 +123,6 @@ class TaskDialog:
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
class TaskDialogButton:
|
||||
"""
|
||||
Special button to be used inside TaskDialog widgets.
|
||||
@@ -123,19 +132,21 @@ class TaskDialogButton:
|
||||
def button(self) -> PyQt6.QtWidgets.QMessageBox.StandardButton: ...
|
||||
@button.setter
|
||||
def button(self, arg0: PyQt6.QtWidgets.QMessageBox.StandardButton) -> None: ...
|
||||
|
||||
@property
|
||||
def description(self) -> str: ...
|
||||
@description.setter
|
||||
def description(self, arg0: str) -> None: ...
|
||||
|
||||
@property
|
||||
def text(self) -> str: ...
|
||||
@text.setter
|
||||
def text(self, arg0: str) -> None: ...
|
||||
|
||||
@overload
|
||||
def __init__(self: TaskDialogButton, text: str, description: str, button: PyQt6.QtWidgets.QMessageBox.StandardButton) -> None:
|
||||
def __init__(
|
||||
self: TaskDialogButton,
|
||||
text: str,
|
||||
description: str,
|
||||
button: PyQt6.QtWidgets.QMessageBox.StandardButton,
|
||||
) -> None:
|
||||
"""
|
||||
Create a TaskDialogButton.
|
||||
|
||||
@@ -146,7 +157,11 @@ class TaskDialogButton:
|
||||
"""
|
||||
...
|
||||
@overload
|
||||
def __init__(self: TaskDialogButton, text: str, button: PyQt6.QtWidgets.QMessageBox.StandardButton) -> None:
|
||||
def __init__(
|
||||
self: TaskDialogButton,
|
||||
text: str,
|
||||
button: PyQt6.QtWidgets.QMessageBox.StandardButton,
|
||||
) -> None:
|
||||
"""
|
||||
Create a TaskDialogButton without description.
|
||||
|
||||
@@ -155,5 +170,3 @@ class TaskDialogButton:
|
||||
button: Value returned by TaskDialog.exec() if this button is clicked.
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user