Skip to content

Commit

Permalink
set up sphinx docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevalicjus committed Dec 1, 2022
1 parent b878415 commit 318c996
Show file tree
Hide file tree
Showing 19 changed files with 288 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Sphinx opts
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)
23 changes: 23 additions & 0 deletions docs/api/actions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
NTFYAction
==========

.. autoclass:: ntfpy.NTFYAction
:members:

NTFYBroadcastAction
-------------------

.. autoclass:: ntfpy.NTFYBroadcastAction
:members:

NTFYHttpAction
--------------

.. autoclass:: ntfpy.NTFYHttpAction
:members:

NTFYViewAction
--------------

.. autoclass:: ntfpy.NTFYViewAction
:members:
5 changes: 5 additions & 0 deletions docs/api/attachments.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NTFYUrlAttachment
-----------------

.. autoclass:: ntfpy.NTFYUrlAttachment
:members:
5 changes: 5 additions & 0 deletions docs/api/client.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NTFYClient
----------

.. autoclass:: ntfpy.NTFYClient
:members:
12 changes: 12 additions & 0 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
API Reference
=============

.. toctree::
:maxdepth: 2

actions
attachments
client
messages
server
user
11 changes: 11 additions & 0 deletions docs/api/messages.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NTFYMessage
===========

.. autoclass:: ntfpy.NTFYMessage
:members:

NTFYPushMessage
---------------

.. autoclass:: ntfpy.NTFYPushMessage
:members:
5 changes: 5 additions & 0 deletions docs/api/server.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NTFYServer
----------

.. autoclass:: ntfpy.NTFYServer
:members:
5 changes: 5 additions & 0 deletions docs/api/user.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NTFYUser
--------

.. autoclass:: ntfpy.NTFYUser
:members:
15 changes: 15 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.. _changelog:

Changelog
=========

.. _vp0p0p10:

v0.0.10
-------

New Features
~~~~~~~~~~~~

- Added ``NTFYPushMessage``

67 changes: 67 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Sphinx Doc Builder Config
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import sys
import os

sys.path.insert(0, os.path.abspath("../src/"))
sys.path.append(os.path.abspath("extensions"))

# Project Info
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "ntfpy"
copyright = "2022, Nevalicjus"
author = "Nevalicjus"
release = "0.0.10"

# General
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.extlinks",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx_copybutton",
"resourcelinks"
]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
source_suffix = ".rst"
locale_dirs = ["locale/"]

# HTML Options
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "domdf_sphinx_theme"
html_static_path = ["_static"]

html_show_sphinx = False
html_logo = "./images/ntfpy-50x50.png"
html_favicon = "./images/ntfpy.ico"

htmlhelp_basename = "ntfpydoc"

# Extension Options

resource_links = {
"discord": "https://n3v.xyz/support",
"issues": "https://github.com/nevalicjus/ntfpy/issues",
"examples": "https://github.com/nevalicjus/ntfpy/tree/main/examples"
}

intersphinx_mapping = {
"py": ("https://docs.python.org/3", None),
"req": ("https://requests.readthedocs.io/en/latest/", None)
}

autodoc_default_options = {
"member-order": "bysource",
"undoc-members": True,
"exclude-members": "__weakref__,__dict__,__str__,__module__,__annotations__",
"autosummary": True
}

napoleon_use_ivar = True
39 changes: 39 additions & 0 deletions docs/extensions/resourcelinks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from typing import Any, Dict, List, Tuple

from docutils import nodes, utils
from docutils.nodes import Node, system_message
from docutils.parsers.rst.states import Inliner

import sphinx
from sphinx.application import Sphinx
from sphinx.util.nodes import split_explicit_title
from sphinx.util.typing import RoleFunction


def make_link_role(resource_links: Dict[str, str]) -> RoleFunction:
def role(
typ: str,
rawtext: str,
text: str,
lineno: int,
inliner: Inliner,
options: Dict = {},
content: List[str] = []
) -> Tuple[List[Node], List[system_message]]:
text = utils.unescape(text)
has_explicit_title, title, key = split_explicit_title(text)
full_url = resource_links[key]
if not has_explicit_title:
title = full_url
pnode = nodes.reference(title, title, internal = False, refuri = full_url)
return [pnode], []
return role


def add_link_role(app: Sphinx) -> None:
app.add_role("resource", make_link_role(app.config.resource_links))

def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value("resource_links", {}, "env")
app.connect("builder-inited", add_link_role)
return {"version": sphinx.__display_version__, "parallel_read_safe": True}
Binary file added docs/images/ntfpy-200x200.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/images/ntfpy-50x50.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/images/ntfpy.ico
Binary file not shown.
Binary file added docs/images/ntfpy.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/images/ntfpy_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. ntfpy documentation master file
Welcome to ntfpy
================

ntfpy is a Python API Wrapper for ntfy.sh


Getting Started
---------------

- :doc:`intro`
- :resource:`Examples <examples>`


Getting Help
------------

- Ask us in the :resource:`Discord <discord>` server
- For specifics, use :ref:`index <genindex>` or :ref:`searching <search>`
- Report bugs in :resource:`issues <issues>`

.. toctree::
:maxdepth: 1
:hidden:

intro
changelog

.. toctree::
:caption: API Reference
:maxdepth: 2
:hidden:

api/index

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

Introduction
============

Installation
------------

Run this in your terminal to install the library

.. code-block:: bash
python3 -m pip install ntfpy
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -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

%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
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd

0 comments on commit 318c996

Please sign in to comment.