Release coccinelle-0.2.3rc1
[bpt/coccinelle.git] / docs / manual / python.tex
1 \documentclass{article}
2
3 \usepackage[utf8]{inputenc}
4 \usepackage[T1]{fontenc}
5
6 \usepackage{listings}
7
8 \begin{document}
9 \section{Python API from SmPL}
10 \label{sec:python-api}
11
12 \subsection{Output mode}
13 \label{sec:output}
14
15 \begin{tabular}{lp{8cm}}
16 \texttt{-pyoutput coccilib.output.Console}& To output on the console \\
17 \texttt{-pyoutput coccilib.output.Gtk} & To output on a Gtk frame \\
18 \end{tabular}
19
20 \subsection{Org mode}
21 \label{sec:orgmode}
22
23 \begin{tabular}{lp{8cm}}
24 \texttt{cocci.print\_main}& For the main position \\
25 \texttt{cocci.print\_sec} & For the secondary position \\
26 \texttt{cocci.print\_secs}& For a set of secondary positions \\
27 \end{tabular}
28
29 \begin{lstlisting}
30 def print_main(p, msg="", color="ovl-face1") :
31 print "* TODO [[view:%s::face=%s::linb=%s::colb=%s::cole=%s][%s %s::%s]]" % (p[0].file,color,p[0].line,p[0].column,p[0].column_end,msg,p[0].file,p[0].line)
32
33 def print_sec(p, msg="", color="ovl-face2") :
34 print "[[view:%s::face=%s::linb=%s::colb=%s::cole=%s][%s]]" % (p[0].file,color,p[0].line,p[0].column,p[0].column_end,msg)
35
36 def print_secs(ps, msg="", color="ovl-face2") :
37 for i in ps:
38 print "[[view:%s::face=%s::linb=%s::colb=%s::cole=%s][%s]]" % (i.file,color,i.line,i.column,i.column_end,msg)
39 \end{lstlisting}
40
41 %\subsection{Trac}
42 %\label{sec:trac}
43
44
45 \end{document}
46
47 %%% Local Variables:
48 %%% mode: LaTeX
49 %%% TeX-master: t
50 %%% coding: utf-8
51 %%% TeX-PDF-mode: t
52 %%% ispell-local-dictionary: "american"
53 %%% End: