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

factor out HTTP logic with ConnectStrategy abstraction #6

Merged
merged 19 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add docs build, simplify modules
  • Loading branch information
eli-darkly committed Dec 30, 2022
commit a763cd7720d34a06904afe8e499e45cd824bbb25
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@

PYTEST_FLAGS=-W error::SyntaxWarning

test:
pytest $(PYTEST_FLAGS)

lint:
mypy --install-types --non-interactive --config-file mypy.ini ld_eventsource testing

.PHONY: lint
docs:
cd docs && make html

.PHONY: test lint docs

TEMP_TEST_OUTPUT=/tmp/sse-contract-test-service.log

Expand Down
1 change: 1 addition & 0 deletions contract-tests/stream_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Import ld_eventsource from parent directory
sys.path.insert(1, os.path.join(sys.path[0], '..'))
from ld_eventsource import *
from ld_eventsource.config import *


http_client = urllib3.PoolManager()
Expand Down
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
#

.PHONY: help install html

SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = launchdarkly-eventsource
SOURCEDIR = .
BUILDDIR = build

help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

install:
pip3 install -r requirements.txt

html: install
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
29 changes: 29 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# How the Python SDK documentation works

The generated API documentation is built with [Sphinx](http://www.sphinx-doc.org/en/master/), and is hosted on [Read the Docs](https://readthedocs.org/).

It uses the following:

* Docstrings within the code. Docstrings can use any of the markup supported by Sphinx.
* The `.rst` files in the `docs` directory. These provide the overall page structure.
* The `conf.py` file containing Sphinx settings.

## What to document

Every public class, method, and module should have a docstring. Classes and methods with no docstring will not be included in the API docs.

"Public" here means things that we want third-party developers to use. The SDK also contains many modules and classes that are not actually private (i.e. they aren't prefixed with `_`), but are for internal use only and aren't supported for any other use (we would like to reduce the amount of these in future).

To add an undocumented class or method in an existing module to the docs, just give it a docstring.

To add a new module to the docs, give it a docstring and then add a link to it in the appropriate `api-*.rst` file, in the same format as the existing links.

## Undocumented things

Modules that contain only implementation details are omitted from the docs by simply not including links to them in the `.rst` files.

Internal classes in a documented module will be omitted from the docs if they do not have any docstrings, unless they inherit from another class that has docstrings. In the latter case, the way to omit them from the docs is to edit the `.rst` file that contains the link to that module, and add a `:members:` directive under the module that specifically lists all the classes that _should_ be shown.

## Testing

In the `docs` directory, run `make html` to build all the docs. Then view `docs/build/html/index.html`.
Empty file added docs/_static/.gitkeep
Empty file.
Empty file added docs/_templates/.gitkeep
Empty file.
172 changes: 172 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# -*- coding: utf-8 -*-
# type: ignore
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- 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('.'))

import os
import sys

sys.path.insert(0, os.path.abspath('..'))

from ld_eventsource.version import VERSION

# -- Project information -----------------------------------------------------

project = u'launchdarkly-eventsource'
copyright = u'2022, LaunchDarkly'
author = u'LaunchDarkly'

# The short X.Y version.
version = VERSION
# The full version, including alpha/beta/rc tags.
release = VERSION


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# 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',
'sphinx_autodoc_typehints',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

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

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

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'


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

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# 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']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'launchdarkly-eventsource-doc'


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'launchdarkly-eventsource.tex', u'launchdarkly-eventsource Documentation',
u'LaunchDarkly', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'launchdarkly-eventsource', u'launchdarkly-eventsource Documentation',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'launchdarkly-eventsource', u'launchdarkly-eventsource Documentation',
author, 'launchdarkly-eventsource', 'One line description of project.',
'Miscellaneous'),
]


# -- Extension configuration -------------------------------------------------

autodoc_default_options = {
'undoc-members': False
}
41 changes: 41 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
LaunchDarkly Python SSE Client
==============================

This is the API reference for the `launchdarkly-eventsource <https://github.com/launchdarkly/python-eventsource/>`_ package, a `Server-Sent Events <https://html.spec.whatwg.org/multipage/server-sent-events.html>`_ client for Python. This package is used internally by the `LaunchDarkly Python SDK <https://github.com/launchdarkly/python-server-sdk>`_, but may also be useful for other purposes.


ld_eventsource module
---------------------

.. automodule:: ld_eventsource
:members:
:imported-members:
:special-members: __init__


ld_eventsource.actions module
-----------------------------

.. automodule:: ld_eventsource.actions
:members:
:imported-members:
:special-members: __init__
:show-inheritance:


ld_eventsource.config module
----------------------------

.. automodule:: ld_eventsource.config
:members:
:imported-members:


ld_eventsource.errors module
----------------------------

.. automodule:: ld_eventsource.errors
:members:
:imported-members:
:special-members: __init__
:show-inheritance:
11 changes: 11 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sphinx
sphinx_rtd_theme
sphinx-autodoc-typehints

backoff>=1.4.3
certifi>=2018.4.16
expiringdict>=1.1.4
pyRFC3339>=1.0
jsonpickle==0.9.3
semver>=2.7.9
urllib3>=1.22.0
4 changes: 0 additions & 4 deletions ld_eventsource/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
from ld_eventsource.actions import *
from ld_eventsource.errors import *
from ld_eventsource.error_strategy import *
from ld_eventsource.request_params import *
from ld_eventsource.retry_delay_strategy import *
from ld_eventsource.sse_client import *
Loading