# ========================================
# FILE: .readthedocs.yaml
# ========================================
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html

version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
  configuration: docs/conf.py
  fail_on_warning: false

# Build documentation with MkDocs
#mkdocs:
#  configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats:
  - pdf
  - epub

# Python requirements required to build your docs
python:
  version: "3.10"
  install:
    - method: pip
      path: .
      extra_requirements:
        - async
        - crypto
    - requirements: docs/requirements.txt

# Build configuration
build:
  os: ubuntu-22.04
  tools:
    python: "3.10"
  jobs:
    pre_build:
      # Install system dependencies if needed
      - apt-get update
      - apt-get install -y build-essential
    post_build:
      # Run any post-build commands
      - echo "Build completed successfully"


# ========================================
# FILE: docs/_static/custom.css
# ========================================
/* Custom CSS for gntplib documentation */

/* Improve code block styling */
.highlight {
    border-radius: 4px;
    margin: 1em 0;
}

/* Fix long code lines - enable horizontal scrolling */
.highlight pre {
    overflow-x: auto;
    white-space: pre;
    word-wrap: normal;
}

/* Better spacing for admonitions */
.admonition {
    margin: 1.5em 0;
    padding: 0.5em 1em;
    border-radius: 4px;
}

/* Make inline code stand out more */
code.literal {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-size: 0.9em;
}

