From 66a016ea84d9207fb4a1eaaf3492e4fd5f692d6b Mon Sep 17 00:00:00 2001 From: "Evan.Mattiza" Date: Sun, 28 May 2017 16:49:00 -0500 Subject: [PATCH 1/8] Version File Add and setup.py exec read for version Single place to change version and keep up to date at package level Signed-off-by: Evan.Mattiza --- maya/__init__.py | 3 ++- maya/__version__.py | 1 + setup.py | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 maya/__version__.py 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', From 0f38b991576cb40a93e2d70d61dcaebd9b30fc7c Mon Sep 17 00:00:00 2001 From: "Evan.Mattiza" Date: Sun, 28 May 2017 15:41:06 -0500 Subject: [PATCH 2/8] Added Sphinx to Pipfile Yeah. What it sounds like. Signed-off-by: Evan.Mattiza --- Pipfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 = "*" From c0fd845d4c6635a4c8c23d6f2d93d1bd224efe75 Mon Sep 17 00:00:00 2001 From: "Evan.Mattiza" Date: Sun, 28 May 2017 15:49:16 -0500 Subject: [PATCH 3/8] Sphinx-Quickstart Additions Basics added from sphinx-quickstart, makefile at project root updated. Signed-off-by: Evan.Mattiza --- Makefile | 2 + docs/Makefile | 20 ++++++ docs/make.bat | 36 ++++++++++ docs/source/conf.py | 160 ++++++++++++++++++++++++++++++++++++++++++ docs/source/index.rst | 20 ++++++ 5 files changed, 238 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst 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/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/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..4e78a9c --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,160 @@ +#!/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('.')) + + +# -- 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 = '' +# The full version, including alpha/beta/rc tags. +release = '' + +# 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..e5ccd99 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,20 @@ +.. 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. + +Welcome to maya's documentation! +================================ + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` From 6375143eac7c64bdee0ba3f344ac65d05639ffc3 Mon Sep 17 00:00:00 2001 From: "Evan.Mattiza" Date: Sun, 28 May 2017 16:09:55 -0500 Subject: [PATCH 4/8] Authors add for Evan Added myself to authors Signed-off-by: Evan.Mattiza --- AUTHORS.rst | 1 + 1 file changed, 1 insertion(+) 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 `_) From 953f8579407814f0c2a2c58891e848d7a1d17d11 Mon Sep 17 00:00:00 2001 From: "Evan.Mattiza" Date: Sun, 28 May 2017 16:21:43 -0500 Subject: [PATCH 5/8] Index Basics added Signed-off-by: Evan.Mattiza --- docs/source/index.rst | 67 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index e5ccd99..b8d9e5b 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -3,15 +3,78 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to maya's documentation! +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) + + .. toctree:: :maxdepth: 2 :caption: Contents: - Indices and tables ================== From 8469e60d3c818e0d9b24002672ba7b0c5001ac84 Mon Sep 17 00:00:00 2001 From: "Evan.Mattiza" Date: Sun, 28 May 2017 16:23:40 -0500 Subject: [PATCH 6/8] Tree of API and Use-Case definitions added files for api descriptions and usage by users Signed-off-by: Evan.Mattiza --- docs/source/api/MayaDT.rst | 0 docs/source/api/MayaInterval.rst | 0 docs/source/api/public_functions.rst | 0 docs/source/user/advanced.rst | 0 docs/source/user/install.rst | 0 docs/source/user/intro.rst | 0 docs/source/user/quickstart.rst | 0 7 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/source/api/MayaDT.rst create mode 100644 docs/source/api/MayaInterval.rst create mode 100644 docs/source/api/public_functions.rst create mode 100644 docs/source/user/advanced.rst create mode 100644 docs/source/user/install.rst create mode 100644 docs/source/user/intro.rst create mode 100644 docs/source/user/quickstart.rst 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/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..e69de29 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..e69de29 From c0f1bd709f1a802243edeb48916bdecbe9eb06e1 Mon Sep 17 00:00:00 2001 From: "Evan.Mattiza" Date: Sun, 28 May 2017 16:47:08 -0500 Subject: [PATCH 7/8] Versioning in docs off Maya Package Signed-off-by: Evan.Mattiza --- docs/source/conf.py | 11 +++++++---- docs/source/index.rst | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 4e78a9c..6cb4c02 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -17,10 +17,13 @@ # 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 +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 ------------------------------------------------ @@ -58,9 +61,9 @@ author = 'Kenneth Reitz' # built documents. # # The short X.Y version. -version = '' +version = maya.__version__ # The full version, including alpha/beta/rc tags. -release = '' +release = maya.__version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/source/index.rst b/docs/source/index.rst index b8d9e5b..9273452 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -74,6 +74,8 @@ Release v\ |version|. (:ref:`Installation `) :maxdepth: 2 :caption: Contents: + user/install + Indices and tables ================== From d8cbdede28aeb020c2a4d1028c27c5cb52a3e4c4 Mon Sep 17 00:00:00 2001 From: "Evan.Mattiza" Date: Mon, 29 May 2017 01:03:35 -0500 Subject: [PATCH 8/8] added update, install, and some quickstart Signed-off-by: Evan.Mattiza --- docs/source/index.rst | 16 ++++++-------- docs/source/user/install.rst | 30 ++++++++++++++++++++++++++ docs/source/user/quickstart.rst | 38 +++++++++++++++++++++++++++++++++ docs/source/user/update.rst | 27 +++++++++++++++++++++++ 4 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 docs/source/user/update.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index 9273452..83962c1 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -66,20 +66,18 @@ Release v\ |version|. (:ref:`Installation `) UTC # Range of hours in a day: - >>> maya.interval(start=maya.now(), end=maya.now().add(days=1), interval=60*60) + >>> maya.interval( + ... start=maya.now(), + ... end=maya.now().add(days=1), + ... interval=60*60) +Table of Contents +----------------- .. toctree:: :maxdepth: 2 - :caption: Contents: user/install + user/quickstart - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/docs/source/user/install.rst b/docs/source/user/install.rst index e69de29..db0c8c1 100644 --- a/docs/source/user/install.rst +++ 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/quickstart.rst b/docs/source/user/quickstart.rst index e69de29..2c0a19e 100644 --- a/docs/source/user/quickstart.rst +++ 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