Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishka17 committed Feb 9, 2024
1 parent 0d7f73d commit 9418220
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.10"
python:
install:
- method: pip
path: .
- requirements: requirements_doc.txt
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 = docs
BUILDDIR = docs-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)
57 changes: 57 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# 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 = 'dishka'
copyright = '2022, reagento'
author = 'Tishka17'
master_doc = 'index'

# -- 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',
]
autodoc_type_aliases = {
}
autodoc_typehints = 'description'

# 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 = []


# -- 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 = 'furo'


# 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']
15 changes: 15 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
dishka
=============================================

.. toctree::
:caption: Contents:

requirements/technical

.. toctree::
:hidden:
:caption: Project Links

GitHub <https://github.com/reagento/dishka>
PyPI <https://pypi.org/project/dishka>
Chat <https://t.me/reagento_ru>
27 changes: 18 additions & 9 deletions docs/technical_requirements.md → docs/requirements/technical.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Technical requirements for IoC-container
Technical requirements
*********************************************

#### 1. Scopes
1. Scopes
================

1. Library should support various number of scopes
2. All dependencies are attached to scopes before any of them can be created
Expand All @@ -12,43 +14,50 @@
8. If the same dependency is requested more than one time within the scope the same instance is returned. Cache is not shared between concurrent instances of same scope
9. Dependency can require other dependencies of the same or previous scope.

#### 2. Concurrency
2. Concurrency
================

1. Containers should be allowed to use with multithreading or asyncio. Not required to support both within same object.
2. Dependency creation using async functions should be supported if container is configured to run in asyncio
3. Concurrent entrance of scopes must not break requirement of single instance of dependency. Type of concurrency model can be configured when creating container
4. User of container may be allowed to switch synchronization on or off for performance tuning

#### 3. Clean dependencies
3. Clean dependencies
========================

1. Usage of container must not require modification of objects we are creating
2. Container must not require to be global variable.
4. Container can require code changes on the borders of scopes (e.g. application start, middlewares, request handlers)

#### 4. Lifecycle
4. Lifecycle
================

1. Dependencies which require some cleanup must be cleaned up on the scope exit
2. Dependencies which do not require cleanup should somehow be supported

#### 5. Context data
5. Context data
================

1. It should be allowed to pass some data when entering the scope
2. Context data must be accessible when creating dependencies

#### 6. Modularity
6. Modularity
================

1. There can be multiple containers within same code base for different purposes
2. There must be a way to assemble a container from some reusable parts.
3. Assembling of container should be done in runtime in local scope

#### 7. Usability
7. Usability
================

1. There should be a way to create dependency based on its `__init__`
2. When creating a dependency there should be a way to decide which subtype is used and request only its dependencies
3. There should be a way to reuse same object for multiple requested types
4. There should be a way to decorate dependency just adding new providers

#### 8. Integration
8. Integration
================

1. Additional helpers should be provided for some popular frameworks. E.g: flask, fastapi, aiogram, celery, apscheduler
2. These helpers should be optional
Expand Down
35 changes: 35 additions & 0 deletions 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=docs
set BUILDDIR=docs-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
3 changes: 3 additions & 0 deletions requirements_doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx==7.2.*
sphinx-autodocgen==1.3
furo==2024.1.*

0 comments on commit 9418220

Please sign in to comment.