Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
pelinski committed Aug 9, 2024
2 parents f89087f + 02722ac commit ff99fe8
Show file tree
Hide file tree
Showing 37 changed files with 3,194 additions and 1,622 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy Documentation to GitHub Pages

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install dependencies
env:
PIPENV_VENV_IN_PROJECT: true
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install -d
sudo apt-get update && sudo apt-get install -y pandoc
- name: Build documentation
run: |
pandoc -s readme.md -o docs/readme.rst
pipenv run sphinx-build -M html docs/ docs/_build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ dev/
*.err
.vscode/
__pycache__/
*.txt
build/
*.egg-info
*.bin
*.fzz
dist/
*.sh
*.sh
.clang-format
docs/_build/*
docs/readme.rst
9 changes: 7 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ nest-asyncio = "*"
aiofiles = "*"
pybela = {editable = true, path = "."}
paramiko = "*"
numpy = "==1.26"

[dev-packages]
build = "*"
twine = "*"
pip-chill = "*"
sphinx = "*"
sphinx-rtd-theme = "*"
build = "*"

[scripts]
test = "python test/test.py"
test-send = "python test/test-send.py"

[requires]
python_version = "3.10"
python_version = "3.9"
2,478 changes: 1,403 additions & 1,075 deletions Pipfile.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
footer {
display: none !important;
}
63 changes: 63 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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 os
import sys
import re
sys.path.insert(0, os.path.abspath('../pybela'))

author = 'Teresa Pelinski'
copyright = '2024'
def get_version_from_setup_py():
version_pattern = re.compile(r"version=['\"]([^'\"]+)['\"]")
with open('../setup.py', 'r') as f:
setup_py_content = f.read()
match = version_pattern.search(setup_py_content)
if match:
return match.group(1)
raise RuntimeError("Unable to find version string in setup.py")

release = get_version_from_setup_py()
project = f'pybela {release}'

# -- General configuration ---------------------------------------------------
extensions = [
'sphinx.ext.napoleon', 'sphinx.ext.viewcode', 'sphinx_rtd_theme']
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '../pybela/utils.py']


# -- Options for HTML output -------------------------------------------------
html_theme = 'sphinx_rtd_theme'
html_css_files = [
'custom.css',
]
html_static_path = ['_static']
html_css_files = ['custom.css']
html_show_sphinx = False
html_show_sourcelink = False
html_sidebars = {
'**': ['globaltoc.html', 'searchbox.html']
}
html_theme_options = {
'collapse_navigation': False,
'sticky_navigation': True,
'navigation_depth': 4,
'titles_only': False,
'display_version': True,
'prev_next_buttons_location': 'None',
}

# remove title from readme file to avoid duplication
file_path = 'readme.rst'

with open(file_path, 'r+') as file:
lines = file.readlines()[2:] # Read lines and skip the first two
file.seek(0) # Move the cursor to the beginning of the file
file.writelines(lines) # Write the modified lines
file.truncate() # Truncate the file to the new size
9 changes: 9 additions & 0 deletions docs/docs-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
To build the docs you will need to install `pandoc` to convert the `readme.md` into `rst` (the format used by `sphinx`, the docs builder). You can see the installation instructions [here](https://pandoc.org/installing.html).

Then you can build the docs with:

```bash
rm -r _build
pandoc -s ../readme.md -o readme.rst
pipenv run sphinx-build -M html . _build
```
29 changes: 29 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. pybela documentation master file, created by
sphinx-quickstart on Tue Aug 6 18:36:50 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
pybela docs
===========
Welcome to pybela’s documentation!

.. include:: readme.rst

.. toctree::
:maxdepth: 2
:caption: Getting started with pybela
:hidden:

readme

.. toctree::
:caption: Module documentation
:maxdepth: 4
:hidden:

genindex
modules




25 changes: 25 additions & 0 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

.. automodule:: pybela.Watcher
:members:
:undoc-members:
:show-inheritance:

.. automodule:: pybela.Streamer
:members:
:undoc-members:
:show-inheritance:

.. automodule:: pybela.Logger
:members:
:undoc-members:
:show-inheritance:

.. automodule:: pybela.Monitor
:members:
:undoc-members:
:show-inheritance:

.. automodule:: pybela.Controller
:members:
:undoc-members:
:show-inheritance:
8 changes: 4 additions & 4 deletions pybela/Controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
from .Watcher import Watcher
from .utils import print_info, print_warning
from .utils import _print_info, _print_warning


class Controller(Watcher):
Expand Down Expand Up @@ -40,7 +40,7 @@ async def async_wait_for_control_mode_to_be_set(variables=variables):

asyncio.run(async_wait_for_control_mode_to_be_set(variables=variables))

print_info(
_print_info(
f"Started controlling variables {variables}... Run stop_controlling() to stop controlling the variable values.")

def stop_controlling(self, variables=[]):
Expand All @@ -65,7 +65,7 @@ async def async_wait_for_control_mode_to_be_set(variables=variables):

asyncio.run(async_wait_for_control_mode_to_be_set(variables=variables))

print_info(f"Stopped controlling variables {variables}.")
_print_info(f"Stopped controlling variables {variables}.")

def send_value(self, variables, values):
"""Send a value to the given variables.
Expand All @@ -90,7 +90,7 @@ def send_value(self, variables, values):
value = values[variables.index(var)]

if value % 1 != 0 and _type in ["i", "j"]:
print_warning(
_print_warning(
f"Value {value} is not an integer, but the variable {var} is of type {_type}. Only the integer part will be sent.")

self.send_ctrl_msg(
Expand Down
Loading

0 comments on commit ff99fe8

Please sign in to comment.