pax_global_header00006660000000000000000000000064131426237630014521gustar00rootroot0000000000000052 comment=e89a0a9bc1ece5a9b1cc0db2b0a2dba7508a69dd sphinx-autorun-1.1.0/000077500000000000000000000000001314262376300145245ustar00rootroot00000000000000sphinx-autorun-1.1.0/.gitignore000066400000000000000000000001011314262376300165040ustar00rootroot00000000000000.tox *.pyc .eggs build dist *.egg-info sphinx_autorun/version.py sphinx-autorun-1.1.0/.travis.yml000066400000000000000000000012121314262376300166310ustar00rootroot00000000000000sudo: false language: python cache: pip python: - 3.3 - 3.4 - 3.5 - 3.6 - 3.7-dev - pypy3.3-5.2-alpha1 env: matrix: - TOXENV=flake8 matrix: allow_failures: - python: 3.7-dev install: - pip install tox script: - tox before_deploy: - pip install wheel - python setup.py sdist bdist_wheel deploy: - provider: pypi user: $PYPI_USERNAME password: $PYPI_PASSWORD on: tags: true distributions: "sdist bdist_wheel" - provider: releases api_key: $GITHUB_OAUTH_TOKEN file_glob: true file: dist/* skip_cleanup: true on: tags: true distributions: "sdist bdist_wheel" sphinx-autorun-1.1.0/AUTHORS000066400000000000000000000002041314262376300155700ustar00rootroot00000000000000Hugo Osvaldo Barrera Michael McNeil Forbes Vadim Gubergrits sphinx-autorun-1.1.0/LICENCE000066400000000000000000000024531314262376300155150ustar00rootroot00000000000000Copyright (c) 2009-2017, The Contributors (see AUTHORS file). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sphinx-autorun-1.1.0/MANIFEST.in000066400000000000000000000000611314262376300162570ustar00rootroot00000000000000include README include LICENSE include CHANGES.* sphinx-autorun-1.1.0/README.rst000066400000000000000000000024011314262376300162100ustar00rootroot00000000000000============== sphinx-autorun ============== sphinx-autorun is an extension for Sphinx_ that can execute the code from a runblock directive and attach the output of the execution to the document. .. _Sphinx: https://sphinx.readthedocs.io/ For example:: .. runblock:: pycon >>> for i in range(5): ... print i Produces:: >>> for i in range(5): ... print i 1 2 3 4 5 Another example:: .. runblock:: console $ date Produces:: $ date Thu 4 Mar 2010 22:56:49 EST Currently autorun supports ``pycon`` and ``console`` languages. It's also possible to configure autorun (from `conf.py`) to run other languages. Installation ------------ Installing via pip (recommended):: $ pip install sphinx-autorun Install from source:: $ git clone git@github.com:hobarrera/sphinx-autorun.git $ python setup.py install To enable autorun add 'sphinx_autorun' to the ``extension`` list in `conf.py`:: extensions.append('sphinx_autorun') The documentation is in the doc/ folder. About this fork --------------- sphinx-contrib/autorun was abandoned and broken for several months. Since it did not even work, this fork was created as a continuation of it with mostly critical fixes. sphinx-autorun-1.1.0/docs/000077500000000000000000000000001314262376300154545ustar00rootroot00000000000000sphinx-autorun-1.1.0/docs/Makefile000066400000000000000000000163621314262376300171240ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " applehelp to make an Apple Help Book" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" @echo " coverage to run coverage check of the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Todoman.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Todoman.qhc" applehelp: $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp @echo @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." @echo "N.B. You won't be able to view it unless you put it in" \ "~/Library/Documentation/Help or install it in your application" \ "bundle." devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/Todoman" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Todoman" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." coverage: $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage @echo "Testing of coverage in the sources finished, look at the " \ "results in $(BUILDDIR)/coverage/python.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." sphinx-autorun-1.1.0/docs/source/000077500000000000000000000000001314262376300167545ustar00rootroot00000000000000sphinx-autorun-1.1.0/docs/source/conf.py000066400000000000000000000157411314262376300202630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # autorun documentation build configuration file, created by # sphinx-quickstart on Mon Mar 1 22:27:51 2010. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. from sphinx_autorun import __version__ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.append(os.path.abspath('.')) # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx_autorun', ] autorun_languages = {} autorun_languages['gnuplot'] = 'gnuplot' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = 'sphinx_autorun' copyright = '2016-2017 Hugo Osvaldo Barrera; 2010, Vadim Gubergrits' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = __version__ # The full version, including alpha/beta/rc tags. release = __version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # today = '' # Else, today_fmt is used as the format for a strftime call. # today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. # show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. # keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. html_theme_options = { 'github_user': 'hobarrera', 'github_repo': 'sphinx_contrib', 'travis_button': 'true', 'github_banner': 'true', 'github_button': 'false', } # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". # html_title = None # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. # html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. # html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. # html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. # html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. # html_additional_pages = {} # If false, no module index is generated. # html_domain_indices = True # If false, no index is generated. # html_use_index = True # If true, the index is split into individual pages for each letter. # html_split_index = False # If true, links to the reST sources are added to the pages. # html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. # html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr' # html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value # html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. # html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = 'sphinx_autorundoc' sphinx-autorun-1.1.0/docs/source/index.rst000066400000000000000000000057071314262376300206260ustar00rootroot00000000000000===================== Autorun Documentation ===================== :maintainer: Hugo Osvaldo Barrera :author: Vadim Gubergrits Autorun is an extension for Sphinx that can execute the code from a runblock directive and attach the output of the execution to the document. For example: .. code-block:: rst .. runblock:: pycon >>> for i in range(5): ... print(i) ... Produces .. runblock:: pycon >>> for i in range(5): ... print(i) ... Another example .. code-block:: rst .. runblock:: console $ date Produces .. runblock:: console $ date Should a user desire to omit some lines: .. code-block:: rst .. runblock:: pycon >>> setup_function(args) # ignore >>> for i in range(5): ... print(i) ... Produces .. runblock:: pycon >>> for i in range(5): ... print(i) ... Currently autorun supports ``pycon`` and ``console`` languages. It's also possible to configure autorun (from :file:`conf.py`) to run other languages. Installation ----------------- Installing via pip .. code-block:: console $ pip install sphinx_autorun Installing from sources .. code-block:: console $ git clone git@github.com:hobarrera/sphinx-autorun.git $ python setup.py install Configuration ----------------- To enable the autorun extension add 'sphinx_autorun' to the ``extensions`` list in :file:`conf.py`. .. code-block:: python extensions = [ 'sphinx_autorun', ] By default autorun supports ``pycon`` and ``console``. It's possible to configure autorun to run other languages. First you need to be able to pipe your source to an executable. In many cases it's already done but you can build your own program to do that. ``autorun_languages``: This is a dictionary in :file:`conf.py` that maps a language to an executable. For example: .. code-block:: python autorun_languages = {} autorun_languages['pycon']='python -' In order to pipe python code to python executable we must use the ``-`` argument. It's also possible to specify the number of characters to remove from each line before sending the code. To do that map ``${language}_prefix_chars`` to the number of characters to remove. .. code-block:: python autorun_languages = {} autorun_languages['pycon'] = 'python -' autorun_languages['pycon_prefix_chars'] = 4 Example of configuring autorun to run gnuplot scripts. .. code-block:: python autorun_languages['gnuplot'] = 'gnuplot' .. code-block:: rst .. runblock:: gnuplot set term png set out 'log.png' plot log(x) This will not produce any output on stdout but it will write the :download:`log.png` file that can be included with a standard image directive: .. code-block:: rst .. image:: log.png sphinx-autorun-1.1.0/setup.cfg000066400000000000000000000000621314262376300163430ustar00rootroot00000000000000[flake8] import-order-style=smarkets exclude=.tox sphinx-autorun-1.1.0/setup.py000066400000000000000000000024311314262376300162360ustar00rootroot00000000000000#!/usr/bin/env python3 from setuptools import setup setup( name='sphinx-autorun', url='https://github.com/hobarrera/sphinx-autorun', download_url='http://pypi.python.org/pypi/sphinx-autorun', license='BSD', author='Hugo Osvaldo Barrera', author_email='hugo@barrera.io', description='Sphinx extension autorun', long_description=open('README.rst').read(), classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Console', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Topic :: Documentation', 'Topic :: Utilities', ], platforms='any', packages=[ 'sphinx_autorun' ], include_package_data=True, install_requires=[ 'Sphinx>=0.6', ], setup_requires=[ 'setuptools_scm', ], use_scm_version={ 'version_scheme': 'post-release', 'write_to': 'sphinx_autorun/version.py', }, ) sphinx-autorun-1.1.0/sphinx_autorun/000077500000000000000000000000001314262376300176125ustar00rootroot00000000000000sphinx-autorun-1.1.0/sphinx_autorun/__init__.py000066400000000000000000000051151314262376300217250ustar00rootroot00000000000000# -*- coding: utf-8 -*- """ sphinxcontirb.autorun ~~~~~~~~~~~~~~~~~~~~~~ Run the code and insert stdout after the code block. """ import os from subprocess import PIPE, Popen from docutils import nodes from docutils.parsers.rst import Directive, directives from sphinx.errors import SphinxError from sphinx_autorun import version __version__ = version.version class RunBlockError(SphinxError): category = 'runblock error' class AutoRun(object): here = os.path.abspath(__file__) pycon = os.path.join(os.path.dirname(here), 'pycon.py') config = dict( pycon='python ' + pycon, pycon_prefix_chars=4, pycon_show_source=False, console='bash', console_prefix_chars=1, ) @classmethod def builder_init(cls, app): cls.config.update(app.builder.config.autorun_languages) class RunBlock(Directive): has_content = True required_arguments = 1 optional_arguments = 0 final_argument_whitespace = False option_spec = { 'linenos': directives.flag, } def run(self): config = AutoRun.config language = self.arguments[0] if language not in config: raise RunBlockError('Unknown language %s' % language) # Get configuration values for the language args = config[language].split() input_encoding = config.get(language+'_input_encoding', 'ascii') output_encoding = config.get(language+'_output_encoding', 'ascii') prefix_chars = config.get(language+'_prefix_chars', 0) show_source = config.get(language+'_show_source', True) # Build the code text proc = Popen(args, bufsize=1, stdin=PIPE, stdout=PIPE, stderr=PIPE) codelines = (line[prefix_chars:] for line in self.content) code = u'\n'.join(codelines).encode(input_encoding) # Run the code stdout, stderr = proc.communicate(code) # Process output if stdout: out = stdout.decode(output_encoding) if stderr: out = stderr.decode(output_encoding) # Get the original code with prefixes if show_source: code = u'\n'.join(self.content) else: code = '' code_out = u'\n'.join((code, out)) literal = nodes.literal_block(code_out, code_out) literal['language'] = language literal['linenos'] = 'linenos' in self.options return [literal] def setup(app): app.add_directive('runblock', RunBlock) app.connect('builder-inited', AutoRun.builder_init) app.add_config_value('autorun_languages', AutoRun.config, 'env') sphinx-autorun-1.1.0/sphinx_autorun/pycon.py000066400000000000000000000015411314262376300213150ustar00rootroot00000000000000import sys from code import InteractiveInterpreter def main(): """ Print lines of input along with output. """ source_lines = (line.rstrip() for line in sys.stdin) console = InteractiveInterpreter() source = '' try: while True: source = next(source_lines) # Allow the user to ignore specific lines of output. if not source.endswith('# ignore'): print('>>>', source) more = console.runsource(source) while more: next_line = next(source_lines) print('...', next_line) source += '\n' + next_line more = console.runsource(source) except StopIteration: if more: print('... ') more = console.runsource(source + '\n') if __name__ == '__main__': main() sphinx-autorun-1.1.0/tox.ini000066400000000000000000000002261314262376300160370ustar00rootroot00000000000000[tox] envlist = flake8 skip_missing_interpreters = True [testenv:flake8] skip_install = True deps = flake8 flake8-import-order commands = flake8