Skip to content

Commit

Permalink
Refactoring (#6)
Browse files Browse the repository at this point in the history
* Refactoring

* Fix quotations

* Remove extra space in yml

* Update licensE

* Remove extra quotes

* Remove unused fixture

* Address review comments

* Use markdown for license

* Remove unnecessary requires

* Some cleanup

* Specify file encoding
  • Loading branch information
Daltz333 authored Jul 1, 2020
1 parent 441bbf8 commit 8b35c26
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 23 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Test and Deploy
on:
push:
branches:
- master
create:
tags:
- '*'
jobs:
test-extension:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', 'pypy3']
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
set -xe
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r dev-requirements.txt
- name: Run Tests for ${{ matrix.python-version }}
run: |
python -m pytest -vv
pypi-release:
needs: test-extension
runs-on: ubuntu-latest
if: contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./dev-requirements.txt
- name: Build PyPI Wheel
run: |
python setup.py sdist
python setup.py bdist_wheel
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
138 changes: 138 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
24 changes: 24 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2020 FIRST
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the FIRST nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# sphinxcontrib-remoteliteralinclude
# sphinxext-remoteliteralinclude
Sphinx extension that extends the ``literalinclude`` directive to allow remote URLS

## Installation

``python3 -m pip install sphinxcontrib-remoteliteralinclude``
``python3 -m pip install sphinxext-remoteliteralinclude``

## Usage

Simply just use it as you normally would a normal ``literalinclude``

```
.. remoteliteralinclude:: https://example.com/example.java
.. rli:: https://example.com/example.java
:language: java
:lines: 10-29
:linenos:
Expand Down
1 change: 0 additions & 1 deletion __init__.py

This file was deleted.

3 changes: 3 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx
pytest==5.4.3
wheel==0.34.2
3 changes: 0 additions & 3 deletions gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions license.txt

This file was deleted.

37 changes: 29 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
import setuptools
import subprocess

with open("README.md", "r") as fh:
ret = subprocess.run("git describe --tags --abbrev=0", stdout=subprocess.PIPE,
stderr=subprocess.PIPE, check=True, shell=True)
version = ret.stdout.decode("utf-8").strip()


with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

setuptools.setup(
name="sphinxcontrib-remoteliteralinclude",
version="0.0.4",
name="sphinxext-remoteliteralinclude",
version=version,
author="Eli Barnett, Dalton Smith",
author_email="[email protected]",
description="Extending literalinclude to include remote URLs",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/daltz333/sphinxcontrib-remoteliteralinclude",
packages=['sphinxcontrib'],
url="https://github.com/wpilibsuite/sphinxext-remoteliteralinclude",
install_requires = ['sphinx>=2.0']
packages=['sphinxext'],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
'Development Status :: 5 - Production/Stable',
'Environment :: Plugins',
'Environment :: Web Environment',
'Framework :: Sphinx :: Extension',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python',
'Topic :: Documentation :: Sphinx',
'Topic :: Documentation',
'Topic :: Software Development :: Documentation',
'Topic :: Text Processing',
'Topic :: Utilities',
],
python_requires='>=3.4',
)
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,4 @@ def run(self):
return [document.reporter.warning(text_type(exc), line=self.lineno)]

def setup(app):
directives.register_directive('remoteliteralinclude', RemoteLiteralInclude)
directives.register_directive('rli', RemoteLiteralInclude)
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest
from sphinx.application import Sphinx
from sphinx.testing.path import path

pytest_plugins = "sphinx.testing.fixtures"

@pytest.fixture(scope="session")
def rootdir():
return path(__file__).parent.abspath() / "roots"

def pytest_configure(config):
config.addinivalue_line(
"markers", "sphinx"
)
7 changes: 7 additions & 0 deletions tests/roots/test-simple/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extensions = ["sphinxext.remoteliteralinclude"]

master_doc = "index"
exclude_patterns = ["_build"]

# removes most of the HTML
html_theme = "basic"
2 changes: 2 additions & 0 deletions tests/roots/test-simple/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.. rli:: http://example.com/
:lines: 4-4
11 changes: 11 additions & 0 deletions tests/test_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest

@pytest.mark.sphinx("html", testroot="simple")
def test_simple(app):
app.builder.build_all()

content = (app.outdir / 'index.html').read_text()

html = ('<span class="n">Example</span> <span class="n">Domain</span>')

assert html in content

0 comments on commit 8b35c26

Please sign in to comment.