diff --git a/AUTHORS.rst b/AUTHORS.rst index 151ad60..ef07ea5 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -21,3 +21,4 @@ In chronological order: - jerry2yu (`@jerry2yu `_) - Joshua Li (`@JoshuaRLi `_) - Sébastien Eustace (`@sdispater `_) +- Evan Mattiza (`@emattiza `_) diff --git a/Makefile b/Makefile index 264178c..32167b8 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,4 @@ tests: pytest tests/ +docs: + cd docs && make html diff --git a/Pipfile b/Pipfile index e451f41..ff3033a 100644 --- a/Pipfile +++ b/Pipfile @@ -1,3 +1,7 @@ +[dev-packages] +pytest = "*" +Sphinx = "*" + [packages] humanize = "*" pytz = "*" @@ -5,6 +9,3 @@ dateparser = "*" "ruamel.yaml" = "*" tzlocal = "*" pendulum = ">=1.0" - -[dev-packages] -pytest = "*" diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..e10ff51 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = python -msphinx +SPHINXPROJ = maya +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) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..4fbc845 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,36 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=python -msphinx +) +set SOURCEDIR=source +set BUILDDIR=build +set SPHINXPROJ=maya + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The Sphinx module was not found. Make sure you have Sphinx installed, + echo.then set the SPHINXBUILD environment variable to point to the full + echo.path of the 'sphinx-build' executable. Alternatively you may add the + echo.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% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/docs/source/api/MayaDT.rst b/docs/source/api/MayaDT.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/source/api/MayaInterval.rst b/docs/source/api/MayaInterval.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/source/api/public_functions.rst b/docs/source/api/public_functions.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..6cb4c02 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# maya documentation build configuration file, created by +# sphinx-quickstart on Sun May 28 15:46:10 2017. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# 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('.')) +sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath('_themes')) + +import maya + +# -- 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.ext.todo', + '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' + +# General information about the project. +project = 'maya' +copyright = '2017, Kenneth Reitz' +author = 'Kenneth Reitz' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = maya.__version__ +# The full version, including alpha/beta/rc tags. +release = maya.__version__ + +# 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 = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = [] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- 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' + +# 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'] + + +# -- Options for HTMLHelp output ------------------------------------------ + +# Output file base name for HTML help builder. +htmlhelp_basename = 'mayadoc' + + +# -- 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, 'maya.tex', 'maya Documentation', + 'Kenneth Reitz', '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, 'maya', 'maya 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, 'maya', 'maya Documentation', + author, 'maya', 'One line description of project.', + 'Miscellaneous'), +] + + + diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..83962c1 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,83 @@ +.. maya documentation master file, created by + sphinx-quickstart on Sun May 28 15:46:10 2017. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Maya: Datetime for Humans +================================ +Release v\ |version|. (:ref:`Installation `) + +.. image:: https://img.shields.io/pypi/v/maya.svg + :target: https://pypi.python.org/pypi/maya + +.. image:: https://travis-ci.org/kennethreitz/maya.svg?branch=master + :target: https://travis-ci.org/kennethreitz/maya + +.. image:: https://img.shields.io/badge/SayThanks-!-1EAEDB.svg + :target: https://saythanks.io/to/kennethreitz + +☤ Behold, datetimes for humans! +------------------------------- +.. code-block:: pycon + + >>> now = maya.now() + + + >>> tomorrow = maya.when('tomorrow') + + + >>> tomorrow.slang_date() + 'tomorrow' + + >>> tomorrow.slang_time() + '23 hours from now' + + # Also: MayaDT.from_iso8601(...) + >>> tomorrow.iso8601() + '2017-02-10T22:17:01.445418Z' + + # Also: MayaDT.from_rfc2822(...) + >>> tomorrow.rfc2822() + 'Fri, 10 Feb 2017 22:17:01 GMT' + + # Also: MayaDT.from_rfc3339(...) + >>> tomorrow.rfc3339() + '2017-02-10T22:17:01.44Z' + + >>> tomorrow.datetime() + datetime.datetime(2016, 12, 16, 15, 11, 30, 263350, tzinfo=) + + # Automatically parse datetime strings and generate naive datetimes. + >>> scraped = '2016-12-16 18:23:45.423992+00:00' + >>> maya.parse(scraped).datetime(to_timezone='US/Eastern', naive=True) + datetime.datetime(2016, 12, 16, 13, 23, 45, 423992) + + >>> rand_day = maya.when('2011-02-07', timezone='US/Eastern') + + + >>> rand_day.day + 7 + + >>> rand_day.add(days=10).day + 17 + + # Always. + >>> rand_day.timezone + UTC + + # Range of hours in a day: + >>> maya.interval( + ... start=maya.now(), + ... end=maya.now().add(days=1), + ... interval=60*60) + + + +Table of Contents +----------------- +.. toctree:: + :maxdepth: 2 + + user/install + user/quickstart + diff --git a/docs/source/user/advanced.rst b/docs/source/user/advanced.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/source/user/install.rst b/docs/source/user/install.rst new file mode 100644 index 0000000..db0c8c1 --- /dev/null +++ b/docs/source/user/install.rst @@ -0,0 +1,30 @@ +.. _install: +Installation +============= + +Pip Install Maya +---------------- + +To install maya, simply use:: + $ pip install maya + +Source Code +----------- +Maya is actively developed on `Github +`_ + +You can either clone the public repository:: + + $ git clone git://github.com/kennethreitz/maya.git + +Or, download the `tarball `_:: + + $ curl -OL https://github.com/kennethreitz/maya/tarball/master + # optionally, zipball is also available (for Windows users). + +Once you have a copy of the source, you can embed it in your own Python +package, or install it into your site-packages easily:: + + $ python setup.py install + + diff --git a/docs/source/user/intro.rst b/docs/source/user/intro.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/source/user/quickstart.rst b/docs/source/user/quickstart.rst new file mode 100644 index 0000000..2c0a19e --- /dev/null +++ b/docs/source/user/quickstart.rst @@ -0,0 +1,38 @@ +.. _quickstart: +Quickstart +========== + +.. module::maya + +Ready for a simple datetime tool? This doc provides some tools to use in your +busy workflow. + +First, make sure that Maya is: + +- :ref:`Installed ` +- :ref:`Up to date ` + + +Parse a Date +------------ +Parsing a date from a string with Maya is 🍰! + +First, you'll need to import maya:: + + >>> import maya + +There are currently two ways to make sense of datetime: + +- ``maya.parse`` +- ``maya.when`` + +A simple answer is that you should use parse on machine output, and when on human input. + +Use as follows:: + + >>> recent_win = maya.parse('2016-11-02T20:00PM') + >>> old_win = maya.when('October 14, 1908') + >>> grandpas_date = maya.when('108 years ago') + + + diff --git a/docs/source/user/update.rst b/docs/source/user/update.rst new file mode 100644 index 0000000..79a1a4b --- /dev/null +++ b/docs/source/user/update.rst @@ -0,0 +1,27 @@ +.. _update: +Community Updates +================= + +If you'd like to stay up to date on the community and development of Maya, +there are several options: + + +GitHub +------ + +The best way to track the development of Maya is through +`the GitHub repo `_. + +Twitter +------- + +The author, Kenneth Reitz, often tweets about new features and releases of Maya. + +Follow `@kennethreitz `_ for updates. + + + +Release and Version History +=========================== + +.. include:: ../../HISTORY.rst diff --git a/maya/__init__.py b/maya/__init__.py index a8ce586..d162cc0 100644 --- a/maya/__init__.py +++ b/maya/__init__.py @@ -1 +1,2 @@ -from .core import * \ No newline at end of file +from .core import * +from .__version__ import __version__ diff --git a/maya/__version__.py b/maya/__version__.py new file mode 100644 index 0000000..73e3bb4 --- /dev/null +++ b/maya/__version__.py @@ -0,0 +1 @@ +__version__ = '0.3.2' diff --git a/setup.py b/setup.py index 690d083..7c891f1 100755 --- a/setup.py +++ b/setup.py @@ -37,9 +37,14 @@ packages = [ 'maya', ] +# About dict to store version and package info +about = dict() +with open(os.path.join(here, 'maya', '__version__.py'), 'r', 'utf-8') as f: + exec(f.read(), about) + setup( name='maya', - version='0.3.1', + version=about['__version__'], description='Datetimes for Humans.', long_description=long_description, author='Kenneth Reitz',