-
Notifications
You must be signed in to change notification settings - Fork 1
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
Addresses #28, #37 moved main files to src folder. Testing and sphinx… #49
Changes from 3 commits
1f76e0d
0a514a7
8024c5a
a635768
36b281e
c882302
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,11 @@ wheels/ | |
MANIFEST | ||
|
||
# Environments | ||
.tox | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
venv.bak/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# File: .readthedocs.yaml | ||
|
||
version: 2 | ||
|
||
build: | ||
os: "ubuntu-20.04" | ||
tools: | ||
python: "3.9" | ||
|
||
sphinx: | ||
configuration: docs/conf.py | ||
|
||
python: | ||
install: | ||
- requirements: docs/requirements.txt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AUTHORS | ||
======= | ||
|
||
DHtech Community |
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 = . | ||
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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. include:: ../Authors.rst |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# 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 = 'Undate' | ||
copyright = '2022, DHtech' | ||
author = 'DHtech Community' | ||
|
||
# The full version, including alpha/beta/rc tags | ||
release = '0.0.1.dev' | ||
|
||
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', | ||
'sphinx.ext.intersphinx', | ||
'm2r2' | ||
] | ||
|
||
# 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 = ['_build', 'Thumbs.db', '.DS_Store'] | ||
|
||
source_suffix = [".rst", ".md"] | ||
|
||
# -- 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' | ||
|
||
# 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'] | ||
|
||
html_logo = '_static/logo.png' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Undate documentation | ||
==================== | ||
|
||
This project ... | ||
|
||
|
||
.. toctree:: | ||
:maxdepth: 3 | ||
:caption: Contents: | ||
|
||
readme | ||
undate | ||
authors | ||
license | ||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
License | ||
======= | ||
.. mdinclude:: ../LICENSE.md |
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=. | ||
set BUILDDIR=_build | ||
|
||
if "%1" == "" goto help | ||
|
||
%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 | ||
) | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Introduction | ||
============ | ||
.. mdinclude:: ../README.md |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-e .[dev] | ||
sphinx | ||
sphinx_rtd_theme | ||
m2r2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Undate | ||
====== | ||
|
||
.. autoclass:: undate.undate.Undate | ||
:members: | ||
:undoc-members: | ||
|
||
|
||
.. autoclass:: undate.undate.UndateInterval | ||
:members: | ||
:undoc-members: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools>=42", | ||
"wheel" | ||
] | ||
build-backend = "setuptools.build_meta" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[metadata] | ||
name = undate | ||
version = attr: undate.__version__ | ||
author = 'DHTech' | ||
author_email = 'dhtech.community@gmail.com' | ||
description = "library for working with uncertain, fuzzy, or " | ||
+ "partially unknown dates and date intervals" | ||
long_description = file: README.md | ||
license="Apache License, Version 2.0", | ||
long_description_content_type = text/markdown | ||
url = https://github.com/dh-tech/hackathon-2022 | ||
project_urls = | ||
Project Home = https://dh-tech.github.io | ||
Bug Tracker = https://github.com/dh-tech/hackathon-2022/-/issues | ||
classifiers = | ||
Development Status :: 2 - Pre-Alpha | ||
Programming Language :: Python :: 3 | ||
Intended Audience :: Developers | ||
License :: OSI Approved :: Apache Software License | ||
Operating System :: OS Independent | ||
Topic :: Software Development :: Libraries :: Python Modules | ||
Topic :: Utilities | ||
Typing :: Typed | ||
|
||
[options] | ||
package_dir = | ||
= src | ||
packages = find: | ||
python_requires = >=3.8 | ||
install_requires = | ||
python-dateutil | ||
[options.extras_require] | ||
all = | ||
%(dev)s | ||
%(test)s | ||
dev = | ||
black>=22.10.0 | ||
pre-commit>=2.20.0 | ||
tox | ||
sphinx | ||
twine | ||
test = | ||
pytest>=7.2 | ||
|
||
[options.packages.find] | ||
where = src |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,4 @@ | ||
import os | ||
from setuptools import setup | ||
import setuptools | ||
|
||
from undate import __version__ | ||
|
||
# load the readme contents and use for package long description | ||
with open(os.path.join(os.path.dirname(__file__), "README.md")) as readme: | ||
README = readme.read() | ||
|
||
REQUIREMENTS = ["python-dateutil"] | ||
TEST_REQUIREMENTS = ["pytest>=7.2"] | ||
DEV_REQUIREMENTS = [ | ||
"black>=22.10.0", | ||
"pre-commit>=2.20.0", | ||
] | ||
|
||
setup( | ||
name="undate", | ||
version=__version__, | ||
description="library for working with uncertain, fuzzy, or " | ||
+ "partially unknown dates and date intervals", | ||
long_description=README, | ||
url="https://github.com/dh-tech/hackathon-2022", | ||
author="DHTech", | ||
author_email="dhtech.community@gmail.com", | ||
license="Apache License, Version 2.0", | ||
packages=["undate"], | ||
install_requires=REQUIREMENTS, | ||
tests_require=TEST_REQUIREMENTS, | ||
extras_require={ | ||
"test": TEST_REQUIREMENTS, | ||
"dev": TEST_REQUIREMENTS + DEV_REQUIREMENTS, | ||
}, | ||
classifiers=[ | ||
# any relevant environment classifiers ? | ||
"Development Status :: 2 - Pre-Alpha", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
"Topic :: Utilities", | ||
"Typing :: Typed", | ||
], | ||
) | ||
if __name__ == "__main__": | ||
setuptools.setup() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
ONE_DAY = datetime.timedelta(days=1) | ||
|
||
|
||
class Undate: | ||
class Undate(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am just old school, I guess. We can remove them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am too, trying to train myself not to do this style |
||
"""Simple object for representing uncertain, fuzzy or partially unknown dates""" | ||
|
||
DEFAULT_FORMAT = "ISO8601" | ||
|
@@ -88,7 +88,14 @@ def duration(self) -> datetime.timedelta: | |
return self.latest - self.earliest + ONE_DAY | ||
|
||
|
||
class UndateInterval: | ||
class UndateInterval(): | ||
"""A date range between two uncertain dates. | ||
|
||
:param earliest: Earliest undate | ||
:type earliest: `undate.Undate` | ||
:param latest: Latest undate | ||
:type latest: `undate.Undate` | ||
""" | ||
# date range between two uncertain dates | ||
|
||
def __init__( | ||
|
@@ -107,6 +114,11 @@ def __eq__(self, other) -> bool: | |
return self.earliest == other.earliest and self.latest == other.latest | ||
|
||
def duration(self) -> datetime.timedelta: | ||
"""Calculate the duration between two undates. | ||
|
||
:returns: A duration | ||
:rtype: timedelta | ||
""" | ||
# what is the duration of this date range? | ||
|
||
# if both years are known, subtract end of range from beginning of start | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ColeDCrawford I don't know how to reconcile tox with the python version test matrix, do you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like
tox-gh-actions
worked!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now do we need to specify the python versions in more places? would be nice if we could avoid that duplication somehow (seems redundant to have it in the tox config and also the build matrix). We should put it on the readme at some point, too, but hoping we can use a badge to pull from pypi once we publish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, it would be nice to pull the build matrix from
tox.ini tox.envlist
orsetup.cfg
, but not sure how to set that up.