diff --git a/.readthedocs.yml b/.readthedocs.yml deleted file mode 100644 index 334c9bdd..00000000 --- a/.readthedocs.yml +++ /dev/null @@ -1,23 +0,0 @@ -# .readthedocs.yml -# Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -# Required -version: 2 - -# Build documentation in the docs/ directory with Sphinx -sphinx: - configuration: docs/source/conf.py - -# Build documentation with MkDocs -#mkdocs: -# configuration: mkdocs.yml - -# Optionally build your docs in additional formats such as PDF and ePub -formats: all - -# Optionally set the version of Python and requirements required to build your docs -python: - version: 3.7 - install: - - requirements: docs/requirements.txt diff --git a/docs/Makefile b/docs/Makefile index d0c3cbf1..d4bb2cbb 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -5,8 +5,8 @@ # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build -SOURCEDIR = source -BUILDDIR = build +SOURCEDIR = . +BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 00000000..391d0251 --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,8 @@ +API +---------- + +.. autoclass:: uiautomator2.Device + :members: + +.. autoclass:: uiautomator2.Session + :members: diff --git a/docs/source/conf.py b/docs/conf.py similarity index 86% rename from docs/source/conf.py rename to docs/conf.py index 1d107318..a3618123 100644 --- a/docs/source/conf.py +++ b/docs/conf.py @@ -12,7 +12,9 @@ # import os import sys -sys.path.insert(0, os.path.abspath('../..')) +sys.path.insert(0, os.path.abspath('..')) + +import uiautomator2 # -- Project information ----------------------------------------------------- @@ -27,7 +29,12 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ["sphinx.ext.autodoc"] +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx.ext.coverage', + 'sphinx.ext.viewcode', +] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -35,7 +42,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. -exclude_patterns = [] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # -- Options for HTML output ------------------------------------------------- @@ -43,8 +50,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -#html_theme = 'alabaster' -html_theme = 'sphinx_rtd_theme' +html_theme = 'alabaster' # 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, diff --git a/docs/source/index.rst b/docs/index.rst similarity index 72% rename from docs/source/index.rst rename to docs/index.rst index c79563f3..bc59fed0 100644 --- a/docs/source/index.rst +++ b/docs/index.rst @@ -1,5 +1,5 @@ .. uiautomator2 documentation master file, created by - sphinx-quickstart on Tue Feb 18 09:46:00 2020. + sphinx-quickstart on Tue Feb 18 15:32:23 2020. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -10,11 +10,8 @@ Welcome to uiautomator2's documentation! :maxdepth: 2 :caption: Contents: -.. automodule:: uiautomator2.Device - :members: + api -.. automodule:: uiautomator2.Session - :members: Indices and tables ================== diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 483a4e96..00000000 --- a/docs/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -sphinx_rtd_theme diff --git a/uiautomator2/ext/ocr/README.md b/uiautomator2/ext-archived/ocr/README.md similarity index 100% rename from uiautomator2/ext/ocr/README.md rename to uiautomator2/ext-archived/ocr/README.md diff --git a/uiautomator2/ext/ocr/__init__.py b/uiautomator2/ext-archived/ocr/__init__.py similarity index 100% rename from uiautomator2/ext/ocr/__init__.py rename to uiautomator2/ext-archived/ocr/__init__.py diff --git a/uiautomator2/ext/ocr/baiduOCR.py b/uiautomator2/ext-archived/ocr/baiduOCR.py similarity index 100% rename from uiautomator2/ext/ocr/baiduOCR.py rename to uiautomator2/ext-archived/ocr/baiduOCR.py diff --git a/uiautomator2/session.py b/uiautomator2/session.py index 6a8b87bc..c3e03442 100644 --- a/uiautomator2/session.py +++ b/uiautomator2/session.py @@ -466,7 +466,7 @@ def drag(self, sx, sy, ex, ey, duration=0.5): return self.jsonrpc.drag(sx, sy, ex, ey, int(duration * 200)) @retry((IOError, SyntaxError), delay=.5, tries=5, jitter=0.1, - max_delay=1) # delay .5, .6, .7, .8 ... + max_delay=1, logger=logging) # delay .5, .6, .7, .8 ... def screenshot(self, filename=None, format='pillow'): """ Image format is JPEG @@ -492,9 +492,12 @@ def screenshot(self, filename=None, format='pillow'): f.write(r.content) return filename elif format == 'pillow': - from PIL import Image - buff = io.BytesIO(r.content) - return Image.open(buff).convert("RGB") + try: + from PIL import Image + buff = io.BytesIO(r.content) + return Image.open(buff).convert("RGB") + except Exception as ex: + raise IOError("PIL.Image.open IOError", ex) elif format == 'opencv': import cv2 import numpy as np