Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy Documentation to GitHub Pages

on:
push:
branches: [ "formatting-changes" ]

workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'

- name: Install Hatch
run: pip install hatch

- name: Install dependencies
run: |
pip install -e ".[docs]"

- name: Build documentation
run: |
cd docs
make html

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/build/html'

deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
__pycache__
.*.swp
.idea/
*.DS_Store
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
14 changes: 14 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Minimal makefile for Sphinx documentation

SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@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.https://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
Binary file added docs/source/_static/powersensor-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
API Reference
=============

.. automodule:: powersensor_local
:members:
:undoc-members:
:show-inheritance:

Submodules
__________

.. autosummary::
:toctree: submodules
:recursive:

devices
listener
86 changes: 86 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""Sphinx configuration file for powersensor_local documentation."""

import sys
from pathlib import Path

# Add the package to the Python path
project_root = Path(__file__).parent.parent.parent
sys.path.insert(0, str(project_root / "src"))
print(project_root)

# Project information
project = "powersensor_local"
copyright = "2025, DiUS" # noqa A001
author = "Powersensor Team!"

html_favicon = "_static/powersensor-logo.png"
html_logo = "_static/powersensor-logo.png"

# The full version, including alpha/beta/rc tags
try:
from powersensor_local import __version__ as release
except ImportError:
release = "0.1.0"

version = ".".join(release.split(".")[:2])

# Extensions
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx_autodoc_typehints",
"sphinx.ext.autosummary"
]

# Napoleon settings (for Google and NumPy style docstrings)
napoleon_google_docstring = True
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = False
napoleon_include_private_with_doc = False

# Autodoc settings
autodoc_default_options = {
"members": True,
"undoc-members": True,
"show-inheritance": True,
}

# Intersphinx mapping
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
}

# HTML theme
html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
html_css_files = []


# Output file base name for HTML help builder
htmlhelp_basename = "powersensor_localdoc"

# Options for LaTeX output
latex_elements = {}
latex_documents = [
("index", "powersensor_local.tex", "powersensor_local Documentation", "Your Name", "manual"),
]

# Options for manual page output
man_pages = [
("index", "powersensor_local", "powersensor_local Documentation", [author], 1)
]

# Options for Texinfo output
texinfo_documents = [
(
"index",
"powersensor_local",
"powersensor_local Documentation",
author,
"powersensor_local",
"One line description of project.",
"Miscellaneous",
),
]
38 changes: 38 additions & 0 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Contributing
============

We welcome contributions! Here's how you can help:

Development Setup
-----------------

1. Fork the repository
2. Clone your fork:

.. code-block:: bash

git clone https://github.com/yourusername/powersensor_local.git

3. Install development dependencies:

.. code-block:: bash

pip install -e ".[docs]"


Building Documentation
----------------------

.. code-block:: bash

cd docs
make html

The documentation will be built in `docs/build/html/`.

Submitting Changes
------------------

1. Create a new branch for your changes
2. Make your changes and add tests
3. Submit a pull request
18 changes: 18 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Welcome to powersensor_local's documentation!
=================================================

.. toctree::
:maxdepth: 2
:caption: Contents:

installation
usage
api
contributing

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
27 changes: 27 additions & 0 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Installation
============

From PyPI
---------

.. code-block:: bash

pip install powersensor_local

From Source
-----------

.. code-block:: bash

git clone https://github.com/yourusername/powersensor_local.git
cd powersensor_local
pip install -e .

Development Installation
------------------------

.. code-block:: bash

git clone https://github.com/yourusername/powersensor_local.git
cd powersensor_local
pip install -e ".[docs]"
18 changes: 18 additions & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Usage
=====

Basic Usage
-----------

Here's a simple example of how to use powersensor_local:

.. code-block:: python

import powersensor_local

# Add your usage examples here

Advanced Usage
--------------

More detailed examples and advanced features will be documented here.
13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[project]
name = "powersensor-local"
version = "2.0.1"
dynamic = ["version"]
description = "Network-local (non-cloud) interface for Powersensor devices"
authors = [
{ name = "Jade Mattsson", email = "jmattsson@dius.com.au" },
{ name = "Lake Bookman", email = "lbookman@dius.com.au" },
]
readme = "README.md"
requires-python = ">=3.11"
Expand All @@ -28,3 +29,13 @@ ps-plugevents = "powersensor_local.plugevents:app"
[build-system]
requires = [ "hatchling" ]
build-backend = "hatchling.build"

[project.optional-dependencies]
docs = [
"sphinx>=7.0.0",
"sphinx-rtd-theme>=1.3.0",
"sphinx-autodoc-typehints>=1.24.0",
]

[tool.hatch.version]
path = "src/powersensor_local/__init__.py"
16 changes: 8 additions & 8 deletions src/powersensor_local/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
Lower-level interfaces are available in the PlugListenerUdp and PlugListenerTcp
classes, though they are not recommended for general use.

Additionally a convience abstraction for translating some of the events into
Additionally, a convenience abstraction for translating some of the events into
a household view is available in VirtualHousehold.

Quick overview:
• PlugApi is the recommended API layer
• PlugListenerUdp is the UDP lower-level abstraction used by PlugApi
• PlugListenerTcp is the TCP lower-level abstraction used by PlugApi
• PowersensorDevices is the legacy main API layer
LegadyDiscovery provides access to the legacy discovery mechanism
LegacyDiscovery provides access to the legacy discovery mechanism
• VirtualHousehold can be used to translate events into a household view

The 'plugevents' and 'rawplug' modules are helper utilities provided as
Expand All @@ -35,13 +35,13 @@
nder the names ps-events, and offers up the events from PowersensorDevices.
"""
__all__ = [
'devices',
'legacy_discovery',
'plug_api',
'plug_listener_tcp',
'plug_listener_udp',
'virtual_household'
'VirtualHousehold',
'PlugApi',
'__version__',
'PlugListenerTcp',
'PlugListenerUdp'
]
__version__ = "2.0.1"
from .devices import PowersensorDevices
from .legacy_discovery import LegacyDiscovery
from .plug_api import PlugApi
Expand Down
Loading