Skip to content

Commit

Permalink
Initial implementation of singlefile-slides builder. (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyergler committed Apr 8, 2015
1 parent 16cfd73 commit 2b4410e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
7 changes: 7 additions & 0 deletions NEWS.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
News
====

0.8
---

*Release date: UNRELEASED*

* Add `singlefile-slides` builder

0.7.1
-----

Expand Down
1 change: 1 addition & 0 deletions src/hieroglyph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def setup(app):
# Register Builders
app.add_builder(builder.SlideBuilder)
app.add_builder(builder.DirectorySlideBuilder)
app.add_builder(builder.SingleFileSlideBuilder)
app.add_builder(builder.InlineSlideBuilder)
app.add_builder(builder.DirectoryInlineSlideBuilder)

Expand Down
14 changes: 14 additions & 0 deletions src/hieroglyph/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from docutils import nodes
from sphinx.theming import Theme
from sphinx.builders.html import (
SingleFileHTMLBuilder,
StandaloneHTMLBuilder,
DirectoryHTMLBuilder,
)
Expand Down Expand Up @@ -197,6 +198,19 @@ class SlideBuilder(AbstractSlideBuilder, StandaloneHTMLBuilder):
name = 'slides'


class SingleFileSlideBuilder(AbstractSlideBuilder, SingleFileHTMLBuilder):
"""This is the single file Slide HTML builder.
Its output is a directory with a single HTML file, along with the
needed style sheets and JavaScript.
Its name is ``singlefile-slides``.
"""

name = 'singlefile-slides'


class AbstractInlineSlideBuilder(object):

name = 'inlineslides'
Expand Down
16 changes: 16 additions & 0 deletions src/hieroglyph/tests/test_builder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import glob
from unittest import TestCase

from sphinx_testing import (
Expand Down Expand Up @@ -106,3 +107,18 @@ def test_docstitle_fallback_to_html_title(self, app, status, warning):
builder.globalcontext['docstitle'],
builder.config.html_title,
)


class SingleFileBuilderTests(TestCase):

@with_app(
buildername='singlefile-slides',
)
def test_builds_single_file(self, app, *args):

app.build()

self.assertEqual(
len(glob.glob(app.builddir/'singlefile-slides'/'*.html')),
1,
)
2 changes: 1 addition & 1 deletion src/hieroglyph/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def visit_slide(self, node):

def depart_slide(self, node):

if not getattr(node, 'closed', False):
if self.current_slide and not getattr(node, 'closed', False):

# mark the slide closed
node.closed = True
Expand Down

0 comments on commit 2b4410e

Please sign in to comment.