Skip to content
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

Dependencies upgrade #76

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
- "3.5.1"
- "3.6.5"
install:
- pip install -r requirements.txt
script:
Expand Down
17 changes: 15 additions & 2 deletions deconstrst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys

from pip import pip
from setuptools import setup
from deconstrst.deconstrst import build, get_conf_builder
from deconstrst.config import Configuration

Expand All @@ -18,7 +19,8 @@ def main(directory=False):

if config.content_root:
if directory and directory != config.content_root:
print("Warning: Overriding CONTENT_ROOT [{}] with argument [{}].".format(config.content_root, directory))
print("Warning: Overriding CONTENT_ROOT [{}] with argument [{}].".format(
config.content_root, directory))
else:
os.chdir(config.content_root)
elif directory:
Expand Down Expand Up @@ -52,6 +54,7 @@ def main(directory=False):
print(file=sys.stderr)
sys.exit(1)


def install_requirements():
"""
Install non-colliding dependencies from a "requirements.txt" file found at
Expand Down Expand Up @@ -79,8 +82,18 @@ def install_requirements():

dependencies.append(stripped)

print("Installing dependencies from {}: {}.".format(reqfile, ', '.join(dependencies)))
print("Installing dependencies from {}: {}.".format(
reqfile, ', '.join(dependencies)))
pip.main(['install'] + dependencies)


if __name__ == '__main__':
setup(
entry_points={
'sphinx.builders': [
'deconst-serial = DeconstSerialJSONBuilder',
'deconst-single = DeconstSingleJSONBuilder',
],
}
)
main()
14 changes: 11 additions & 3 deletions deconstrst/builders/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

TOC_DOCNAME = '_toc'


class DeconstSerialJSONBuilder(JSONHTMLBuilder):
"""
Custom Sphinx builder that generates Deconst-compatible JSON documents.
Expand Down Expand Up @@ -87,7 +88,8 @@ def write_context(self, context):

# If this repository has a TOC, reference it as an addenda.
if self.toc_envelope:
envelope.add_addenda('repository_toc', self.toc_envelope.content_id)
envelope.add_addenda(
'repository_toc', self.toc_envelope.content_id)

self.dump_context(envelope.serialization_payload(),
envelope.serialization_path())
Expand Down Expand Up @@ -161,8 +163,10 @@ def _toc_envelope(self):
if full_render:
self.secnumbers = self.env.toc_secnumbers.get(docname, {})
self.fignumbers = self.env.toc_fignumbers.get(docname, {})
self.imgpath = relative_uri(self.get_target_uri(docname), '_images')
self.dlpath = relative_uri(self.get_target_uri(docname), '_downloads')
self.imgpath = relative_uri(
self.get_target_uri(docname), '_images')
self.dlpath = relative_uri(
self.get_target_uri(docname), '_downloads')
self.current_docname = docname

rendered_toc = self.render_partial(doctree)['body']
Expand All @@ -178,3 +182,7 @@ def _toc_envelope(self):
deconst_config=self.deconst_config,
per_page_meta={'deconstunsearchable': True},
docwriter=self._publisher.writer)


def setup(app):
app.add_builder(DeconstSerialJSONBuilder)
4 changes: 4 additions & 0 deletions deconstrst/builders/single.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@ def write_context(self, context):

with open(envelope.serialization_path(), 'w', encoding="utf-8") as f:
jsonimpl.dump(envelope.serialization_payload(), f)


def setup(app):
app.add_builder(DeconstSerialJSONBuilder)
21 changes: 18 additions & 3 deletions deconstrst/deconstrst.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import urllib.parse

import requests
from setuptools import setup
from deconstrst.builders.serial import DeconstSerialJSONBuilder
from deconstrst.builders.single import DeconstSingleJSONBuilder
from sphinx.application import Sphinx
from sphinx.builders import BUILTIN_BUILDERS

DEFAULT_BUILDER = 'deconst-serial'

Expand All @@ -19,8 +19,8 @@ def build(srcdir, destdir):
"""

# I am a terrible person
BUILTIN_BUILDERS['deconst-serial'] = DeconstSerialJSONBuilder
BUILTIN_BUILDERS['deconst-single'] = DeconstSingleJSONBuilder
# BUILTIN_BUILDERS['deconst-serial'] = DeconstSerialJSONBuilder
# BUILTIN_BUILDERS['deconst-single'] = DeconstSingleJSONBuilder

conf_builder = get_conf_builder(srcdir)
doctreedir = os.path.join(destdir, '.doctrees')
Expand All @@ -34,6 +34,7 @@ def build(srcdir, destdir):

return app.statuscode


def get_conf_builder(srcdir):
with open(os.path.join(srcdir, 'conf.py'), encoding="utf-8") as conf_file:
conf_data = conf_file.read()
Expand All @@ -47,3 +48,17 @@ def get_conf_builder(srcdir):
"""

return locals().get('builder', DEFAULT_BUILDER)


def setup(app):
app.setup_extension('sphinx.builders.html')
app.add_builder(DeconstSerialJSONBuilder)
app.add_builder(DeconstSingleJSONBuilder)
setup(
entry_points={
'sphinx.builders': [
'deconst-serial = DeconstSerialJSONBuilder',
'deconst-single = DeconstSingleJSONBuilder',
],
}
)
29 changes: 16 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
alabaster==0.7.7
Babel==2.3.4
certifi==2016.2.28
docutils==0.12
imagesize==0.7.1
Jinja2==2.8
MarkupSafe==0.23
Pygments==2.1.3
pytz==2016.4
requests==2.10.0
six==1.10.0
alabaster==0.7.10
Babel==2.5.3
certifi==2018.1.18
docutils==0.14
imagesize==1.0.0
Jinja2==2.10
MarkupSafe==1.0
pbr==4.0.2
Pygments==2.2.0
pytz==2018.4
PyYAML==3.12
reno==2.7.0
requests==2.18.4
six==1.11.0
snowballstemmer==1.2.1
Sphinx==1.4.1
sphinx-rtd-theme==0.1.9
Sphinx==1.7.2
sphinx_rtd_theme==0.3.0
termcolor==1.1.0
31 changes: 16 additions & 15 deletions test/requirements/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
alabaster==0.7.7
Babel==2.3.4
docutils==0.12
imagesize==0.7.1
Jinja2==2.8
MarkupSafe==0.23
pbr==1.10.0
Pygments==2.1.3
pytz==2016.4
PyYAML==3.11
reno==1.6.2
requests==2.10.0
six==1.10.0
alabaster==0.7.10
Babel==2.5.3
certifi==2018.1.18
docutils==0.14
imagesize==1.0.0
Jinja2==2.10
MarkupSafe==1.0
pbr==4.0.2
Pygments==2.2.0
pytz==2018.4
PyYAML==3.12
reno==2.7.0
requests==2.18.4
six==1.11.0
snowballstemmer==1.2.1
Sphinx==1.4.1
sphinx-rtd-theme==0.1.9
Sphinx==1.7.2
sphinx_rtd_theme==0.3.0
termcolor==1.1.0