Skip to content

Commit

Permalink
BUSY: asis (experiment) -- to fix bug nyergler#102
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert Mietus authored and Albert Mietus committed Jul 23, 2015
1 parent bb747f6 commit 273f785
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/hieroglyph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ def setup(app):
app.connect('builder-inited', html.inspect_config)
app.connect('html-page-context', html.add_link)

#import hack; app.connect('doctree-resolved', hack.dump_xml)
import hack; app.connect('doctree-resolved', hack.dump_xml)
51 changes: 26 additions & 25 deletions src/hieroglyph/directives.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
from __future__ import print_function

from docutils import nodes

from sphinx.util.nodes import set_source_info
from docutils.nodes import SkipNode
from docutils.parsers.rst import Directive, directives
from docutils.parsers.rst.directives import (
admonitions,
)
from docutils.parsers.rst.directives import admonitions
from docutils.parsers.rst.roles import set_classes
from docutils.transforms import Transform


def raiseSkip(self, node):
raise SkipNode()

import hack

class if_slides(nodes.Element):
pass
Expand All @@ -27,16 +28,9 @@ class IfBuildingSlides(Directive):
option_spec = {}

def run(self):
if self.name in ('slides', 'notslides',):
if self.name in ('slides', 'notslides',): # these are deprecated, print a warning
import warnings

# these are deprecated, print a warning
warnings.warn(
"The %s directive has been deprecated; replace with if%s" % (
self.name, self.name,
),
stacklevel=2,
)
warnings.warn("The %s directive has been deprecated; replace with if%s" % (self.name, self.name))

node = if_slides()
node.document = self.state.document
Expand Down Expand Up @@ -109,6 +103,7 @@ class TransformNextSlides(Transform):

default_priority = 550

@hack.TRACE
def apply(self, *args, **kwargs):

app = self.document.settings.env.app
Expand All @@ -117,14 +112,10 @@ def apply(self, *args, **kwargs):

is_slides = builder.building_slides(app)

return self.apply_to_document(
self.document,
env=self.document.settings.env,
building_slides=is_slides,
)
return self.apply_to_document(self.document, env=self.document.settings.env, building_slides=is_slides)

@hack.TRACE
def apply_to_document(self, document, env, building_slides):

need_reread = False

for node in document.traverse(nextslide):
Expand All @@ -134,6 +125,7 @@ def apply_to_document(self, document, env, building_slides):
if need_reread:
env.note_reread()

@hack.TRACE
def _make_title_node(self, node, increment=True):
"""Generate a new title node for ``node``.
Expand Down Expand Up @@ -176,17 +168,27 @@ def _make_title_node(self, node, increment=True):
new_title.nextslide_info = nextslide_info
return new_title

@hack.TRACE
def visit_nextslide(self, node, building_slides):

index = node.parent.index(node)

if (not building_slides or
not node.parent.children[index+1:]):
if not building_slides or not node.parent.children[index+1:]:
node.parent.replace(node, [])

# nothing else to do
return

if True:
print('XXX fore-fathers of node:', node)
n = node
while n is not None:
print('XXX \t', n, "--", str(n)[:40]+'...', "class:", type(n))
n = n.parent
doctree = n

auto_level=slideconf.get_conf(self.document.settings.env.app.builder, doctree)['slide_levels']
print('XXX auto_level:', auto_level)

# figure out where to hoist the subsequent content to
parent = node.parent
grandparent = node.parent.parent
Expand All @@ -199,7 +201,7 @@ def visit_nextslide(self, node, building_slides):

# create the next section
new_section = nodes.section()
new_section += self._make_title_node(node)
new_section += self._make_title_node(node) # XXX
new_section.extend(new_children)
self.document.set_id(new_section)

Expand Down Expand Up @@ -246,6 +248,7 @@ def get_conf(cls, builder, doctree=None):
'theme': builder.config.slide_theme,
'autoslides': builder.config.autoslides,
'slide_classes': [],
'slide_levels': builder.config.slide_levels
}

# now look for a slideconf node in the doctree and update the conf
Expand Down Expand Up @@ -334,9 +337,7 @@ def process_slideconf_nodes(app, doctree, docname):

# if autoslides is disabled and we're building slides,
# replace the document tree with only explicit slide nodes
if (is_slides and
not slideconf.get_conf(
app.builder, doctree)['autoslides']):
if is_slides and not slideconf.get_conf(app.builder, doctree)['autoslides']:
filter_doctree_for_slides(doctree)


Expand Down
1 change: 0 additions & 1 deletion src/hieroglyph/themes/slides/slide.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<article class="{% if classes %}{{ ' '.join(classes) }} {% endif %}slide level-{{ level }}"{% if id %} id="{{ id }}"{% endif %}>

{% if title %}<h{{ level }}>{{ title }}</h{{ level }}> {% endif %}

{{ content }}
Expand Down
23 changes: 9 additions & 14 deletions src/hieroglyph/themes/slides2/slide.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
<slide class="{% if slide_number==1 %}title-slide segue nobackground {% endif %}{% if slide_classes %}{{ ' '.join(slide_classes) }} {% endif %}level-{{ level }}"{% if id %} id="{{ id }}"{% endif %}>
<hgroup>
{% if title %}<h{{ level }}>{{ title }}</h{{ level }}> {% endif %}
</hgroup>
<article class="{{ content_classes|join(' ') }}">
{{ content }}
<slide class="{% if slide_number==1 %}title-slide segue nobackground {% endif %}{% if slide_classes %}{{ ' '.join(slide_classes) }} {% endif %}level-{{ level }}"{% if id %} id="{{ id }}"{% endif %}>
<hgroup> {% if title %}<h{{ level }}>{{ title }}</h{{ level }}> {% endif %}</hgroup>
<article class="{{ content_classes|join(' ') }}">
{{ content }}

{% if config.slide_numbers %}<div class="slide-no">{{ slide_number }}</div>{% endif %}
{% if config.slide_footer %}<div class="slide-footer">{{ config.slide_footer }}</div>{% endif %}
</article>
</slide>

{% if config.slide_numbers %}
<div class="slide-no">{{ slide_number }}</div>
{% endif %}
{% if config.slide_footer %}
<div class="slide-footer">{{ config.slide_footer }}</div>
{% endif %}
</article>
</slide>

0 comments on commit 273f785

Please sign in to comment.