From 4a33f10b2bc9eadd02c4538d126d0076e591bfbd Mon Sep 17 00:00:00 2001 From: milde Date: Mon, 22 Oct 2007 09:56:40 +0000 Subject: move example files for "legacy" implementation git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@5460 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- sandbox/code-block-directive/docs/for-else-test.py | 85 ---------- .../code-block-directive/docs/for-else-test.py.htm | 185 --------------------- .../code-block-directive/docs/for-else-test.py.pdf | Bin 45325 -> 0 bytes .../code-block-directive/docs/for-else-test.py.tex | 166 ------------------ .../code-block-directive/docs/for-else-test.py.txt | 92 ---------- 5 files changed, 528 deletions(-) delete mode 100644 sandbox/code-block-directive/docs/for-else-test.py delete mode 100644 sandbox/code-block-directive/docs/for-else-test.py.htm delete mode 100644 sandbox/code-block-directive/docs/for-else-test.py.pdf delete mode 100644 sandbox/code-block-directive/docs/for-else-test.py.tex delete mode 100644 sandbox/code-block-directive/docs/for-else-test.py.txt (limited to 'sandbox/code-block-directive/docs') diff --git a/sandbox/code-block-directive/docs/for-else-test.py b/sandbox/code-block-directive/docs/for-else-test.py deleted file mode 100644 index d3edf4400..000000000 --- a/sandbox/code-block-directive/docs/for-else-test.py +++ /dev/null @@ -1,85 +0,0 @@ -# Example for syntax highlight with Pygments -# ========================================== -# -# Translate this document to HTML with a pygments enhanced frontend:: -# -# rst2html-pygments --stylesheet=pygments-default.css -# -# or to LaTeX with:: -# -# rst2latex-pygments --stylesheet=pygments-default.sty -# -# to gain syntax highlight in the output. -# -# .. Run the doctests with ``pylit --doctest for-else-test.py``. -# -# -# for-else-test -# ------------- -# -# Test the flow in a `for` loop with `else` statement. -# -# First define a simple `for` loop. -# -# .. code-block:: python - -def loop1(iterable): - """simple for loop with `else` statement""" - for i in iterable: - print i - else: - print "iterable empty" - print "Ende" - -# Now test it: -# -# The first test runs as I expect: iterator empty -> else clause applies: -# -# .. code-block:: pycon -# -# >>> loop1(range(0)) -# iterable empty -# Ende -# -# However, the else clause even runs if the iterator is not empty in the first -# place but after it is "spent": -# -# .. code-block:: pycon -# -# >>> loop1(range(3)) -# 0 -# 1 -# 2 -# iterable empty -# Ende -# -# It seems like the else clause can only be prevented, if we break out of -# the loop. Let's try -# -# .. code-block:: python - -def loop2(iterable): - """for loop with `break` and `else` statement""" - for i in iterable: - print i - break - else: - print "iterable empty" - print "Ende" - -# And indeed, the else clause is skipped after breaking out of the loop: -# -# .. code-block:: pycon -# -# >>> loop2(range(3)) -# 0 -# Ende -# -# The empty iterator runs as expected: -# -# .. code-block:: pycon -# -# >>> loop2(range(0)) -# iterable empty -# Ende -# diff --git a/sandbox/code-block-directive/docs/for-else-test.py.htm b/sandbox/code-block-directive/docs/for-else-test.py.htm deleted file mode 100644 index 1e6057be1..000000000 --- a/sandbox/code-block-directive/docs/for-else-test.py.htm +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - -Example for syntax highlight with Pygments - - - -
-

Example for syntax highlight with Pygments

-

Translate this document to HTML with a pygments enhanced frontend:

-
-rst2html-pygments --stylesheet=pygments-default.css
-
-

or to LaTeX with:

-
-rst2latex-pygments --stylesheet=pygments-default.sty
-
-

to gain syntax highlight in the output.

-

Convert between text <-> code source formats with:

-
-pylit --code-block-marker='.. code-block:: python'
-
-

Run the doctests with:

-
-pylit --doctest for-else-test.py
-
-
-

for-else-test

-

Test the flow in a for loop with else statement.

-

First define a simple for loop.

-
def loop1(iterable):
-    """simple for loop with `else` statement"""
-    for i in iterable:
-        print i
-    else:
-        print "iterable empty"
-    print "Ende"
-
-

Now test it:

-

The first test runs as I expect: iterator empty -> else clause applies:

-
>>> execfile('for-else-test.py')
->>> loop1(range(0))
-iterable empty
-Ende
-
-

However, the else clause even runs if the iterator is not empty in the first -place but after it is "spent":

