Skip to content

Commit

Permalink
Merge pull request #9 from numberly/feature/documentation
Browse files Browse the repository at this point in the history
Add documentation
  • Loading branch information
ramnes committed Apr 5, 2018
2 parents 804af3b + 294fd18 commit 86693d2
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ Session.vim

# virtualenv
.venv*
src/
src/

# docs
docs/_build
20 changes: 20 additions & 0 deletions docs/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.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = Thingy
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)
38 changes: 38 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#

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


# -- 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",
"sphinx.ext.viewcode",
]

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'Thingy'
copyright = 'numberly'
author = 'numberly'


# -- 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 = 'alabaster'
14 changes: 14 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. Thingy documentation master file, created by
sphinx-quickstart on Thu Mar 29 15:01:49 2018.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. include:: ../README.rst

Documentation
=============

.. toctree::
:maxdepth: 1

reference
6 changes: 6 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
API reference
#############

.. automodule:: thingy
:members:
:undoc-members:
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pytest==3.0.7
pytest-cov==2.4.0
six==1.10.0
sphinx==1.7.2
8 changes: 8 additions & 0 deletions thingy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ def __get__(self, instance, cls):


class View(object):
"""Transform an :class:`object` into a dict
:param bool defaults: Include attributes of object
:param list include: A list of properties to include
:param list exclude: A list of attributes to exclude
:param bool ordered: Use an :class:`OrderedDict` instead
"""

def __init__(self, defaults=False, include=None, exclude=None,
ordered=False):
Expand Down Expand Up @@ -78,6 +85,7 @@ def getclassattr(instance, attr):

@six.add_metaclass(ThingyMetaClass)
class Thingy(object):
"""Allows you to use object notation instead of dict notation"""
_view_cls = View
_silent = True

Expand Down

0 comments on commit 86693d2

Please sign in to comment.