mirror of
https://github.com/ModOrganizer2/pystubs-generation.git
synced 2026-07-27 14:07:13 -07:00
Compare commits
31
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fe9b1d569 | ||
|
|
dd80b67a0a | ||
|
|
8789b59f23 | ||
|
|
72c652daaa | ||
|
|
80a365f19a | ||
|
|
1b8d6840e2 | ||
|
|
d7c1ecd6f2 | ||
|
|
6a76dda9d7 | ||
|
|
0c807ad974 | ||
|
|
a3542ca1c4 | ||
|
|
d6760273a2 | ||
|
|
ece93e7cb3 | ||
|
|
4fa50f89a4 | ||
|
|
962a3c2c1f | ||
|
|
7c2581eb0c | ||
|
|
336d80a5c6 | ||
|
|
a1f5ef3a45 | ||
|
|
be6a6761f7 | ||
|
|
52f835dc75 | ||
|
|
9ee5222bbc | ||
|
|
4655e1f3eb | ||
|
|
c4a6e2266d | ||
|
|
966a84a59a | ||
|
|
3a5c16af21 | ||
|
|
3eb1daa053 | ||
|
|
0eca0f7644 | ||
|
|
7467a2b11c | ||
|
|
eb420fcd79 | ||
|
|
156b827389 | ||
|
|
104e8612d8 | ||
|
|
4f24d363ec |
@@ -1,36 +0,0 @@
|
|||||||
name: Build Documentation
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
# Standard drop-in approach that should work for most people.
|
|
||||||
- uses: ammaraskar/sphinx-action@master
|
|
||||||
env:
|
|
||||||
PYTHONPATH: .
|
|
||||||
with:
|
|
||||||
pre-build-command: "apt-get update -y && apt-get install -y libgl1-mesa-glx && cp stubs/2.4.0/mobase.pyi docs/mobase.py"
|
|
||||||
docs-folder: "docs/"
|
|
||||||
|
|
||||||
- name: Install SSH Client 🔑
|
|
||||||
uses: webfactory/ssh-agent@v0.4.1
|
|
||||||
with:
|
|
||||||
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
|
|
||||||
|
|
||||||
- name: Deploy 🚀
|
|
||||||
uses: JamesIves/github-pages-deploy-action@3.7.1
|
|
||||||
with:
|
|
||||||
SSH: true
|
|
||||||
REPOSITORY_NAME: ModOrganizer2/python-plugins-doc
|
|
||||||
BRANCH: master
|
|
||||||
FOLDER: docs/build/html
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
name: Build Documentation
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: 3.12
|
||||||
|
- uses: abatilo/actions-poetry@v2
|
||||||
|
- name: Install
|
||||||
|
run: poetry install
|
||||||
|
- name: Install libgl1
|
||||||
|
run: sudo apt install -y libgl1 libegl1 libglib2.0-0 libxkbcommon0 libdbus-1-3
|
||||||
|
- name: Copy stubs
|
||||||
|
run: |
|
||||||
|
mkdir -p docs/src
|
||||||
|
cp -r stubs/2.5.2/mobase-stubs docs/src/mobase
|
||||||
|
- name: Build
|
||||||
|
run: poetry run sphinx-build -b html docs/source docs/build
|
||||||
|
env:
|
||||||
|
PYTHONPATH: docs
|
||||||
|
- if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
|
||||||
|
name: Deploy Documentation
|
||||||
|
uses: JamesIves/github-pages-deploy-action@v4
|
||||||
|
with:
|
||||||
|
ssh-key: ${{ secrets.DEPLOY_KEY }}
|
||||||
|
repository-name: ModOrganizer2/python-plugins-doc
|
||||||
|
branch: master
|
||||||
|
folder: docs/build
|
||||||
@@ -5,20 +5,16 @@ on: [push, pull_request]
|
|||||||
jobs:
|
jobs:
|
||||||
checks:
|
checks:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
max-parallel: 4
|
|
||||||
matrix:
|
|
||||||
python-version: [3.8]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: 3.12
|
||||||
- name: Install dependencies
|
- uses: abatilo/actions-poetry@v2
|
||||||
run: |
|
- name: Install
|
||||||
python -m pip install --upgrade pip
|
run: |
|
||||||
pip install tox
|
poetry install
|
||||||
- name: Test with tox
|
- name: Lint
|
||||||
run: tox -e py38-lint
|
run: |
|
||||||
|
poetry run poe lint
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
name: Check Documentation
|
|
||||||
|
|
||||||
on: [pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
# Standard drop-in approach that should work for most people.
|
|
||||||
- uses: ammaraskar/sphinx-action@master
|
|
||||||
env:
|
|
||||||
PYTHONPATH: .
|
|
||||||
with:
|
|
||||||
pre-build-command: "apt-get update -y && apt-get install -y libgl1-mesa-glx && cp stubs/2.4.0/mobase.pyi docs/mobase.py"
|
|
||||||
docs-folder: "docs/"
|
|
||||||
@@ -1,41 +1,57 @@
|
|||||||
# This workflows will upload a Python Package using Twine when a release is created
|
# This workflows will upload a Python Package using Twine when a release is created
|
||||||
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
|
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
|
||||||
|
|
||||||
name: Upload Python Package
|
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags: ["*.dev[0-9]+"]
|
tags: ["*"]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
build:
|
||||||
|
name: Build distribution 📦
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Replace string
|
||||||
|
uses: frabert/replace-string-action@v1.1
|
||||||
|
id: version
|
||||||
|
with:
|
||||||
|
string: ${{ github.ref_name }}
|
||||||
|
pattern: "v?([0-9][.][0-9][.][0-9]).*"
|
||||||
|
replace-with: "$1"
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: 3.12
|
||||||
|
- uses: abatilo/actions-poetry@v2
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cd stubs/setup
|
||||||
|
mkdir mobase-stubs
|
||||||
|
cp -r ../${{ steps.version.outputs.replaced }}/mobase-stubs/* mobase-stubs/
|
||||||
|
sed -i 's/__version__ = ".*"/__version__ = "${{ github.ref_name }}"/' mobase-stubs/__init__.pyi
|
||||||
|
TAG=${{ github.ref_name }}
|
||||||
|
poetry version ${TAG#v}
|
||||||
|
poetry build
|
||||||
|
- name: Store the distribution packages
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: python-package-distributions
|
||||||
|
path: stubs/setup/dist/
|
||||||
|
|
||||||
|
publish-to-pypi:
|
||||||
|
name: Publish Python 🐍 distribution 📦 to PyPI
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Download all the dists
|
||||||
- name: Replace string
|
uses: actions/download-artifact@v3
|
||||||
uses: frabert/replace-string-action@v1.1
|
with:
|
||||||
id: version
|
name: python-package-distributions
|
||||||
with:
|
path: dist/
|
||||||
string: ${{ github.ref_name }}
|
- name: Publish distribution 📦 to PyPI
|
||||||
pattern: "v?([0-9][.][0-9][.][0-9]).*"
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
replace-with: "$1"
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: '3.10'
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install setuptools wheel twine
|
|
||||||
- name: Build and publish
|
|
||||||
env:
|
|
||||||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
|
||||||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
|
||||||
run: |
|
|
||||||
cd stubs/setup
|
|
||||||
cp ../${{ steps.version.outputs.replaced }}/mobase.pyi mobase-stubs/__init__.pyi
|
|
||||||
sed -i 's/__version__ = ".*"/__version__ = "${{ github.ref_name }}"/' mobase-stubs/__init__.pyi
|
|
||||||
python setup.py sdist bdist_wheel
|
|
||||||
twine upload dist/*
|
|
||||||
|
|||||||
+2
-1
@@ -2,9 +2,10 @@
|
|||||||
.mypy_cache
|
.mypy_cache
|
||||||
__pycache__
|
__pycache__
|
||||||
.vscode
|
.vscode
|
||||||
|
**/*.egg-info
|
||||||
|
|
||||||
# The 'bin/' directory:
|
# The 'bin/' directory:
|
||||||
bin
|
bin
|
||||||
docs/build
|
docs/build
|
||||||
docs/mobase.py
|
docs/mobase.py
|
||||||
docs/source/api
|
docs/source/api
|
||||||
|
|||||||
@@ -16,23 +16,12 @@ MO2.
|
|||||||
You can install stubs for a specific version of MO2:
|
You can install stubs for a specific version of MO2:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install mobase-stubs==2.3.2.*
|
pip install mobase-stubs==2.5.*
|
||||||
```
|
|
||||||
|
|
||||||
If you want development stubs, you can install them this way:
|
|
||||||
```bash
|
|
||||||
# Clone this repository:
|
|
||||||
git clone https://github.com/ModOrganizer2/pystubs-generation.git
|
|
||||||
|
|
||||||
# Install the stubs:
|
|
||||||
cd pystubs-generation/stubs/setup
|
|
||||||
pip install .
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Some words of warning:
|
Some words of warning:
|
||||||
|
|
||||||
- The stubs are as correct as possible, but some errors are expected.
|
- The stubs are as correct as possible, but some errors are expected.
|
||||||
- If you see a `InterfaceNotImplemented` class anywhere in the stubs, it means that
|
|
||||||
a proper interface is currently not available.
|
|
||||||
- Some classes are said (in the stubs) to inherit `QWidget` or `QObject`. This is true
|
- Some classes are said (in the stubs) to inherit `QWidget` or `QObject`. This is true
|
||||||
on the C++ side but NOT on the python side. The inheritance is only added to help with
|
on the C++ side but NOT on the python side. The inheritance is only added to help with
|
||||||
auto-completion since these classes also override `__getattr__` to dispatch to the
|
auto-completion since these classes also override `__getattr__` to dispatch to the
|
||||||
@@ -44,35 +33,39 @@ Some words of warning:
|
|||||||
|
|
||||||
The stubs are generated using python by parsing the `mobase` module.
|
The stubs are generated using python by parsing the `mobase` module.
|
||||||
You need the version of python that matches your current MO2 installation: e.g., if you
|
You need the version of python that matches your current MO2 installation: e.g., if you
|
||||||
have a `python38.dll` in your MO2 installation path, then you need **Python 3.8**.
|
have a `python310.dll` in your MO2 installation path, then you need **Python 3.10**.
|
||||||
|
|
||||||
To generate the stubs, you can run:
|
To generate the stubs, you can run:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
# Change the output folder to whatever you want:
|
# install the package
|
||||||
python main.py -c configs\config-2.4.yml ${MO2_INSTALL_PATH}
|
poetry install
|
||||||
|
|
||||||
|
# change the output folder to whatever you want
|
||||||
|
mo2-stubs-generator -c configs/config-2.4.yml -o mobase-stubs ${MO2_INSTALL_PATH}
|
||||||
```
|
```
|
||||||
|
|
||||||
Where `${MO2_INSTALL_PATH}` is the path to your MO2 installation (the one containing `ModOrganizer.exe`).
|
Where `${MO2_INSTALL_PATH}` is the path to your MO2 installation (the one
|
||||||
|
containing `ModOrganizer.exe`).
|
||||||
|
|
||||||
The stubs are generated under `stubs/setup/mobase-stubs/__init__.pyi`, you
|
The stubs are generated under `stubs/setup/mobase-stubs` by default, you
|
||||||
can change the output file by using the `-o` option
|
can change the output file by using the `-o` option.
|
||||||
The latest stubs are kept under `stubs/setup/mobase-stubs/__init__.pyi`,
|
The stubs under `stubs/setup/mobase-stubs` should not be committed as these are
|
||||||
and when a new version is released, the stubs are backed-up under
|
generated from the version stubs under `stubs/${VERSION}/mobase-stubs`.
|
||||||
`stubs/x.y.z/mobase.pyi`.
|
|
||||||
|
|
||||||
A few options are available for `main.py`:
|
A few options are available for `mo2-stubs-generator`:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
usage: Stubs generator for the MO2 python interface [-h] [-o OUTPUT] [-v] [-c CONFIG] INSTALL_DIR
|
$ mo2-stubs-generator --help
|
||||||
|
usage: stubs generator for the MO2 python interface [-h] [-o OUTPUT] [-v] [-c CONFIG] INSTALL_DIR
|
||||||
|
|
||||||
positional arguments:
|
positional arguments:
|
||||||
INSTALL_DIR installation directory of Mod Organizer 2
|
INSTALL_DIR installation directory of Mod Organizer 2
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-o OUTPUT, --output OUTPUT
|
-o OUTPUT, --output OUTPUT
|
||||||
output file (default stubs/setup/mobase-stubs/__init__.pyi)
|
output folder (default stubs/setup/mobase-stubs)
|
||||||
-v, --verbose verbose mode (all logs go to stderr)
|
-v, --verbose verbose mode (all logs go to stderr)
|
||||||
-c CONFIG, --config CONFIG
|
-c CONFIG, --config CONFIG
|
||||||
configuration file
|
configuration file
|
||||||
@@ -81,19 +74,7 @@ optional arguments:
|
|||||||
The stubs generator will try hard to find a valid stubs for all classes
|
The stubs generator will try hard to find a valid stubs for all classes
|
||||||
and methods of `mobase`.
|
and methods of `mobase`.
|
||||||
A lot of information is available through the `-v` options. Without it,
|
A lot of information is available through the `-v` options. Without it,
|
||||||
only conversions or fixes
|
only conversions or fixes considered "strange" will be shown.
|
||||||
considered "strange" will be shown.
|
|
||||||
For instance, here is the output with the current `config-2.4.yml` file:
|
|
||||||
|
|
||||||
```
|
|
||||||
WARNING: Replacing IOrganizer::FileInfo with FileInfo.
|
|
||||||
WARNING: Replacing IOrganizer::FileInfo with FileInfo.
|
|
||||||
WARNING: Replacing IPluginInstaller::EInstallResult with InstallResult.
|
|
||||||
WARNING: Replacing IPluginInstaller::EInstallResult with InstallResult.
|
|
||||||
```
|
|
||||||
|
|
||||||
As you can see, only a few types were manually fixed (specified in
|
|
||||||
`config-2.4.yml`).
|
|
||||||
|
|
||||||
## Configuration file
|
## Configuration file
|
||||||
|
|
||||||
@@ -102,20 +83,36 @@ deduced by `main` (or are too complex to deduce), and the documentation for ever
|
|||||||
|
|
||||||
## Uploading the stubs to pypi
|
## Uploading the stubs to pypi
|
||||||
|
|
||||||
The upload of the stubs to https://pypi.org/project/mobase-stubs/ should be
|
The upload of the stubs to [https://pypi.org/project/mobase-stubs/](https://pypi.org/project/mobase-stubs/)
|
||||||
done automatically when a new Github release is made.
|
should be done automatically when a new Github tag is pushed.
|
||||||
|
|
||||||
## Extras — Starts a python interpreter with `mobase`
|
## Extras — Using `mobase` in a Python interpreter
|
||||||
|
|
||||||
It is possible to start a (i)python interpret with `mobase` imported by running:
|
It is possible to start a (i)python interpreter with `mobase` imported by running
|
||||||
|
|
||||||
```
|
```bash
|
||||||
python -im generator.loader ${MO2_INSTALL_PATH}
|
python -i -m mo2.stubs.generator.loader ${MO2_INSTALL_PATH}
|
||||||
```
|
```
|
||||||
|
|
||||||
This has no real usage except for MO2 developers since most classes from the `mobase` module cannot be instantiated.
|
You can also import `mobase` in your code using the following (after installing
|
||||||
|
this package):
|
||||||
|
|
||||||
# License
|
```python
|
||||||
|
from mo2.stubs.generator import load_mobase
|
||||||
|
|
||||||
|
mobase = load_mobase(MO2_INSTALL_PATH)
|
||||||
|
|
||||||
|
# the above will probably not give you type-completion in your IDE or typing, so
|
||||||
|
# you can use the following (if the stubs are installed)
|
||||||
|
load_mobase(MO2_INSTALL_PATH)
|
||||||
|
import mobase
|
||||||
|
import mobase.widgets
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Most classes in `mobase` cannot be instantiated, so this is mostly intended
|
||||||
|
for MO2 developers.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
|||||||
+385
-68
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
|||||||
# Minimal makefile for Sphinx documentation
|
|
||||||
#
|
|
||||||
|
|
||||||
# You can set these variables from the command line, and also
|
|
||||||
# from the environment for the first two.
|
|
||||||
SPHINXOPTS ?=
|
|
||||||
SPHINXBUILD ?= sphinx-build
|
|
||||||
SOURCEDIR = source
|
|
||||||
BUILDDIR = build
|
|
||||||
|
|
||||||
# Put it first so that "make" without argument is like "make help".
|
|
||||||
help:
|
|
||||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
||||||
|
|
||||||
.PHONY: help Makefile
|
|
||||||
|
|
||||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
||||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
||||||
%: Makefile
|
|
||||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
@ECHO OFF
|
|
||||||
|
|
||||||
pushd %~dp0
|
|
||||||
|
|
||||||
REM Command file for Sphinx documentation
|
|
||||||
|
|
||||||
if "%SPHINXBUILD%" == "" (
|
|
||||||
set SPHINXBUILD=sphinx-build
|
|
||||||
)
|
|
||||||
set SOURCEDIR=source
|
|
||||||
set BUILDDIR=build
|
|
||||||
|
|
||||||
if "%1" == "" goto help
|
|
||||||
|
|
||||||
%SPHINXBUILD% >NUL 2>NUL
|
|
||||||
if errorlevel 9009 (
|
|
||||||
echo.
|
|
||||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
||||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
||||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
||||||
echo.may add the Sphinx directory to PATH.
|
|
||||||
echo.
|
|
||||||
echo.If you don't have Sphinx installed, grab it from
|
|
||||||
echo.http://sphinx-doc.org/
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
||||||
goto end
|
|
||||||
|
|
||||||
:help
|
|
||||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
||||||
|
|
||||||
:end
|
|
||||||
popd
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
sphinx-rtd-theme
|
|
||||||
sphinx-autodoc-typehints
|
|
||||||
sphinx-automodapi
|
|
||||||
PyQt5
|
|
||||||
+7
-11
@@ -10,21 +10,13 @@
|
|||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
#
|
#
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
sys.path.insert(0, os.path.abspath("../../stubs/2.4.0/"))
|
|
||||||
|
|
||||||
|
|
||||||
# -- Project information -----------------------------------------------------
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
project = "MO2 Python Plugin API"
|
project = "MO2 Python Plugin API"
|
||||||
copyright = "2020, Holt59"
|
copyright = "2023, Holt59"
|
||||||
author = "Holt59"
|
author = "Holt59"
|
||||||
|
|
||||||
# The full version, including alpha/beta/rc tags
|
|
||||||
release = "2.3rc1"
|
|
||||||
|
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
|
|
||||||
@@ -35,8 +27,9 @@ extensions = [
|
|||||||
"sphinx.ext.autodoc",
|
"sphinx.ext.autodoc",
|
||||||
"sphinx_autodoc_typehints",
|
"sphinx_autodoc_typehints",
|
||||||
"sphinx.ext.napoleon",
|
"sphinx.ext.napoleon",
|
||||||
|
"autoapi.extension",
|
||||||
# "sphinx.ext.autosummary",
|
# "sphinx.ext.autosummary",
|
||||||
"sphinx_automodapi.automodapi",
|
# "sphinx_automodapi.automodapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
@@ -47,6 +40,9 @@ templates_path = ["_templates"]
|
|||||||
# This pattern also affects html_static_path and html_extra_path.
|
# This pattern also affects html_static_path and html_extra_path.
|
||||||
exclude_patterns = []
|
exclude_patterns = []
|
||||||
|
|
||||||
|
autoapi_dirs = ["../src"]
|
||||||
|
autoapi_member_order = "groupwise"
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output -------------------------------------------------
|
# -- Options for HTML output -------------------------------------------------
|
||||||
|
|
||||||
@@ -69,5 +65,5 @@ html_favicon = "mo2.ico"
|
|||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
html_static_path = ["_static"]
|
# html_static_path = ["_static"]
|
||||||
html_extra_path = [".nojekyll"]
|
html_extra_path = [".nojekyll"]
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ This documentation is dedicated to writting MO2 **Python** plugins.
|
|||||||
plugin-types
|
plugin-types
|
||||||
writing-plugins
|
writing-plugins
|
||||||
faq
|
faq
|
||||||
mobase
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
``mobase`` API
|
|
||||||
==============
|
|
||||||
|
|
||||||
.. currentmodule:: mobase
|
|
||||||
|
|
||||||
.. automodapi:: mobase
|
|
||||||
:no-inheritance-diagram:
|
|
||||||
:no-heading:
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 4
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
mobase
|
|
||||||
======
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 4
|
|
||||||
|
|
||||||
mobase
|
|
||||||
@@ -64,10 +64,8 @@ These plugins (shall eventually) implement all the game specific features and fu
|
|||||||
able to add support for further games.
|
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.
|
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.
|
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
|
To allow this without creating one huge plugin interface that involves every aspect of MO,
|
||||||
expose a *feature list*.
|
game plugins can register only the features they need to MO2 using :meth:`registerFeature<mobase.IGameFeatures.registerFeature>`
|
||||||
The list of possible features can be found in the "game_features" project and each feature can itself be
|
|
||||||
considered a plugin interface.
|
|
||||||
|
|
||||||
As an example for a game feature take BSA invalidation: If the game requires BSA invalidation it will implement
|
As an example for a game feature take BSA invalidation: If the game requires BSA invalidation it will implement
|
||||||
this feature.
|
this feature.
|
||||||
@@ -147,4 +145,4 @@ File Mappings
|
|||||||
|
|
||||||
This interface allows plugins to add virtual file (or directory) links to the virtual file system in addition to the
|
This interface allows plugins to add virtual file (or directory) links to the virtual file system in addition to the
|
||||||
mod files.
|
mod files.
|
||||||
Profile-local save games, ini-files and load-orders are all implemented this way in MO2.
|
Profile-local save games, ini-files and load-orders are all implemented this way in MO2.
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import logging
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import cast
|
|
||||||
|
|
||||||
import black
|
|
||||||
import isort
|
|
||||||
|
|
||||||
from generator import LOGGER
|
|
||||||
from generator.loader import load_mobase
|
|
||||||
from generator.mtypes import Class, Function, PyType
|
|
||||||
from generator.parser import is_enum
|
|
||||||
from generator.register import MOBASE_REGISTER
|
|
||||||
from generator.utils import Settings, clean_class
|
|
||||||
from generator.writer import Writer
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser("Stubs generator for the MO2 python interface")
|
|
||||||
parser.add_argument(
|
|
||||||
"install_dir",
|
|
||||||
metavar="INSTALL_DIR",
|
|
||||||
type=Path,
|
|
||||||
default=None,
|
|
||||||
help="installation directory of Mod Organizer 2",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-o",
|
|
||||||
"--output",
|
|
||||||
type=Path,
|
|
||||||
default="stubs/setup/mobase-stubs/__init__.pyi",
|
|
||||||
help="output file (default stubs/setup/mobase-stubs/__init__.pyi)",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-v", "--verbose", action="store_true", help="verbose mode (all logs go to stderr)"
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-c",
|
|
||||||
"--config",
|
|
||||||
type=argparse.FileType("r"),
|
|
||||||
default=None,
|
|
||||||
help="configuration file",
|
|
||||||
)
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
logging.basicConfig()
|
|
||||||
LOGGER.setLevel(logging.WARNING)
|
|
||||||
|
|
||||||
if args.verbose:
|
|
||||||
LOGGER.setLevel(logging.INFO)
|
|
||||||
|
|
||||||
output_path = cast(Path, args.output)
|
|
||||||
|
|
||||||
# Load settings from the configuration:
|
|
||||||
settings: Settings = Settings(register=MOBASE_REGISTER)
|
|
||||||
if args.config is not None:
|
|
||||||
settings = Settings(MOBASE_REGISTER, args.config)
|
|
||||||
|
|
||||||
# Parse mobase:
|
|
||||||
|
|
||||||
# Load mobase (cannot simply do "import mobase"):
|
|
||||||
mobase = load_mobase(Path(args.install_dir))
|
|
||||||
|
|
||||||
# List of objects:
|
|
||||||
objects = []
|
|
||||||
|
|
||||||
for name in dir(mobase):
|
|
||||||
if name.startswith("__"):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if name in settings.ignore_names:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# we do not want the real MoVariant
|
|
||||||
if name == "MoVariant":
|
|
||||||
continue
|
|
||||||
|
|
||||||
# ignore the private module
|
|
||||||
if name == "private":
|
|
||||||
continue
|
|
||||||
|
|
||||||
# for now, ignore this since it is a submodule and we
|
|
||||||
# not handle them
|
|
||||||
if name == "widgets":
|
|
||||||
continue
|
|
||||||
|
|
||||||
# IPlugin is not the real object
|
|
||||||
if name == "IPlugin":
|
|
||||||
continue
|
|
||||||
|
|
||||||
objects.append((name, getattr(mobase, name)))
|
|
||||||
|
|
||||||
# enum first, and then alphabetical, should be fine with the __future__ import
|
|
||||||
objects = sorted(
|
|
||||||
objects, key=lambda e: (isinstance(e[1], type), not is_enum(e[1]), e[0])
|
|
||||||
)
|
|
||||||
|
|
||||||
for n, o in objects:
|
|
||||||
MOBASE_REGISTER.add_object(n, o)
|
|
||||||
|
|
||||||
# Process everything:
|
|
||||||
for n, o in objects:
|
|
||||||
|
|
||||||
# Create the corresponding object:
|
|
||||||
c = MOBASE_REGISTER.make_object(n, o)
|
|
||||||
|
|
||||||
if isinstance(c, Class):
|
|
||||||
|
|
||||||
# Clean the class (e.g., remove duplicates methods due to wrappers):
|
|
||||||
clean_class(c, settings)
|
|
||||||
|
|
||||||
# Path the class using the configuration:
|
|
||||||
settings.patch_class(c)
|
|
||||||
|
|
||||||
elif isinstance(c, list) and isinstance(c[0], Function):
|
|
||||||
settings.patch_functions(c)
|
|
||||||
|
|
||||||
else:
|
|
||||||
LOGGER.critical(
|
|
||||||
"Cannot generated stubs for {}, unsupported object type.".format(n)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Write everything:
|
|
||||||
with open(args.output, "w") as output:
|
|
||||||
|
|
||||||
writer = Writer(output, settings)
|
|
||||||
|
|
||||||
# the __future__ import must be at the beginning
|
|
||||||
writer.print_imports([("__future__", ["annotations"])])
|
|
||||||
writer.print_version(settings.mobase["__version__"]) # type: ignore
|
|
||||||
writer.print_imports(
|
|
||||||
[
|
|
||||||
"abc",
|
|
||||||
("enum", ["Enum"]),
|
|
||||||
("pathlib", ["Path"]),
|
|
||||||
(
|
|
||||||
"typing",
|
|
||||||
[
|
|
||||||
"Dict",
|
|
||||||
"Iterator",
|
|
||||||
"List",
|
|
||||||
"Tuple",
|
|
||||||
"Union",
|
|
||||||
"Any",
|
|
||||||
"Optional",
|
|
||||||
"Callable",
|
|
||||||
"overload",
|
|
||||||
"Sequence",
|
|
||||||
"Set",
|
|
||||||
"TypeVar",
|
|
||||||
"Type",
|
|
||||||
],
|
|
||||||
),
|
|
||||||
"PyQt6.QtCore",
|
|
||||||
"PyQt6.QtGui",
|
|
||||||
"PyQt6.QtWidgets",
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Needs to define the MVariant and GameFeatureType type:
|
|
||||||
writer._print(f"MoVariant = {PyType.MO_VARIANT}")
|
|
||||||
writer._print(f"FileWrapper = {PyType.FILE_WRAPPER}")
|
|
||||||
writer._print(f"DirectoryWrapper = {PyType.DIRECTORY_WRAPPER}")
|
|
||||||
writer._print('GameFeatureType = TypeVar("GameFeatureType")')
|
|
||||||
writer._print()
|
|
||||||
|
|
||||||
# This is a class to represent interface not implemented:
|
|
||||||
writer.print_class(Class("InterfaceNotImplemented", [], []))
|
|
||||||
writer._print()
|
|
||||||
|
|
||||||
for n, o in objects:
|
|
||||||
|
|
||||||
# Get the corresponding object:
|
|
||||||
c = MOBASE_REGISTER.get_object(n)
|
|
||||||
|
|
||||||
if isinstance(c, Class):
|
|
||||||
writer.print_class(c)
|
|
||||||
|
|
||||||
elif isinstance(c, list) and isinstance(c[0], Function):
|
|
||||||
for fn in c:
|
|
||||||
writer.print_function(fn)
|
|
||||||
|
|
||||||
black.format_file_in_place(
|
|
||||||
output_path,
|
|
||||||
fast=False,
|
|
||||||
mode=black.Mode(is_pyi=args.output.name.endswith("pyi")),
|
|
||||||
write_back=black.WriteBack.YES,
|
|
||||||
)
|
|
||||||
isort.api.sort_file(output_path)
|
|
||||||
Generated
+818
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user