summaryrefslogtreecommitdiff
path: root/sandbox/code-block-directive/docs/myfunction.py.txt
blob: cce27ea52455d695bbf9ea911742f0f9818d1200 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
This is a test of the new "code" directive:

.. Translate this document with a pygments enhanced frontend, e.g.

    ../rst2html-highlight.py --stylesheet=../data/pygments-default.css
    ../rst2latex-highlight.py --stylesheet=../data/pygments-docutilsroles.sty
    
   or via the test case in
   
    ../pygments_code_block_directive.py --traceback
    

The example from Docutils TODO list:

.. code:: python

  print 'This is Python code.'
  for i in range(10):
      print i

Numbered lines:

.. code:: python
  :number-lines:

  # This is Python code,
  # that prints the integers from 0 to 9
  for i in range(10):
      print i

Another example:

.. code:: python
  :class: silly
  :name: my_function
  :number-lines: 7

  def my_function():
      """Test the lexer.
      """

      # and now for something completely different
      print 8/2

The end.