diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index f0fe511..9672b73 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -21,10 +21,7 @@ jobs: run: pip install -r src/requirements.txt - name: Build docs - run: | - cd docs/ && \ - pip install -r requirements.txt && \ - make html -e + run: make doc - name: Deploy uses: peaceiris/actions-gh-pages@v3 diff --git a/.gitignore b/.gitignore index ee14731..0f96b96 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,12 @@ src/.coverage dist/ +venv/ env/ -venv/ \ No newline at end of file +/.coverage +/src/python3_captchaai.egg-info/ +/src/.coverage +/src/coverage/lcov.info +/src/htmlcov/ +/src/coverage/ +/docs/_build/ diff --git a/Makefile b/Makefile index 68e67dd..52f8ae2 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,9 @@ tests: coverage xml -o coverage/coverage.xml refactor: + black docs/ + isort docs/ + cd src/ && \ autoflake --in-place \ --recursive \ @@ -16,9 +19,9 @@ refactor: --remove-duplicate-keys \ --remove-all-unused-imports \ --ignore-init-module-imports \ - python3_anticaptcha/ setup.py && \ - black python3_anticaptcha/ setup.py && \ - isort python3_anticaptcha/ setup.py + python3_anticaptcha/ tests/ && \ + black python3_anticaptcha/ tests/ && \ + isort python3_anticaptcha/ tests/ lint: cd src/ && \ @@ -33,3 +36,7 @@ release: upload: pip install twine cd src/ && python setup.py upload + +doc: + cd docs/ && \ + make html -e diff --git a/conf.py b/conf.py new file mode 100644 index 0000000..68fedf2 --- /dev/null +++ b/conf.py @@ -0,0 +1,52 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# 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. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'python3-anticaptcha' +copyright = '2022, AndreiDrang' +author = 'AndreiDrang' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# 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 = ['_build', 'Thumbs.db', '.DS_Store'] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +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, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] \ No newline at end of file diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# 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 = . +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) diff --git a/docs/_static/AntiCaptcha.png b/docs/_static/AntiCaptcha.png new file mode 100644 index 0000000..b6219aa Binary files /dev/null and b/docs/_static/AntiCaptcha.png differ diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..6c5522f --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,87 @@ +# -- Path setup -------------------------------------------------------------- + +import os +import sys + +from pallets_sphinx_themes import ProjectLink + +os.chdir("../") +sys.path.insert(0, os.path.abspath("src/")) + +for x in os.walk("src/python3_captchaai/"): + sys.path.insert(0, x[0]) + +from python3_anticaptcha import core, turnstile +from python3_anticaptcha.__version__ import __version__ + +# -- Project information ----------------------------------------------------- + +project = "python3-anticaptcha" +copyright = "2022, AndreiDrang" +author = "AndreiDrang" + +# -- General configuration --------------------------------------------------- +extensions = ( + "myst_parser", + "sphinx.ext.napoleon", + "pallets_sphinx_themes", + "sphinxcontrib.autodoc_pydantic", +) +myst_enable_extensions = ["deflist"] +intersphinx_mapping = {"python": ("https://docs.python.org/3.10/", None)} +templates_path = ["_templates"] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + +# -- Options for HTML output ------------------------------------------------- +# Theme config +html_theme = "jinja" +html_theme_options = {"index_sidebar_logo": False} +html_static_path = ["_static"] +html_favicon = "_static/AntiCaptcha.png" +html_logo = "_static/AntiCaptcha.png" +html_title = f"python3-anticaptcha ({__version__})" +html_show_sourcelink = False + +html_context = { + "project_links": [ + ProjectLink("PyPI Releases", "https://pypi.org/project/python3-anticaptcha/"), + ProjectLink("Source Code", "https://github.com/AndreiDrang/python3-anticaptcha"), + ProjectLink( + "AntiCaptcha", + "http://getcaptchasolution.com/vchfpctqyz", + ), + ] +} +html_sidebars = { + "index": ["project.html", "localtoc.html", "searchbox.html", "ethicalads.html"], + "**": ["localtoc.html", "relations.html", "searchbox.html", "ethicalads.html"], +} + +# Typehints config +autodoc_typehints = "both" +autodoc_typehints_description_target = "documented" +autodoc_typehints_format = "short" + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = False +napoleon_include_init_with_doc = False +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = False +napoleon_use_admonition_for_examples = True +napoleon_use_admonition_for_notes = True +napoleon_use_admonition_for_references = True +napoleon_use_ivar = True +napoleon_use_param = True +napoleon_use_rtype = True +napoleon_preprocess_types = True +napoleon_type_aliases = True +napoleon_attr_annotations = True + +autodoc_preserve_defaults = False +autodoc_member_order = "bysource" +autodoc_class_signature = "mixed" + +# Pydantic +autodoc_pydantic_model_show_json = True +autodoc_pydantic_settings_show_json = False diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..5d8c646 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,19 @@ +.. rst-class:: hide-header + +python3-anticaptcha +=================== +.. image:: _static/AntiCaptcha.png + :align: center + +Python3 library for `AntiCaptcha API `_. + +The library is intended for software developers and is used to work with the `AntiCaptcha API `_. + +.. toctree:: + :maxdepth: 1 + :caption: Start here: + + modules/main/info.md + modules/other-libs/info.md + modules/license/info.md + modules/contacts/info.md diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..48b9584 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,36 @@ + +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +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% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd \ No newline at end of file diff --git a/docs/modules/contacts/info.md b/docs/modules/contacts/info.md new file mode 100644 index 0000000..a896f45 --- /dev/null +++ b/docs/modules/contacts/info.md @@ -0,0 +1,5 @@ +# Contacts + +If you have any questions, please send a message to the [Telegram](https://t.me/pythoncaptcha) chat room. + +Or email: [python-captcha@pm.me](mailto:python-captcha@pm.me) \ No newline at end of file diff --git a/docs/modules/license/info.md b/docs/modules/license/info.md new file mode 100644 index 0000000..e452cbe --- /dev/null +++ b/docs/modules/license/info.md @@ -0,0 +1,23 @@ +# License + +MIT License + +Copyright 2022 Andrei + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/docs/modules/main/info.md b/docs/modules/main/info.md new file mode 100644 index 0000000..81228fb --- /dev/null +++ b/docs/modules/main/info.md @@ -0,0 +1,48 @@ +# Introduction + +## Welcome to python3-anticaptcha + +![](../../_static/AntiCaptcha.png) + +[![PyPI version](https://badge.fury.io/py/python3-captchaai.svg)](https://badge.fury.io/py/python3-captchaai) +[![Python versions](https://img.shields.io/pypi/pyversions/python3-captchaai.svg?logo=python&logoColor=FBE072)](https://badge.fury.io/py/python3-captchaai) +[![Downloads](https://pepy.tech/badge/python3-captchaai/month)](https://pepy.tech/project/python3-captchaai) + +[![Maintainability](https://api.codeclimate.com/v1/badges/3431fd3fe71baf7eb9da/maintainability)](https://codeclimate.com/github/AndreiDrang/python3-captchaai/maintainability) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/323d4eda0fe1477bbea8fe8902b9e97e)](https://www.codacy.com/gh/AndreiDrang/python3-captchaai/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AndreiDrang/python3-captchaai&utm_campaign=Badge_Grade) +[![codecov](https://codecov.io/gh/AndreiDrang/python3-captchaai/branch/main/graph/badge.svg?token=2L4VVIF4G8)](https://codecov.io/gh/AndreiDrang/python3-captchaai) + +[![Build check](https://github.com/AndreiDrang/python3-captchaai/actions/workflows/test_build.yml/badge.svg?branch=main)](https://github.com/AndreiDrang/python3-captchaai/actions/workflows/test_build.yml) +[![Installation check](https://github.com/AndreiDrang/python3-captchaai/actions/workflows/install.yml/badge.svg?branch=main)](https://github.com/AndreiDrang/python3-captchaai/actions/workflows/install.yml) +[![Test](https://github.com/AndreiDrang/python3-captchaai/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/AndreiDrang/python3-captchaai/actions/workflows/test.yml) +[![Lint](https://github.com/AndreiDrang/python3-captchaai/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/AndreiDrang/python3-captchaai/actions/workflows/lint.yml) + + +Python3 library for [Capsolver](https://capsolver.com/) service API. + +Tested on UNIX based OS. + +The library is intended for software developers and is used to work with the [Capsolver](https://capsolver.com/) service API. + +## How to install? + +We recommend using the latest version of Python. `python3-captchaai` supports Python +3.7+. + +### pip + +```bash +pip install python3-captchaai +``` + +### Source +```bash +git clone https://github.com/AndreiDrang/python3-captchaai.git +cd python3-captchaai +python setup.py install +``` + +## How to test? + +1. You need set ``API_KEY`` in your environment(get this value from you account). +2. Run command ``make tests``, from root directory. diff --git a/docs/modules/other-libs/info.md b/docs/modules/other-libs/info.md new file mode 100644 index 0000000..4ee6070 --- /dev/null +++ b/docs/modules/other-libs/info.md @@ -0,0 +1,6 @@ +# Other captcha-solving services libs + +## Other libraries for Captcha-solving services +1. [RuCaptcha / 2Captcha](https://github.com/AndreiDrang/python-rucaptcha) +2. [AntiCaptcha](https://github.com/AndreiDrang/python3-anticaptcha) +3. [Capsolver](https://github.com/AndreiDrang/python3-captchaai) diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..170893f --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,3 @@ +pallets_sphinx_themes==2.* +myst-parser==0.18.* +autodoc_pydantic==1.8.* diff --git a/index.rst b/index.rst new file mode 100644 index 0000000..330992b --- /dev/null +++ b/index.rst @@ -0,0 +1,20 @@ +.. python3-anticaptcha documentation master file, created by + sphinx-quickstart on Wed Dec 14 19:06:56 2022. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to python3-anticaptcha's documentation! +=============================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/make.bat b/make.bat new file mode 100644 index 0000000..153be5e --- /dev/null +++ b/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +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://www.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 diff --git a/src/tests/test_core.py b/src/tests/test_core.py index 4354f0c..90504c9 100644 --- a/src/tests/test_core.py +++ b/src/tests/test_core.py @@ -4,7 +4,7 @@ from urllib3.util.retry import Retry from src.tests.conftest import BaseTest from python3_anticaptcha.core.base import BaseCaptcha from python3_anticaptcha.core.enum import CaptchaTypeEnm -from python3_anticaptcha.core.config import RETRIES, BASE_REQUEST_URL, ASYNC_RETRIES, attempts_generator +from python3_anticaptcha.core.config import RETRIES, ASYNC_RETRIES, BASE_REQUEST_URL, attempts_generator class TestCore(BaseTest):