Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Fix StringIO issue (by using BytesIO) and add a python_2_unicode_compatible decorator to the function toctree() #12

Merged
merged 3 commits into from
Feb 18, 2016
Merged
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
7 changes: 4 additions & 3 deletions atelier/rstgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from __future__ import unicode_literals, print_function
from builtins import bytes
from future.utils import python_2_unicode_compatible
from future import standard_library

standard_library.install_aliases()
Expand All @@ -27,7 +28,6 @@
from builtins import object

import sys
# import cStringIO as StringIO
import io


Expand Down Expand Up @@ -496,6 +496,7 @@ def boldheader(title):
return "\n\n**%s**\n\n" % str(title).strip()


@python_2_unicode_compatible
def toctree(*children, **options):
r"""Return a `toctree` directive with specified `options` and
`children`.
Expand All @@ -506,7 +507,7 @@ def toctree(*children, **options):
'\n\n.. toctree::\n :maxdepth: 2\n\n a\n b\n c\n'

>>> toctree('a', 'b', 'c', hidden=True)
u'\n\n.. toctree::\n :hidden:\n\n a\n b\n c\n'
'\n\n.. toctree::\n :hidden:\n\n a\n b\n c\n'


"""
Expand All @@ -525,7 +526,7 @@ def toctree(*children, **options):
for child in children:
text += "\n " + child
text += "\n"
return text
return str(text)


class stdout_prefix(object):
Expand Down
5 changes: 3 additions & 2 deletions atelier/sphinxconf/insert_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def import_object(self, objname, source=None):

import sys
# from io import StringIO # see blog 2016/0125.html
from StringIO import StringIO
# from StringIO import StringIO
from io import BytesIO
# import inspect
import traceback

Expand Down Expand Up @@ -209,7 +210,7 @@ def get_rst(self):

def output_from_exec(self, code):
old = sys.stdout
buffer = StringIO()
buffer = BytesIO()
sys.stdout = buffer
context = self.get_context()

Expand Down
1 change: 0 additions & 1 deletion atelier/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def setup_from_tasks(
prj.load_tasks()
# ns.configure({
# 'current_project': prj})
print(prj)
ns.configure({'doc_trees': prj.doc_trees})
ns.configure({'main_package': main_package,
'doc_trees': prj.doc_trees})
Expand Down