Revision 7142485a
b/Makefile.am | ||
---|---|---|
197 | 197 |
|
198 | 198 |
noinst_PYTHON = \ |
199 | 199 |
lib/build/__init__.py \ |
200 |
lib/build/sphinx_ext.py |
|
200 |
lib/build/sphinx_ext.py \ |
|
201 |
lib/build/shell_example_lexer.py |
|
201 | 202 |
|
202 | 203 |
pkgpython_PYTHON = \ |
203 | 204 |
lib/__init__.py \ |
... | ... | |
427 | 428 |
# successfully, but we certainly don't want the docs to be rebuilt if |
428 | 429 |
# it changes |
429 | 430 |
doc/html/index.html: $(docrst) $(docpng) doc/conf.py configure.ac \ |
430 |
$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py lib/opcodes.py lib/ht.py \ |
|
431 |
$(RUN_IN_TEMPDIR) lib/build/sphinx_ext.py \ |
|
432 |
lib/build/shell_example_lexer.py lib/opcodes.py lib/ht.py \ |
|
431 | 433 |
| $(BUILT_PYTHON_SOURCES) |
432 | 434 |
@test -n "$(SPHINX)" || \ |
433 | 435 |
{ echo 'sphinx-build' not found during configure; exit 1; } |
... | ... | |
991 | 993 |
{ echo 'pandoc' not found during configure; exit 1; } |
992 | 994 |
$(PANDOC) -f rst -t html -o $@ $< |
993 | 995 |
|
994 |
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py |
|
996 |
man/%.gen: man/%.rst lib/query.py lib/build/sphinx_ext.py \ |
|
997 |
lib/build/shell_example_lexer.py |
|
995 | 998 |
PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(DOCPP) < $< > $@ |
996 | 999 |
|
997 | 1000 |
man/%.7.in man/%.8.in man/%.1.in: man/%.gen man/footer.man |
b/doc/conf.py | ||
---|---|---|
29 | 29 |
"sphinx.ext.todo", |
30 | 30 |
"sphinx.ext.graphviz", |
31 | 31 |
"ganeti.build.sphinx_ext", |
32 |
"ganeti.build.shell_example_lexer", |
|
32 | 33 |
] |
33 | 34 |
|
34 | 35 |
# Add any paths that contain templates here, relative to this directory. |
... | ... | |
45 | 46 |
|
46 | 47 |
# General information about the project. |
47 | 48 |
project = u"Ganeti" |
48 |
copyright = u"2006, 2007, 2008, 2009, 2010, 2011, Google Inc." |
|
49 |
copyright = u"2006, 2007, 2008, 2009, 2010, 2011, 2012, Google Inc."
|
|
49 | 50 |
|
50 | 51 |
# The version info for the project you're documenting, acts as replacement for |
51 | 52 |
# |version| and |release|, also used in various other places throughout the |
b/lib/build/shell_example_lexer.py | ||
---|---|---|
1 |
# |
|
2 |
# |
|
3 |
|
|
4 |
# Copyright (C) 2012 Google Inc. |
|
5 |
# |
|
6 |
# This program is free software; you can redistribute it and/or modify |
|
7 |
# it under the terms of the GNU General Public License as published by |
|
8 |
# the Free Software Foundation; either version 2 of the License, or |
|
9 |
# (at your option) any later version. |
|
10 |
# |
|
11 |
# This program is distributed in the hope that it will be useful, but |
|
12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
# General Public License for more details. |
|
15 |
# |
|
16 |
# You should have received a copy of the GNU General Public License |
|
17 |
# along with this program; if not, write to the Free Software |
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
19 |
# 02110-1301, USA. |
|
20 |
|
|
21 |
|
|
22 |
"""Pygments lexer for our custom shell example sessions. |
|
23 |
|
|
24 |
The lexer support the following custom markup: |
|
25 |
|
|
26 |
- comments: # this is a comment |
|
27 |
- command lines: '$ ' at the beginning of a line denotes a command |
|
28 |
- variable input: %input% (works in both commands and screen output) |
|
29 |
- otherwise, regular text output from commands will be plain |
|
30 |
|
|
31 |
""" |
|
32 |
|
|
33 |
from pygments.lexer import RegexLexer, bygroups, include |
|
34 |
from pygments.token import Name, Text, Generic, Comment |
|
35 |
|
|
36 |
|
|
37 |
class ShellExampleLexer(RegexLexer): |
|
38 |
name = "ShellExampleLexer" |
|
39 |
aliases = "shell-example" |
|
40 |
filenames = [] |
|
41 |
|
|
42 |
tokens = { |
|
43 |
"root": [ |
|
44 |
include("comments"), |
|
45 |
include("userinput"), |
|
46 |
# switch to state input on '$ ' at the start of the line |
|
47 |
(r"^\$ ", Text, "input"), |
|
48 |
(r"\s+", Text), |
|
49 |
(r"[^#%\s]+", Text), |
|
50 |
], |
|
51 |
"input": [ |
|
52 |
include("comments"), |
|
53 |
include("userinput"), |
|
54 |
(r"[^%\\\s]+", Generic.Strong), |
|
55 |
(r"\\\n", Generic.Strong), |
|
56 |
(r"\\", Generic.Strong), |
|
57 |
# switch to prev state at non-escaped new-line |
|
58 |
(r"\n", Text, "#pop"), |
|
59 |
(r"\s+", Text), |
|
60 |
], |
|
61 |
"comments": [ |
|
62 |
(r"#.*\n", Comment.Single), |
|
63 |
], |
|
64 |
"userinput": [ |
|
65 |
(r"\\%", Text), |
|
66 |
(r"(%)([^%]*)(%)", bygroups(None, Name.Variable, None)), |
|
67 |
], |
|
68 |
} |
|
69 |
|
|
70 |
|
|
71 |
def setup(app): |
|
72 |
app.add_lexer("shell-example", ShellExampleLexer()) |
Also available in: Unified diff