Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Docs #141

Merged
merged 5 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Sphinx build

on:
push:
branches: [ "release" ]
paths:
- '.github/workflows/sphinx.yml'
- 'src/**'
- 'docs/**'
- 'files/**'

jobs:
docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3

- name: Build library requirements
run: pip install -r src/requirements.txt

- name: Build docs
run: make doc

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_build/html/
force_orphan: true
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ remove:
pip uninstall python_rucaptcha -y

refactor:
black docs/
isort docs/

cd src/ && \
autoflake --in-place \
--recursive \
Expand Down Expand Up @@ -32,3 +35,7 @@ tests:
coverage report --precision=3 --sort=cover --skip-empty --show-missing && \
coverage html --precision=3 --skip-empty -d coverage/html/ && \
coverage xml -o coverage/coverage.xml

doc:
cd docs/ && \
make html -e
19 changes: 19 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
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)
Binary file added docs/_static/Captcha300x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/CaptchaESm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/CaptchaSm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 90 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# -- 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/python_rucaptcha/"):
sys.path.insert(0, x[0])

from python_rucaptcha import (amazon_waf, capy_puzzle, control, core,
fun_captcha, gee_test, hcaptcha, image_captcha,
key_captcha, lemin_cropped_captcha, re_captcha,
rotate_captcha, text_captcha, turnstile,
yandex_smart_captcha)
from python_rucaptcha.__version__ import __version__

# -- Project information -----------------------------------------------------
project = "python_rucaptcha"
copyright = f"2023, AndreiDrang, Release - {__version__}"
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/CaptchaESm.png"
html_logo = "_static/CaptchaSm.png"
html_title = f"python-rucaptcha ({__version__})"
html_show_sourcelink = False

html_context = {
"project_links": [
ProjectLink("PyPI Releases", "https://pypi.org/project/python-rucaptcha/"),
ProjectLink("Source Code", "https://github.com/AndreiDrang/python-rucaptcha"),
ProjectLink(
"Capsolver",
"https://dashboard.capsolver.com/passport/register?inviteCode=kQTn-tG07Jb1",
),
]
}
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 = True
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
34 changes: 34 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.. rst-class:: hide-header

python-rucaptcha
================
.. image:: _static/Captcha300x.png
:align: center

Python3 library for `RuCaptcha <https://rucaptcha.com/>`_ and `2Captcha <https://2captcha.com/>`_ service API.

The library is intended for software developers and is used to work with the `RuCaptcha <https://rucaptcha.com/>`_ and `2Captcha <https://2captcha.com/>`_ service API.

.. toctree::
:maxdepth: 1
:caption: Start here:

modules/main/info.md
modules/other-libs/info.md
modules/license/info.md
modules/contacts/info.md

.. toctree::
:maxdepth: 3
:caption: Captcha examples:

modules/h-captcha/example.rst
modules/fun-captcha/example.rst
modules/gee-test/example.rst

.. toctree::
:maxdepth: 2
:caption: Additional modules

modules/enum/info.rst
modules/serializer/info.rst
36 changes: 36 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions docs/modules/contacts/info.md
Original file line number Diff line number Diff line change
@@ -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)
77 changes: 77 additions & 0 deletions docs/modules/enum/info.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
Enum
====

To import this module:

.. code-block:: python

from python_rucaptcha.core import enums


.. autoclass:: core.enums.MyEnum
:members:
:undoc-members:

.. autoclass:: core.enums.ServicesEnm
:members:
:undoc-members:

.. autoclass:: core.enums.SaveFormatsEnm
:members:
:undoc-members:

.. autoclass:: core.enums.GeetestEnm
:members:
:undoc-members:

.. autoclass:: core.enums.ImageCaptchaEnm
:members:
:undoc-members:

.. autoclass:: core.enums.CapyPuzzleEnm
:members:
:undoc-members:

.. autoclass:: core.enums.FunCaptchaEnm
:members:
:undoc-members:

.. autoclass:: core.enums.ReCaptchaEnm
:members:
:undoc-members:

.. autoclass:: core.enums.LeminCroppedCaptchaEnm
:members:
:undoc-members:

.. autoclass:: core.enums.HCaptchaEnm
:members:
:undoc-members:

.. autoclass:: core.enums.KeyCaptchaEnm
:members:
:undoc-members:

.. autoclass:: core.enums.RotateCaptchaEnm
:members:
:undoc-members:

.. autoclass:: core.enums.TikTokCaptchaEnm
:members:
:undoc-members:

.. autoclass:: core.enums.ControlEnm
:members:
:undoc-members:

.. autoclass:: core.enums.YandexSmartCaptchaEnm
:members:
:undoc-members:

.. autoclass:: core.enums.TurnstileCaptchaEnm
:members:
:undoc-members:

.. autoclass:: core.enums.AmazonWAFCaptchaEnm
:members:
:undoc-members:
12 changes: 12 additions & 0 deletions docs/modules/fun-captcha/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FunCaptcha
==========

To import this module:

.. code-block:: python

from python_rucaptcha.fun_captcha import FunCaptcha


.. autoclass:: fun_captcha.FunCaptcha
:members:
12 changes: 12 additions & 0 deletions docs/modules/gee-test/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
GeeTest
=======

To import this module:

.. code-block:: python

from python_rucaptcha.gee_test import GeeTest


.. autoclass:: gee_test.GeeTest
:members:
12 changes: 12 additions & 0 deletions docs/modules/h-captcha/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
HCaptcha
========

To import this module:

.. code-block:: python

from python_rucaptcha.hcaptcha import HCaptcha


.. autoclass:: hcaptcha.HCaptcha
:members:
23 changes: 23 additions & 0 deletions docs/modules/license/info.md
Original file line number Diff line number Diff line change
@@ -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.
Loading