[New-bugs-announce] [issue2154] doc: better detection of python snippets for highliting

Amaury Forgeot d'Arc report at bugs.python.org
Thu Feb 21 15:26:45 CET 2008


New submission from Amaury Forgeot d'Arc:

The new doc framework highlights python code, and looks very nice.
However, some snippets are not parseable by the compiler, and are thus
left unhighlighted. For example:
http://docs.python.org/dev/whatsnew/2.6.html#the-contextlib-module

The vast majority of misses is because of lines containing "...", which
is not a valid expression (except in slices).
The attached patch tries to recognize some common patterns, and replaces
"..." by some valid identifier; "... continue processing ..." is also
transformed. 

Note that the replacements are done only to get a better answer to "is
this block a python code"; pygment still works on the original string.

I checked that all new highlighted blocks are actually python snippets.
(actually, except one in configfile.rst; but others similar blocks on
the same page were already wrongly given to the python lexer)

The patch also corrects some easy syntax errors in samples.

----------
components: Documentation, Documentation tools (Sphinx)
files: doc_highlight.patch
keywords: patch
messages: 62623
nosy: amaury.forgeotdarc, georg.brandl
severity: normal
status: open
title: doc: better detection of python snippets for highliting
versions: Python 2.6
Added file: http://bugs.python.org/file9480/doc_highlight.patch

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2154>
__________________________________


More information about the New-bugs-announce mailing list