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

[WIP] Entry points #78

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
189eb46
(chore): updating dependencies
nimbinatus Apr 10, 2018
1b21165
(chore): update dependencies
nimbinatus Apr 11, 2018
55dee99
(fix): working on fixing the builder call with the newer Sphinx API
nimbinatus Apr 11, 2018
0b3b5e5
(fix): a bit more WIP; I'm going to end up just repackaging this soon...
nimbinatus Apr 11, 2018
0ea74fd
[WIP] Update to latest Alpine and pip packages
Aug 30, 2018
6fc577a
Use subprocess to run pip (for pip10+)
Sep 12, 2018
c894e82
Fix class name typo
Sep 12, 2018
36fa2a1
Primarily adds a setup.py file, for use by docker to install, so that…
Oct 30, 2018
c86c13d
The tests are now running. They are failing, but I am not yet sure if…
Oct 30, 2018
040b4c7
Fixes no newline at the end of gitignore.
Oct 30, 2018
041a73d
Fixes code-style to conform to Flake8
Oct 30, 2018
910d4e7
Updates travis.yml to follow use the setup.py file to install
Nov 5, 2018
f39fb34
This is a progress update, a key change made is that the conf.py requ…
Nov 27, 2018
563782e
Merge branch 'master' into entry-points
dubhsuil Nov 27, 2018
c92bf68
single now successfully builds! The output is incorrect, but it's fin…
Nov 27, 2018
d504772
Merge branch 'master' of https://github.com/deconst/preparer-sphinx i…
Nov 27, 2018
f6bcf2d
Merge branch 'entry-points' of https://github.com/dubhsuil/preparer-s…
Nov 27, 2018
6a80ad7
All tests are now building successfully, the builders are, however, p…
Nov 28, 2018
b7319bf
Simply removing some commented out code that is not needed.
Nov 28, 2018
f1f091e
Updated tests to expect unicode characters, made some QOL changes to …
Dec 6, 2018
ef53649
accidentally included a bad edit in the last commit, removing it now.
Dec 6, 2018
2c21142
Now accurately calculates asset offsets, the asset paths, and the act…
Dec 17, 2018
cd26f73
Serial and single builds are now successful, there were several unic…
Jan 2, 2019
b0de3ae
Made some fixes to the output of "requirements," it is still not quit…
Jan 7, 2019
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
Prev Previous commit
Next Next commit
(fix): working on fixing the builder call with the newer Sphinx API
  • Loading branch information
nimbinatus committed Apr 11, 2018
commit 55dee99340a9b6068982ddb755e1c746d45022cd
8 changes: 6 additions & 2 deletions deconstrst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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 +53,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 +81,10 @@ 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__':
main()
10 changes: 7 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 Down
20 changes: 17 additions & 3 deletions deconstrst/deconstrst.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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 +18,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 +33,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 +47,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',
],
}
)