Skip to content

Commit

Permalink
readthedocs integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalmat committed Apr 24, 2024
1 parent e75f918 commit f79501b
Show file tree
Hide file tree
Showing 7 changed files with 1,297 additions and 81 deletions.
35 changes: 35 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: requirements.txt
14 changes: 0 additions & 14 deletions DISPLAY_MANAGER_LICENSE.txt

This file was deleted.

134 changes: 68 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# PyMonCtl
[![Type Checking](https://github.com/Kalmat/PyMonCtl/actions/workflows/type-checking.yml/badge.svg)](https://github.com/Kalmat/PyMonCtl/actions/workflows/type-checking.yml)
[![PyPI version](https://badge.fury.io/py/PyMonCtl.svg)](https://badge.fury.io/py/PyMonCtl)
[![Documentation Status](https://readthedocs.org/projects/pymonctl/badge/?version=latest)](https://pymonctl.readthedocs.io/en/latest/?badge=latest)


Cross-Platform module which provides a set of features to get info on and control monitors.

Expand All @@ -19,20 +21,20 @@ Additional tools/extensions/APIs used:

Functions to get monitor instances, get info and arrange monitors plugged to the system.

| General functions: |
|:-----------------------:|
| getAllMonitors |
| getAllMonitorsDict |
| getMonitorsCount |
| getPrimary |
| findMonitorsAtPoint |
| findMonitorsAtPointInfo |
| findMonitorWithName |
| findMonitorWithNameInfo |
| saveSetup |
| restoreSetup |
| arrangeMonitors |
| getMousePos |
| General functions: |
|:----------------------------------------------------------------:|
| [getAllMonitors](docstrings.md#getallmonitors) |
| [getAllMonitorsDict](docstrings.md#getallmonitorsdict) |
| [getMonitorsCount](docstrings.md#getmonitorscount) |
| [getPrimary](docstrings.md#getprimary) |
| [findMonitorsAtPoint](docstrings.md#findmonitorsatpoint) |
| [findMonitorsAtPointInfo](docstrings.md#findmonitorsatpointinfo) |
| [findMonitorWithName](docstrings.md#findmonitorwithname) |
| [findMonitorWithNameInfo](docstrings.md#findmonitorwithnameinfo) |
| [saveSetup](docstrings.md#savesetup) |
| [restoreSetup](docstrings.md#restoresetup) |
| [arrangeMonitors](docstrings.md#arrangemonitors) |
| [getMousePos](docstrings.md#getmousepos) |


## Monitor Class
Expand All @@ -47,40 +49,40 @@ can directly be used to invoke `findMonitorWithName(name)` function.
To instantiate it, you need to pass the monitor handle (OS-dependent). It can raise ValueError exception in case
the provided handle is not valid.

| Methods | Windows | Linux | macOS |
|:--------------:|:-------:|:-----:|:-----:|
| size | X | X | X |
| workarea | X | X | X |
| position | X | X | X |
| setPosition | X | X | X |
| box | X | X | X |
| rect | X | X | X |
| frequency | X | X | X |
| colordepth | X | X | X |
| dpi | X | X | X |
| scale | X | X | X |
| setScale | X | X | X |
| orientation | X | X | X |
| setOrientation | X | X | X (1) |
| brightness | X (2) | X | X (1) |
| setBrightness | X (2) | X | X (1) |
| contrast | X (2) | X (3) | X (3) |
| setContrast | X (2) | X (3) | X (3) |
| mode | X | X | X |
| setMode | X | X | X |
| defaultMode | X | X | X |
| setDefaultMode | X | X | X |
| allModes | X | X | X |
| setPrimary | X | X | X |
| isPrimary | X | X | X |
| turnOn | X (4) | X | X (4) |
| turnOff | X (4) | X | X (4) |
| isOn | X (2) | X | X |
| suspend | X (4) | X (4) | X (4) |
| isSuspended | X (2) | X | X |
| attach | X | X | |
| detach | X | X | |
| isAttached | X | X | X |
| Methods | Windows | Linux | macOS |
|:----------------------------------------------:|:-------:|:-----:|:-----:|
| [size](docstrings.md#size) | X | X | X |
| [workarea](docstrings.md#workarea) | X | X | X |
| [position](docstrings.md#position) | X | X | X |
| [setPosition](docstrings.md#setposition) | X | X | X |
| [box](docstrings.md#box) | X | X | X |
| [rect](docstrings.md#rect) | X | X | X |
| [frequency](docstrings.md#frequency) | X | X | X |
| [colordepth](docstrings.md#colordepth) | X | X | X |
| [dpi](docstrings.md#dpi) | X | X | X |
| [scale](docstrings.md#scale) | X | X | X |
| [setScale](docstrings.md#setscale) | X | X | X |
| [orientation](docstrings.md#orientation) | X | X | X |
| [setOrientation](docstrings.md#setorientation) | X | X | X (1) |
| [brightness](docstrings.md#brightness) | X (2) | X | X |
| [setBrightness](docstrings.md#setbrightness) | X (2) | X | X |
| [contrast](docstrings.md#contrast) | X (2) | X (3) | X (3) |
| [setContrast](docstrings.md#setcontrast) | X (2) | X (3) | X (3) |
| [mode](docstrings.md#mode) | X | X | X |
| [setMode](docstrings.md#setmode) | X | X | X |
| [defaultMode](docstrings.md#defaultmode) | X | X | X |
| [setDefaultMode](docstrings.md#setdefaultmode) | X | X | X |
| [allModes](docstrings.md#allmodes) | X | X | X |
| [setPrimary](docstrings.md#setprimary) | X | X | X |
| [isPrimary](docstrings.md#isprimary) | X | X | X |
| [turnOn](docstrings.md#turnon) | X (4) | X | X (4) |
| [turnOff](docstrings.md#turnoff) | X (4) | X | X (4) |
| [isOn](docstrings.md#ison) | X (2) | X | X |
| [suspend](docstrings.md#suspend) | X (4) | X (4) | X (4) |
| [isSuspended](docstrings.md#issuspended) | X (2) | X | X |
| [attach](docstrings.md#attach) | X | X | |
| [detach](docstrings.md#detach) | X | X | |
| [isAttached](docstrings.md#isattached) | X | X | X |


(1) Maybe not working in all macOS versions and/or architectures (thanks to University of [Utah - Marriott Library - Apple Infrastructure](https://github.com/univ-of-utah-marriott-library-apple/privacy_services_manager), [eryksun](https://stackoverflow.com/questions/22841741/calling-functions-with-arguments-from-corefoundation-using-ctypes) and [nriley](https://github.com/nriley/brightness/blob/master/brightness.c) for pointing me to the solution)
Expand All @@ -95,7 +97,7 @@ the provided handle is not valid.
- macOS: It will suspend ALL monitors. Use turnOn() to wake them up again


#### WARNING: Most of these properties may return ''None'' in case the value can not be obtained
***WARNING: Most of these properties may return ''None'' in case the value can not be obtained***

### Important OS-dependent behaviors and limitations:

Expand Down Expand Up @@ -123,10 +125,10 @@ You can activate a watchdog, running in a separate Thread, which will allow you
information updated, without negatively impacting your main process, and define hooks and its callbacks to be
notified when monitors are plugged / unplugged or their properties change.

| Watchdog methods: |
|:----------------------:|
| isWatchdogEnabled |
| updateWatchdogInterval |
| Watchdog methods: |
|:--------------------------------------------------------------:|
| [isWatchdogEnabled](docstrings.md#iswatchdogenabled) |
| [updateWatchdogInterval](docstrings.md#updatewatchdoginterval) |

The watchdog will automatically start while the update information is enabled and / or there are any listeners
registered, and will automatically stop otherwise or if the script finishes.
Expand All @@ -138,11 +140,11 @@ consume more CPU and may produce additional notifications for intermediate (non-

### Keep Monitors info updated

| Info update methods: |
|:--------------------------:|
| enableUpdateInfo |
| disableUpdateInfo |
| isUpdateInfoEnabled |
| Info update methods: |
|:---------------------------------------------------------:|
| [enableUpdateInfo](docstrings.md#enableupdateinfo) |
| [disableUpdateInfo](docstrings.md#disableupdateinfo) |
| [isUpdateInfoEnabled](docstrings.md#isupdateinfoenabled) |

Enable this only if you need to keep track of monitor-related events like changing its resolution, position, scale,
or if monitors can be dynamically plugged or unplugged in a multi-monitor setup. If you need monitors info updated
Expand All @@ -156,14 +158,14 @@ their properties (see `getAllMonitors()` and `getAllMonitorsDict()` function).
It is possible to register listeners to be invoked in case the number of connected monitors or their
properties change.

| Listeners methods: |
|:--------------------------:|
| plugListenerRegister |
| changeListenerRegister |
| plugListenerUnregister |
| changeListenerUnregister |
| isPlugListenerRegistered |
| isChangeListenerRegistered |
| Listeners methods: |
|:----------------------------------------------------------------------:|
| [plugListenerRegister](docstrings.md#pluglistenerregister) |
| [changeListenerRegister](docstrings.md#changelistenerregister) |
| [plugListenerUnregister](docstrings.md#pluglistenerunregister) |
| [changeListenerUnregister](docstrings.md#changelistenerunregister) |
| [isPlugListenerRegistered](docstrings.md#ispluglistenerregistered) |
| [isChangeListenerRegistered](docstrings.md#ischangelistenerregistered) |

The information passed to the listeners is as follows:

Expand Down
54 changes: 54 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import re
import time

project = 'PyMonCtl'
year = time.strftime("%Y")
author = 'Kalmat'
copyright = year + ", " + author
release = "latest"
with open("../../src/pymonctl/__init__.py", "r") as fileObj:
match = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fileObj.read(), re.MULTILINE
)
if match:
release = match.group(1)

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = ["myst_parser"]
myst_enable_extensions = ["colon_fence"]
source_suffix = {
'.rst': 'restructuredtext',
'.txt': 'markdown',
'.md': 'markdown',
}
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
# https://www.sphinx-doc.org/en/master/usage/theming.html
html_theme = 'bizstyle'
html_static_path = ['_static']
myst_heading_anchors = 7

# -- Copy the modules documentation ------------------------------------------
# https://stackoverflow.com/questions/66495200/is-it-possible-to-include-external-rst-files-in-my-documentation
from urllib.request import urlretrieve

# urlretrieve(
# "https://raw.githubusercontent.com/kalmat/pymonctl/master/README.md",
# "index.md"
# )
# urlretrieve(
# "https://raw.githubusercontent.com/kalmat/pymonctl/master/docstrings.md",
# "docstrings.md"
# )
Loading

0 comments on commit f79501b

Please sign in to comment.