1
0
mirror of https://github.com/otter18/tg_logger.git synced 2025-06-18 21:47:37 +02:00

docs init

This commit is contained in:
Chernykh Vladimir
2021-03-11 19:47:11 +03:00
parent 93756128ef
commit f9ce96ac22
9 changed files with 290 additions and 6 deletions

20
docs/Makefile Normal file
View File

@ -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 = source
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)

View File

@ -1,6 +0,0 @@
{\rtf1\ansi\ansicpg1251\cocoartf2513
\cocoatextscaling0\cocoaplatform0{\fonttbl}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
}

35
docs/make.bat Normal file
View File

@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
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% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

61
docs/source/conf.py Normal file
View File

@ -0,0 +1,61 @@
# 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('../tg_logger'))
# -- Project information -----------------------------------------------------
project = 'tg-logger'
copyright = '2021, ChernV (otter18)'
author = 'ChernV (otter18)'
# The full version, including alpha/beta/rc tags
release = '3.0'
# -- 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 = ["sphinx.ext.autodoc"]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'python3'
# 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 = []
# -- 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 = 'sphinx_rtd_theme'
# 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']

13
docs/source/fqa.rst Normal file
View File

@ -0,0 +1,13 @@
FQA
====
How to create a telegram bot?
******************************
To create bot use official `BotFather <https://t.me/BotFather>`_ bot (descibed `here <https://core.telegram.org/bots#6-botfather>`_)
How to get **token** and **user_id**?
*************************************
- Bot's **token** is shown after new bot is made
- To get **user_id** use special bots (e.g. `@userinfobot <https://t.me/userinfobot>`_, `@JsonDumpBot <https://t.me/JsonDumpBot>`_)

30
docs/source/index.rst Normal file
View File

@ -0,0 +1,30 @@
.. tg-logger documentation master file, created by
sphinx-quickstart on Thu Mar 11 18:47:28 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to tg-logger's documentation!
=====================================
.. toctree::
:maxdepth: 2
:caption: Contents:
intro
modules
fqa
license
Links
=====
- Github: https://github.com/otter18/tg_logger
- Pypi: https://pypi.org/project/tg-logger
..
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

100
docs/source/intro.rst Normal file
View File

@ -0,0 +1,100 @@
Introduction
============
Tg-logger is took for bridging python logging and files to tg bot
Installation & Usage
********************
.. code:: bash
pip install tg-logger
.. code:: python
import tg_logger
Screenshot
**********
.. image:: https://raw.githubusercontent.com/otter18/tg_logger/master/img/example_scr.png
:alt: example screenshot
Examples
********
Simple logging
##############
.. code:: python
import logging
import tg_logger
# Telegram data
token = "1234567890:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
users = [1111111111]
# Base logger
logger = logging.getLogger('foo')
logger.setLevel(logging.INFO)
# Logging bridge setup
tg_logger.setup(logger, token=token, users=users)
# Test
logger.info("Hello from tg_logger by otter18")
Flask logging
#############
.. code:: python
from flask import Flask
import tg_logger
# Telegram data
token = "1234567890:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
users = [1111111111]
# Flask app setup
app = Flask(__name__)
app.logger.setLevel(logging.ERROR) # flask logger
tg_logger.setup(app.logger, token=token, users=users) # bridge setup
@app.route('/')
def hello_world():
return 'Hello, World!'
if __name__ == '__main__':
app.run()
TgFileLogger example
####################
.. code:: python
import tg_logger
# Telegram data
token = "1234567890:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
users = [1111111111]
# TgFileLogger example
tg_files_logger = tg_logger.TgFileLogger(
token=token, # tg bot token
users=users, # list of user_id
timeout=10 # 10 seconds by default
)
file_name = "test.txt"
with open(file_name, 'w') as example_file:
example_file.write("Hello from tg_logger by otter18")
tg_files_logger.send(file_name, "Test file")

24
docs/source/license.rst Normal file
View File

@ -0,0 +1,24 @@
License
========
MIT License
Copyright (c) 2021 ChernV
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.

7
docs/source/modules.rst Normal file
View File

@ -0,0 +1,7 @@
Module description
===================
.. automodule:: tg_logger
:members:
:undoc-members:
:show-inheritance: