Menu

[r10204]: / trunk / sandbox / code-block-directive / docs / myfunction.py.txt  Maximize  Restore  History

Download this file

92 lines (64 with data), 1.8 kB

 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
This is a test of the new "code" directive:
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
And now some CSS:
.. code:: css
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
as well as TeX:
.. code:: tex
% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
\usepackage[linkcolor=blue,urlcolor=blue]{hyperref}
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
\begin{document}
The area of a circle is $A = \pi/4 d^2$
\end{document}
You can also highlight a diff:
.. code:: diff
Index: html4css1.css
===================================================================
--- html4css1.css (Revision 7509)
+++ html4css1.css (Arbeitskopie)
@@ -68,7 +68,7 @@
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
-div.warning p.admonition-title {
+div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
Inline code
***********
.. role:: tex(code)
:language: tex
.. role:: python(code)
:language: python
:class: testclass
Inline code in LaTeX :tex:`$\alpha = \int_0^\infty f(x) dx$` and
Python: :python:`print("The end.")`.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.