-
>>> loop1(range(3))
-0
-1
-2
-iterable empty
-Ende
-
-

It seems like the else clause can only be prevented, if we break out of -the loop. Let's try

-
def loop2(iterable):
-    """for loop with `break` and `else` statement"""
-    for i in iterable:
-        print i
-        break
-    else:
-        print "iterable empty"
-    print "Ende"
-
-

And indeed, the else clause is skipped after breaking out of the loop:

-
>>> loop2(range(3))
-0
-Ende
-
-

The empty iterator runs as expected:

-
>>> loop2(range(0))
-iterable empty
-Ende
-
-
-
- - - diff --git a/sandbox/code-block-directive/docs/for-else-test.py.pdf b/sandbox/code-block-directive/docs/for-else-test.py.pdf deleted file mode 100644 index b8e63b5e8..000000000 Binary files a/sandbox/code-block-directive/docs/for-else-test.py.pdf and /dev/null differ diff --git a/sandbox/code-block-directive/docs/for-else-test.py.tex b/sandbox/code-block-directive/docs/for-else-test.py.tex deleted file mode 100644 index b664d4865..000000000 --- a/sandbox/code-block-directive/docs/for-else-test.py.tex +++ /dev/null @@ -1,166 +0,0 @@ -\documentclass[10pt,a4paper,english]{article} -\usepackage{babel} -\usepackage{ae} -\usepackage{aeguill} -\usepackage{shortvrb} -\usepackage[latin1]{inputenc} -\usepackage{tabularx} -\usepackage{longtable} -\setlength{\extrarowheight}{2pt} -\usepackage{amsmath} -\usepackage{graphicx} -\usepackage{color} -\usepackage{multirow} -\usepackage{ifthen} -\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref} -\usepackage[DIV12]{typearea} -%% generator Docutils: http://docutils.sourceforge.net/ -\newlength{\admonitionwidth} -\setlength{\admonitionwidth}{0.9\textwidth} -\newlength{\docinfowidth} -\setlength{\docinfowidth}{0.9\textwidth} -\newlength{\locallinewidth} -\newcommand{\optionlistlabel}[1]{\bf #1 \hfill} -\newenvironment{optionlist}[1] -{\begin{list}{} - {\setlength{\labelwidth}{#1} - \setlength{\rightmargin}{1cm} - \setlength{\leftmargin}{\rightmargin} - \addtolength{\leftmargin}{\labelwidth} - \addtolength{\leftmargin}{\labelsep} - \renewcommand{\makelabel}{\optionlistlabel}} -}{\end{list}} -\newlength{\lineblockindentation} -\setlength{\lineblockindentation}{2.5em} -\newenvironment{lineblock}[1] -{\begin{list}{} - {\setlength{\partopsep}{\parskip} - \addtolength{\partopsep}{\baselineskip} - \topsep0pt\itemsep0.15\baselineskip\parsep0pt - \leftmargin#1} - \raggedright} -{\end{list}} -% begin: floats for footnotes tweaking. -\setlength{\floatsep}{0.5em} -\setlength{\textfloatsep}{\fill} -\addtolength{\textfloatsep}{3em} -\renewcommand{\textfraction}{0.5} -\renewcommand{\topfraction}{0.5} -\renewcommand{\bottomfraction}{0.5} -\setcounter{totalnumber}{50} -\setcounter{topnumber}{50} -\setcounter{bottomnumber}{50} -% end floats for footnotes -% some commands, that could be overwritten in the style file. -\newcommand{\rubric}[1]{\subsection*{~\hfill {\it #1} \hfill ~}} -\newcommand{\titlereference}[1]{\textsl{#1}} -% end of "some commands" -\input{pygments-default.sty} -\title{Example for syntax highlight with Pygments} -\author{} -\date{} -\hypersetup{ -pdftitle={Example for syntax highlight with Pygments} -} -\raggedbottom -\begin{document} -\maketitle - - -\setlength{\locallinewidth}{\linewidth} -% # -*- rst-mode -*- - -Translate this document to HTML with a pygments enhanced frontend: -\begin{quote}{\ttfamily \raggedright \noindent -rst2html-pygments~-{}-stylesheet=pygments-default.css -}\end{quote} - -or to LaTeX with: -\begin{quote}{\ttfamily \raggedright \noindent -rst2latex-pygments~-{}-stylesheet=pygments-default.sty -}\end{quote} - -to gain syntax highlight in the output. -% Run the doctests with ``pylit --doctest for-else-test.py``. - - -%___________________________________________________________________________ - -\hypertarget{for-else-test}{} -\pdfbookmark[0]{for-else-test}{for-else-test} -\section*{for-else-test} - -Test the flow in a \titlereference{for} loop with \titlereference{else} statement. - -First define a simple \titlereference{for} loop. -\begin{Verbatim}[commandchars=@\[\]] -@Cax[def] @CaJ[loop1](iterable): - @Car["""simple for loop with `else` statement"""] - @Cax[for] i @Cam[in] iterable: - @Cax[print] i - @Cax[else]: - @Cax[print] @Cad["]@Cad[iterable empty]@Cad["] - @Cax[print] @Cad["]@Cad[Ende]@Cad["] - -\end{Verbatim} - -Now test it: - -The first test runs as I expect: iterator empty -{\textgreater} else clause applies: -\begin{Verbatim}[commandchars=@\[\]] -@CaN[>>> ]loop1(@CaW[range](@Cag[0])) -@Caa[iterable empty] -@Caa[Ende] - -\end{Verbatim} - -However, the else clause even runs if the iterator is not empty in the first -place but after it is ``spent'': -\begin{Verbatim}[commandchars=@\[\]] -@CaN[>>> ]loop1(@CaW[range](@Cag[3])) -@Caa[0] -@Caa[1] -@Caa[2] -@Caa[iterable empty] -@Caa[Ende] - -\end{Verbatim} - -It seems like the else clause can only be prevented, if we break out of -the loop. Let's try -\begin{Verbatim}[commandchars=@\[\]] -@Cax[def] @CaJ[loop2](iterable): - @Car["""for loop with `break` and `else` statement"""] - @Cax[for] i @Cam[in] iterable: - @Cax[print] i - @Cax[break] - @Cax[else]: - @Cax[print] @Cad["]@Cad[iterable empty]@Cad["] - @Cax[print] @Cad["]@Cad[Ende]@Cad["] - -\end{Verbatim} - -And indeed, the else clause is skipped after breaking out of the loop: -\begin{Verbatim}[commandchars=@\[\]] -@CaN[>>> ]loop2(@CaW[range](@Cag[3])) -@Caa[0] -@Caa[Ende] - -\end{Verbatim} - -The empty iterator runs as expected: -\begin{Verbatim}[commandchars=@\[\]] -@CaN[>>> ]loop2(@CaW[range](@Cag[0])) -@Caa[iterable empty] -@Caa[Ende] - -\end{Verbatim} - -\begin{center}\small - -Generated on: 2007-04-24. - - -\end{center} - -\end{document} diff --git a/sandbox/code-block-directive/docs/for-else-test.py.txt b/sandbox/code-block-directive/docs/for-else-test.py.txt deleted file mode 100644 index d9687ecd5..000000000 --- a/sandbox/code-block-directive/docs/for-else-test.py.txt +++ /dev/null @@ -1,92 +0,0 @@ -Example for syntax highlight with Pygments -========================================== - -Translate this document to HTML with a pygments enhanced frontend:: - - rst2html-pygments --stylesheet=pygments-default.css - -or to LaTeX with:: - - rst2latex-pygments --stylesheet=pygments-default.sty - -to gain syntax highlight in the output. - -Convert between text <-> code source formats with:: - - pylit --code-block-marker='.. code-block:: python' - -Run the doctests with:: - - pylit --doctest for-else-test.py - - -for-else-test -------------- - -Test the flow in a `for` loop with `else` statement. - -First define a simple `for` loop. - -.. code-block:: python - - def loop1(iterable): - """simple for loop with `else` statement""" - for i in iterable: - print i - else: - print "iterable empty" - print "Ende" - -Now test it: - -The first test runs as I expect: iterator empty -> else clause applies: - -.. code-block:: pycon - - >>> execfile('for-else-test.py') - >>> loop1(range(0)) - iterable empty - Ende - -However, the else clause even runs if the iterator is not empty in the first -place but after it is "spent": - -.. code-block:: pycon - - >>> loop1(range(3)) - 0 - 1 - 2 - iterable empty - Ende - -It seems like the else clause can only be prevented, if we break out of -the loop. Let's try - -.. code-block:: python - - def loop2(iterable): - """for loop with `break` and `else` statement""" - for i in iterable: - print i - break - else: - print "iterable empty" - print "Ende" - -And indeed, the else clause is skipped after breaking out of the loop: - -.. code-block:: pycon - - >>> loop2(range(3)) - 0 - Ende - -The empty iterator runs as expected: - -.. code-block:: pycon - - >>> loop2(range(0)) - iterable empty - Ende - -- cgit v1.2.1