/* Dark mode inline code */
[data-theme="dark"] code.literal {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Better table styling */
table.docutils {
    border-collapse: collapse;
    margin: 1em 0;
    width: 100%;
}

table.docutils th {
    background-color: rgba(0, 0, 0, 0.05);
    font-weight: 600;
    padding: 0.5em;
    text-align: left;
}

table.docutils td {
    padding: 0.5em;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] table.docutils th {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] table.docutils td {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Improve parameter list styling */
dl.field-list {
    margin: 1em 0;
}

dl.field-list dt {
    font-weight: 600;
    margin-top: 0.5em;
}

dl.field-list dd {
    margin-left: 2em;
    margin-bottom: 0.5em;
}

/* Better rubric headers */
p.rubric {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    font-size: 1.1em;
    color: var(--color-brand-primary);
}

/* Improve note/warning/tip boxes */
.admonition.note {
    border-left: 4px solid #3498db;
}

.admonition.warning {
    border-left: 4px solid #e74c3c;
}

.admonition.tip {
    border-left: 4px solid #2ecc71;
}

/* Better mobile responsiveness */
@media (max-width: 768px) {
    .highlight {
        font-size: 0.9em;
    }
    
    table.docutils {
        font-size: 0.9em;
    }
    
    dl.field-list dd {
        margin-left: 1em;
    }
}

/* Better spacing for admonitions */
.admonition {
    margin: 1.5em 0;
    padding: 0.5em 1em;
    border-radius: 4px;
}

/* Make inline code stand out more */
code.literal {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-size: 0.9em;
}

/* Dark mode inline code */
[data-theme="dark"] code.literal {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Better table styling */
table.docutils {
    border-collapse: collapse;
    margin: 1em 0;
    width: 100%;
}

table.docutils th {
    background-color: rgba(0, 0, 0, 0.05);
    font-weight: 600;
    padding: 0.5em;
    text-align: left;
}

table.docutils td {
    padding: 0.5em;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] table.docutils th {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] table.docutils td {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Improve parameter list styling */
dl.field-list {
    margin: 1em 0;
}

dl.field-list dt {
    font-weight: 600;
    margin-top: 0.5em;
}

dl.field-list dd {
    margin-left: 2em;
    margin-bottom: 0.5em;
}

/* Better API documentation sections */
.py.class > dt,
.py.function > dt,
.py.method > dt {
    background-color: rgba(0, 0, 0, 0.02);
    padding: 0.5em;
    border-left: 3px solid var(--color-brand-primary);
    border-radius: 3px;
    margin-top: 1em;
}

[data-theme="dark"] .py.class > dt,
[data-theme="dark"] .py.function > dt,
[data-theme="dark"] .py.method > dt {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Improve version badge styling */
.version-badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    background-color: var(--color-brand-primary);
}

/* Code copy button enhancement */
.highlight button.copybtn {
    opacity: 0;
    transition: opacity 0.2s;
}

.highlight:hover button.copybtn {
    opacity: 1;
}

/* Enhance sidebar navigation */
.sidebar-tree li.current > a {
    font-weight: 600;
    color: var(--color-brand-primary);
}

/* Better spacing for rubric headers */
p.rubric {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    font-size: 1.1em;
    color: var(--color-brand-primary);
}

/* Improve note/warning/tip boxes */
.admonition.note {
    border-left: 4px solid #3498db;
}

.admonition.warning {
    border-left: 4px solid #e74c3c;
}

.admonition.tip {
    border-left: 4px solid #2ecc71;
}

/* Better mobile responsiveness */
@media (max-width: 768px) {
    .highlight {
        font-size: 0.9em;
    }
    
    table.docutils {
        font-size: 0.9em;
    }
    
    dl.field-list dd {
        margin-left: 1em;
    }
}

/* Enhance search results */
.search-result-item {
    padding: 1em;
    margin: 0.5em 0;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .search-result-item {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Footer enhancement */
.footer {
    margin-top: 3em;
    padding-top: 1em;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.9em;
}

[data-theme="dark"] .footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}


# ========================================
# FILE: docs/license.rst
# ========================================

=======
License
=======

gntplib is released under the MIT License.

MIT License
===========

Copyright (c) 2025 gntplib Contributors

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.

Third-Party Licenses
====================

This project may depend on third-party packages with their own licenses:

PyCryptodome
------------

When using encryption features, PyCryptodome is required.

* License: BSD-2-Clause and Public Domain
* Homepage: https://www.pycryptodome.org/

Tornado
-------

When using async features, Tornado is required.

* License: Apache License 2.0
* Homepage: https://www.tornadoweb.org/

Sphinx
------

Documentation is built with Sphinx.

* License: BSD License
* Homepage: https://www.sphinx-doc.org/

Furo
----

Documentation uses the Furo theme.

* License: MIT License
* Homepage: https://github.com/pradyunsg/furo


# ========================================
# FILE: docs/api/requests.rst
# ========================================

=======================
Requests API Reference
=======================

Request and Response classes for GNTP protocol communication.

Request Classes
===============

BaseRequest
-----------

.. autoclass:: gntplib.requests.BaseRequest
   :members:
   :special-members: __init__
   :show-inheritance:

RegisterRequest
---------------

.. autoclass:: gntplib.requests.RegisterRequest
   :members:
   :special-members: __init__
   :show-inheritance:

   .. rubric:: Example

   .. code-block:: python

      from gntplib.requests import RegisterRequest
      from gntplib import Event, Resource

      events = [Event('update', 'Update Available')]
      icon = Resource.from_file('app.png')
      request = RegisterRequest('MyApp', icon, events)

NotifyRequest
-------------

.. autoclass:: gntplib.requests.NotifyRequest
   :members:
   :special-members: __init__
   :show-inheritance:

   .. rubric:: Example

   .. code-block:: python

      from gntplib.requests import NotifyRequest
      from gntplib.models import Notification

      notification = Notification('update', 'New Version', 'v2.0 released')
      request = NotifyRequest('MyApp', notification)

SubscribeRequest
----------------

.. autoclass:: gntplib.requests.SubscribeRequest
   :members:
   :special-members: __init__
   :show-inheritance:

Response Class
==============

.. autoclass:: gntplib.requests.Response
   :members:
   :special-members: __init__, __repr__, __str__
   :show-inheritance:

   .. rubric:: Methods

   .. automethod:: is_ok
   .. automethod:: is_error
   .. automethod:: is_callback
   .. automethod:: get_header

Utility Functions
=================

.. autofunction:: gntplib.requests.parse_response


# ========================================
# FILE: docs/api/connections.rst
# ========================================

==========================
Connections API Reference
==========================

Connection and client classes for GNTP communication.

See :doc:`core` for the main documentation of these classes.

.. automodule:: gntplib.connections
   :members:
   :show-inheritance:


# ========================================
# FILE: docs/api/async.rst
# ========================================

====================
Async API Reference
====================

Asynchronous API using Tornado framework.

Publisher & Subscriber
======================

AsyncPublisher
--------------

.. autoclass:: gntplib.async_gntp.AsyncPublisher
   :members:
   :special-members: __init__
   :show-inheritance:

AsyncSubscriber
---------------

.. autoclass:: gntplib.async_gntp.AsyncSubscriber
   :members:
   :special-members: __init__
   :show-inheritance:

Client & Connection
===================

AsyncGNTPClient
---------------

.. autoclass:: gntplib.async_gntp.AsyncGNTPClient
   :members:
   :special-members: __init__
   :show-inheritance:

AsyncGNTPConnection
-------------------

.. autoclass:: gntplib.async_gntp.AsyncGNTPConnection
   :members:
   :special-members: __init__
   :show-inheritance:

Resources
=========

AsyncResource
-------------

.. autoclass:: gntplib.async_gntp.AsyncResource
   :members:
   :special-members: __init__, __repr__
   :show-inheritance:

Utility Functions
=================

.. autofunction:: gntplib.async_gntp.fetch_async_resources_in_parallel

.. autofunction:: gntplib.async_gntp.collect_async_resources