Skip to content

Commit 6a2af18

Browse files
authored
Setup lint and test (#1)
* initial commit * fix pip install
1 parent c68da59 commit 6a2af18

File tree

11 files changed

+244
-0
lines changed

11 files changed

+244
-0
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length=100

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v1
16+
- uses: actions/setup-python@v1
17+
with:
18+
python-version: 3.7
19+
- run: pip install -e ".[dev]"
20+
- run: flake8 .
21+
- run: isort --check-only .
22+
- run: black --check .
23+
24+
test:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v1
28+
- uses: actions/setup-python@v1
29+
with:
30+
python-version: 3.7
31+
- run: pip install -e ".[dev]"
32+
- run: pytest tests

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?= -W --keep-going
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/conf.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = "sphinx-plotly-directive"
21+
copyright = "2020, harupy"
22+
author = "harupy"
23+
24+
25+
# -- General configuration ---------------------------------------------------
26+
27+
# Add any Sphinx extension module names here, as strings. They can be
28+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
29+
# ones.
30+
extensions = [
31+
"sphinx.ext.autodoc",
32+
"sphinx.ext.viewcode",
33+
"sphinx.ext.napoleon",
34+
"sphinx_rtd_theme",
35+
"sphinx_plotly_directive",
36+
]
37+
38+
# Add any paths that contain templates here, relative to this directory.
39+
templates_path = ["_templates"]
40+
41+
# List of patterns, relative to source directory, that match files and
42+
# directories to ignore when looking for source files.
43+
# This pattern also affects html_static_path and html_extra_path.
44+
exclude_patterns = []
45+
46+
47+
# -- Options for HTML output -------------------------------------------------
48+
49+
# The theme to use for HTML and HTML Help pages. See the documentation for
50+
# a list of builtin themes.
51+
#
52+
html_theme = "alabaster"
53+
54+
# Add any paths that contain custom static files (such as style sheets) here,
55+
# relative to this directory. They are copied after the builtin static files,
56+
# so a file named "default.css" will overwrite the builtin "default.css".
57+
html_static_path = ["_static"]

docs/source/index.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. sphinx-plotly-directive documentation master file, created by
2+
sphinx-quickstart on Mon Oct 19 19:57:50 2020.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to sphinx-plotly-directive's documentation!
7+
===================================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
14+
15+
Indices and tables
16+
==================
17+
18+
* :ref:`genindex`
19+
* :ref:`modindex`
20+
* :ref:`search`

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[tool.black]
2+
line-length = 100
3+
4+
[tool.isort]
5+
profile = 'black'
6+
skip_glob = ['docs/source/conf.py']
7+
line_length = 100
8+
lines_after_imports = 2

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
addopts = --color=yes --durations=5 --showlocals

setup.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import os
2+
import re
3+
4+
from setuptools import find_packages, setup
5+
6+
7+
PACKAGE_NAME = "sphinx-plotly-directive"
8+
GITHUB_REPO_URL = "https://github.com/harupy/{}".format(PACKAGE_NAME)
9+
ROOT = os.path.abspath(os.path.dirname(__file__))
10+
11+
12+
def extract_version(line):
13+
return re.search(r'__version__ = "(.+)"', line).group(1)
14+
15+
16+
def get_version():
17+
version_filepath = os.path.join(ROOT, PACKAGE_NAME.replace("-", "_"), "version.py")
18+
with open(version_filepath) as f:
19+
for line in f:
20+
if line.startswith("__version__"):
21+
return extract_version(line)
22+
23+
# should not reach this line
24+
assert False
25+
26+
27+
def get_readme():
28+
with open(os.path.join(ROOT, "README.md"), encoding="utf-8") as f:
29+
return f.read()
30+
31+
32+
def get_install_requires():
33+
return ["plotly"]
34+
35+
36+
def get_extras_require():
37+
return {
38+
"dev": [
39+
# code formatting
40+
"flake8",
41+
"isort",
42+
"black",
43+
# test
44+
"pytest",
45+
# document
46+
"sphinx==3.0.4",
47+
"sphinx-rtd-theme",
48+
]
49+
}
50+
51+
52+
setup(
53+
name=PACKAGE_NAME,
54+
version=get_version(),
55+
packages=find_packages(),
56+
python_requires=">=3.6",
57+
install_requires=get_install_requires(),
58+
extras_require=get_extras_require(),
59+
maintainer="harupy",
60+
maintainer_email="hkawamura0130@gmail.com",
61+
url=GITHUB_REPO_URL,
62+
description="A directive for including a plotly figure in a Sphinx document",
63+
long_description=get_readme(),
64+
long_description_content_type="text/markdown",
65+
)

sphinx_plotly_directive/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.1.0"

0 commit comments

Comments
 (0)